1 /**
2 ****************************************************************************************
3 * @file gr55xx_hal.c
4 * @author BLE Driver Team
5 * @brief 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_UART_MODULE_ENABLED) && (defined(GR5515_D) || defined(GR5515_E))
41
42 /* Private variables ---------------------------------------------------------*/
43
44 static hal_uart_callback_t uart_callback = {
45 .uart_msp_init = hal_uart_msp_init,
46 .uart_msp_deinit = hal_uart_msp_deinit,
47 .uart_tx_cplt_callback = hal_uart_tx_cplt_callback,
48 .uart_rx_cplt_callback = hal_uart_rx_cplt_callback,
49 .uart_error_callback = hal_uart_error_callback,
50 .uart_abort_cplt_callback = hal_uart_abort_cplt_callback,
51 .uart_abort_tx_cplt_callback = hal_uart_abort_tx_cplt_callback,
52 .uart_abort_rx_cplt_callback = hal_uart_abort_rx_cplt_callback
53 };
54
55 /* Private function prototypes -----------------------------------------------*/
56
hal_uart_init(uart_handle_t * p_uart)57 hal_status_t hal_uart_init(uart_handle_t *p_uart)
58 {
59 hal_uart_register_callback(&uart_callback);
60
61 hal_status_t ret;
62 GLOBAL_EXCEPTION_DISABLE();
63 ret = hal_uart_init_ext(p_uart);
64 GLOBAL_EXCEPTION_ENABLE();
65
66 return ret;
67 }
68
hal_uart_deinit(uart_handle_t * p_uart)69 hal_status_t hal_uart_deinit(uart_handle_t *p_uart)
70 {
71 hal_uart_register_callback(&uart_callback);
72
73 hal_status_t ret;
74 GLOBAL_EXCEPTION_DISABLE();
75 ret = hal_uart_deinit_ext(p_uart);
76 GLOBAL_EXCEPTION_ENABLE();
77
78 return ret;
79 }
80
hal_uart_msp_init(uart_handle_t * p_uart)81 __WEAK void hal_uart_msp_init(uart_handle_t *p_uart)
82 {
83 /* Prevent unused argument(s) compilation warning */
84 UNUSED(p_uart);
85 }
86
hal_uart_msp_deinit(uart_handle_t * p_uart)87 __WEAK void hal_uart_msp_deinit(uart_handle_t *p_uart)
88 {
89 /* Prevent unused argument(s) compilation warning */
90 UNUSED(p_uart);
91 }
92
hal_uart_tx_cplt_callback(uart_handle_t * p_uart)93 __WEAK void hal_uart_tx_cplt_callback(uart_handle_t *p_uart)
94 {
95 /* Prevent unused argument(s) compilation warning */
96 UNUSED(p_uart);
97 }
98
hal_uart_rx_cplt_callback(uart_handle_t * p_uart)99 __WEAK void hal_uart_rx_cplt_callback(uart_handle_t *p_uart)
100 {
101 /* Prevent unused argument(s) compilation warning */
102 UNUSED(p_uart);
103 }
104
hal_uart_error_callback(uart_handle_t * p_uart)105 __WEAK void hal_uart_error_callback(uart_handle_t *p_uart)
106 {
107 /* Prevent unused argument(s) compilation warning */
108 UNUSED(p_uart);
109 }
110
hal_uart_abort_cplt_callback(uart_handle_t * p_uart)111 __WEAK void hal_uart_abort_cplt_callback (uart_handle_t *p_uart)
112 {
113 /* Prevent unused argument(s) compilation warning */
114 UNUSED(p_uart);
115 }
116
hal_uart_abort_tx_cplt_callback(uart_handle_t * p_uart)117 __WEAK void hal_uart_abort_tx_cplt_callback (uart_handle_t *p_uart)
118 {
119 /* Prevent unused argument(s) compilation warning */
120 UNUSED(p_uart);
121 }
122
hal_uart_abort_rx_cplt_callback(uart_handle_t * p_uart)123 __WEAK void hal_uart_abort_rx_cplt_callback (uart_handle_t *p_uart)
124 {
125 /* Prevent unused argument(s) compilation warning */
126 UNUSED(p_uart);
127 }
128
129 #endif
130