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 ------------------------------------------------------------*/
101 #define CO_MAX(a,b) ((a) > (b) ? (a) : (b))
102
106 #define BLE_INT_DISABLE() \
107 do { \
108 volatile uint32_t __ble_l_irq_rest = __get_PRIMASK(); \
109 volatile bool __ble_int_status = NVIC_GetEnableIRQ(BLE_IRQn) || NVIC_GetEnableIRQ(BLESLP_IRQn); \
110 __set_PRIMASK(1); \
111 if (__ble_int_status) \
112 { \
113 NVIC_DisableIRQ(BLE_IRQn); \
114 NVIC_DisableIRQ(BLESLP_IRQn); \
115 } \
116 __set_PRIMASK(__ble_l_irq_rest);
117
121 #define BLE_INT_RESTORE() \
122 __ble_l_irq_rest = __get_PRIMASK(); \
123 __set_PRIMASK(1); \
124 if (__ble_int_status) \
125 { \
126 NVIC_EnableIRQ(BLE_IRQn); \
127 NVIC_EnableIRQ(BLESLP_IRQn); \
128 } \
129 __set_PRIMASK(__ble_l_irq_rest); \
130 } while(0)
131
132
133 #ifdef GR5515_E
134
137 #define GLOBAL_INT_DISABLE() \
138 do { \
139 extern uint32_t global_int_disable(void); \
140 uint32_t __res_mask = global_int_disable()
141
145 #define GLOBAL_INT_RESTORE() \
146 extern void global_int_enable(uint32_t mask); \
147 global_int_enable(__res_mask); \
148 } while(0)
149 #else
150
155 #define GLOBAL_INT_DISABLE() \
156 do { \
157 volatile uint32_t __nvic_iser0 = 0xFFFFFFFF; \
158 volatile uint32_t __nvic_iser1 = 0xFFFFFFFF; \
159 volatile uint32_t __ret_pri = __get_PRIMASK(); \
160 __set_PRIMASK(1); \
161 if( (NVIC->ICER[0] != 0xFFFFFFFF) || (NVIC->ICER[1] != 0xFFFFFFFF) ) \
162 { \
163 __nvic_iser0 = NVIC->ISER[0]; \
164 __nvic_iser1 = NVIC->ISER[1]; \
165 NVIC->ICER[0] = 0xFFFFFFFF; \
166 NVIC->ICER[1] = 0xFFFFFFFF; \
167 } \
168 __set_PRIMASK(__ret_pri); \
169 __DSB(); \
170 __ISB(); \
171
172
175 #define GLOBAL_INT_RESTORE() \
176 __ret_pri = __get_PRIMASK(); \
177 __set_PRIMASK(1); \
178 if( (__nvic_iser0 != 0xFFFFFFFF) || (__nvic_iser1 != 0xFFFFFFFF) ) \
179 { \
180 NVIC->ISER[0] = __nvic_iser0; \
181 NVIC->ISER[1] = __nvic_iser1; \
182 } \
183 __set_PRIMASK(__ret_pri); \
184 } while(0)
185 #endif
186
192 #define LOCAL_INT_DISABLE(IRQn_Type) \
193 do { \
194 uint32_t __l_irq_rest = __get_BASEPRI(); \
195 __set_BASEPRI(NVIC_GetPriority(IRQn_Type) + \
196 (1 << (NVIC_GetPriorityGrouping() + 1))); \
197
198
201 #define LOCAL_INT_RESTORE() \
202 __set_BASEPRI(__l_irq_rest); \
203 } while(0)
204
205
208 #define CHECK_IS_ON_FPGA() (AON->FPGA_CTRL & AON_REG_FPGA_CTRL_EXIST)
209
210 #define SYSTICK_RELOAD_VALUE (SysTick->LOAD)
211 #define SYSTICK_CURRENT_VALUE (SysTick->VAL)
217 /* Exported types ------------------------------------------------------------*/
218 /* Exported constants --------------------------------------------------------*/
219 /* Exported functions --------------------------------------------------------*/
275 hal_status_t hal_init(void);
276
290 hal_status_t hal_deinit(void);
291
300 void hal_msp_init(void);
301
310 void hal_msp_deinit(void);
311
324 hal_status_t hal_init_tick (uint32_t tick_priority);
325
356 void hal_suspend_tick(void);
357
370 void hal_resume_tick(void);
371
379 uint32_t hal_get_hal_version(void);
380
385 #ifdef __cplusplus
386 }
387 #endif
388
389 #endif /* __GR55xx_HAL_H__ */
390
_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.