1 /**
2 ****************************************************************************************
3 * @file gr55xx_hal_i2s_br.c
4 * @author BLE Driver Team
5 * @brief I2S HAL module driver.
6 ****************************************************************************************
7 * @attention
8 #####Copyright (c) 2019 GOODIX
9 All rights reserved.
10
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are met:
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in the
17 documentation and/or other materials provided with the distribution.
18 * Neither the name of GOODIX nor the names of its contributors may be used
19 to endorse or promote products derived from this software without
20 specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
26 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 POSSIBILITY OF SUCH DAMAGE.
33 ****************************************************************************************
34 */
35
36 /* Includes ------------------------------------------------------------------*/
37 #include "gr55xx_hal.h"
38 #include "gr55xx_rom_symbol.h"
39
40 #if defined(HAL_I2S_MODULE_ENABLED) && (defined(GR5515_D) || defined(GR5515_E))
41
42 /* Private variables ---------------------------------------------------------*/
43
44 static hal_i2s_callback_t i2s_callback = {
45 .i2s_msp_init = hal_i2s_msp_init,
46 .i2s_msp_deinit = hal_i2s_msp_deinit,
47 .i2s_error_callback = hal_i2s_error_callback,
48 .i2s_rx_cplt_callback = hal_i2s_rx_cplt_callback,
49 .i2s_tx_cplt_callback = hal_i2s_tx_cplt_callback,
50 .i2s_tx_rx_cplt_callback = hal_i2s_tx_rx_cplt_callback,
51 };
52
53 /* Private function prototypes -----------------------------------------------*/
54
hal_i2s_init(i2s_handle_t * p_i2s)55 hal_status_t hal_i2s_init(i2s_handle_t *p_i2s)
56 {
57 hal_i2s_register_callback(&i2s_callback);
58
59 hal_status_t ret;
60 GLOBAL_EXCEPTION_DISABLE();
61 ret = hal_i2s_init_ext(p_i2s);
62 GLOBAL_EXCEPTION_ENABLE();
63
64 return ret;
65 }
66
hal_i2s_deinit(i2s_handle_t * p_i2s)67 hal_status_t hal_i2s_deinit(i2s_handle_t *p_i2s)
68 {
69 hal_i2s_register_callback(&i2s_callback);
70
71 hal_status_t ret;
72 GLOBAL_EXCEPTION_DISABLE();
73 ret = hal_i2s_deinit_ext(p_i2s);
74 GLOBAL_EXCEPTION_ENABLE();
75
76 return ret;
77 }
78
hal_i2s_msp_init(i2s_handle_t * p_i2s)79 __WEAK void hal_i2s_msp_init(i2s_handle_t *p_i2s)
80 {
81 /* Prevent unused argument(s) compilation warning */
82 return;
83
84 /* NOTE : This function should not be modified, when the callback is needed,
85 the hal_i2s_msp_init can be implemented in the user file
86 */
87 }
88
hal_i2s_msp_deinit(i2s_handle_t * p_i2s)89 __WEAK void hal_i2s_msp_deinit(i2s_handle_t *p_i2s)
90 {
91 /* Prevent unused argument(s) compilation warning */
92 return;
93
94 /* NOTE : This function should not be modified, when the callback is needed,
95 the hal_i2s_msp_deinit can be implemented in the user file
96 */
97 }
98
hal_i2s_error_callback(i2s_handle_t * p_i2s)99 __WEAK void hal_i2s_error_callback(i2s_handle_t *p_i2s)
100 {
101 /* Prevent unused argument(s) compilation warning */
102 UNUSED(p_i2s);
103 }
104
hal_i2s_rx_cplt_callback(i2s_handle_t * p_i2s)105 __WEAK void hal_i2s_rx_cplt_callback(i2s_handle_t *p_i2s)
106 {
107 /* Prevent unused argument(s) compilation warning */
108 UNUSED(p_i2s);
109 }
110
hal_i2s_tx_cplt_callback(i2s_handle_t * p_i2s)111 __WEAK void hal_i2s_tx_cplt_callback(i2s_handle_t *p_i2s)
112 {
113 /* Prevent unused argument(s) compilation warning */
114 UNUSED(p_i2s);
115 }
116
hal_i2s_tx_rx_cplt_callback(i2s_handle_t * p_i2s)117 __WEAK void hal_i2s_tx_rx_cplt_callback(i2s_handle_t *p_i2s)
118 {
119 /* Prevent unused argument(s) compilation warning */
120 UNUSED(p_i2s);
121 }
122
123 #endif /* HAL_I2S_MODULE_ENABLED */
124