gr55xx_hal.h
Go to the documentation of this file.
1
52 /* Define to prevent recursive inclusion -------------------------------------*/
53 #ifndef __GR55xx_HAL_H__
54 #define __GR55xx_HAL_H__
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60 /* Includes ------------------------------------------------------------------*/
61 #include "gr55xx.h"
62 #include "gr55xx_hal_conf.h"
63 #include "gr55xx_delay.h"
64
77 typedef struct _hal_callback
78 {
79 void (*msp_init)(void);
80 void (*msp_deinit)(void);
81 } hal_callback_t;
82
92 /* Private macros ------------------------------------------------------------*/
93 /* Exported macros ------------------------------------------------------------*/
98 //** @brief Disable interrupts globally in the system(apart from the NMI).
99 // * This macro must be used in conjunction with the @ref GLOBAL_EXCEPTION_ENABLE macro
100 // * since this last one will close the brace that the current macro opens. This means
101 // * that both macros must be located at the same scope level.
102 // */
103 //#define GLOBAL_EXCEPTION_DISABLE() \
104 //do { \
105 // uint32_t __l_irq_rest = __get_PRIMASK(); \
106 // __set_PRIMASK(1)
107
108
109 //** @brief Restore interrupts from the previous global disable(apart from the NMI).
110 // * @sa GLOBAL_EXCEPTION_ENABLE
111 // */
112 //#define GLOBAL_EXCEPTION_ENABLE() \
113 // if(__l_irq_rest == 0) \
114 // { \
115 // __set_PRIMASK(0); \
116 // } \
117 // else \
118 // { \
119 // __set_PRIMASK(1); \
120 // } \
121 //} while(0)
122
126 #define CO_MAX(a,b) ((a) > (b) ? (a) : (b))
127
131 #define BLE_INT_DISABLE() \
132 do { \
133 volatile uint32_t __ble_l_irq_rest = __get_PRIMASK(); \
134 volatile bool __ble_int_status = NVIC_GetEnableIRQ(BLE_IRQn) || NVIC_GetEnableIRQ(BLESLP_IRQn); \
135 __set_PRIMASK(1); \
136 if (__ble_int_status) \
137 { \
138 NVIC_DisableIRQ(BLE_IRQn); \
139 NVIC_DisableIRQ(BLESLP_IRQn); \
140 } \
141 __set_PRIMASK(__ble_l_irq_rest);
142
146 #define BLE_INT_RESTORE() \
147 __ble_l_irq_rest = __get_PRIMASK(); \
148 __set_PRIMASK(1); \
149 if (__ble_int_status) \
150 { \
151 NVIC_EnableIRQ(BLE_IRQn); \
152 NVIC_EnableIRQ(BLESLP_IRQn); \
153 } \
154 __set_PRIMASK(__ble_l_irq_rest); \
155 } while(0)
156
157 #ifdef GR5515_E
158
161 #define GLOBAL_INT_DISABLE() \
162 do { \
163 extern uint32_t global_int_disable(void); \
164 uint32_t __res_mask = global_int_disable()
165
169 #define GLOBAL_INT_RESTORE() \
170 extern void global_int_enable(uint32_t mask); \
171 global_int_enable(__res_mask); \
172 } while(0)
173 #else
174
179 #define GLOBAL_INT_DISABLE() \
180 do { \
181 volatile uint32_t __nvic_iser0 = 0xFFFFFFFF; \
182 volatile uint32_t __nvic_iser1 = 0xFFFFFFFF; \
183 volatile uint32_t __ret_pri = __get_PRIMASK(); \
184 __set_PRIMASK(1); \
185 if( (NVIC->ICER[0] != 0xFFFFFFFF) || (NVIC->ICER[1] != 0xFFFFFFFF) ) \
186 { \
187 __nvic_iser0 = NVIC->ISER[0]; \
188 __nvic_iser1 = NVIC->ISER[1]; \
189 NVIC->ICER[0] = 0xFFFFFFFF; \
190 NVIC->ICER[1] = 0xFFFFFFFF; \
191 } \
192 __set_PRIMASK(__ret_pri); \
193 __DSB(); \
194 __ISB(); \
195
196
199 #define GLOBAL_INT_RESTORE() \
200 __ret_pri = __get_PRIMASK(); \
201 __set_PRIMASK(1); \
202 if( (__nvic_iser0 != 0xFFFFFFFF) || (__nvic_iser1 != 0xFFFFFFFF) ) \
203 { \
204 NVIC->ISER[0] = __nvic_iser0; \
205 NVIC->ISER[1] = __nvic_iser1; \
206 } \
207 __set_PRIMASK(__ret_pri); \
208 } while(0)
209 #endif
210
216 #define LOCAL_INT_DISABLE(IRQn_Type) \
217 do { \
218 uint32_t __l_irq_rest = __get_BASEPRI(); \
219 __set_BASEPRI(NVIC_GetPriority(IRQn_Type) + \
220 (1 << (NVIC_GetPriorityGrouping() + 1))); \
221
222
225 #define LOCAL_INT_RESTORE() \
226 __set_BASEPRI(__l_irq_rest); \
227 } while(0)
228
229
232 #define CHECK_IS_ON_FPGA() (AON->FPGA_CTRL & AON_REG_FPGA_CTRL_EXIST)
233
234 #define SYSTICK_RELOAD_VALUE (SysTick->LOAD)
235 #define SYSTICK_CURRENT_VALUE (SysTick->VAL)
241 /* Exported types ------------------------------------------------------------*/
242 /* Exported constants --------------------------------------------------------*/
243 /* Exported functions --------------------------------------------------------*/
299 hal_status_t hal_init(void);
300
314 hal_status_t hal_deinit(void);
315
324 void hal_msp_init(void);
325
334 void hal_msp_deinit(void);
335
348 hal_status_t hal_init_tick (uint32_t tick_priority);
349
380 void hal_suspend_tick(void);
381
394 void hal_resume_tick(void);
395
403 uint32_t hal_get_hal_version(void);
404
409 #ifdef __cplusplus
410 }
411 #endif
412
413 #endif /* __GR55xx_HAL_H__ */
414
_hal_callback::msp_deinit
void(* msp_deinit)(void)
Definition: gr55xx_hal.h:80
gr55xx_delay.h
PERIPHERAL API DELAY DRIVER.
hal_init
hal_status_t hal_init(void)
This function configures time base source, NVIC and Low level hardware.
hal_get_hal_version
uint32_t hal_get_hal_version(void)
This function returns the HAL revision.
hal_callback_t
struct _hal_callback hal_callback_t
HAL_HAL Callback function definition.
hal_suspend_tick
void hal_suspend_tick(void)
Suspend Tick increment.
hal_deinit
hal_status_t hal_deinit(void)
This function de-initializes common part of the HAL and stops the source of time base.
hal_resume_tick
void hal_resume_tick(void)
Resume Tick increment.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
_hal_callback
HAL_HAL Callback function definition.
Definition: gr55xx_hal.h:78
hal_init_tick
hal_status_t hal_init_tick(uint32_t tick_priority)
This function configures the source of the time base.
_hal_callback::msp_init
void(* msp_init)(void)
Definition: gr55xx_hal.h:79
hal_msp_init
void hal_msp_init(void)
Initialize the MSP.
hal_msp_deinit
void hal_msp_deinit(void)
De-initialize the MSP.
gr55xx_hal_conf.h
HAL configuration file.