gr_common.h
Go to the documentation of this file.
1
#ifndef __GR_COMMON_H
2
#define __GR_COMMON_H
3
4
#include "cmsis_compiler.h"
5
#include "
gr5x.h
"
6
7
//lint -e621 [required] Identifier clash, e.g. "ll_xx_status" and "ll_xx_enabled"
8
//lint -e9031 [required] Composite expression assigned to a wider essential type
9
//lint -e9032 [required] Composite expression with smaller essential type than other operand
10
//lint -e9053 [required] the shift value is at least the precision of the essential type of the left hand side
11
//lint -e578 [required] Declaration of symbol 'xxx' hides symbol 'xxx'
12
//lint -e715 [advisory] Symbol not referenced
13
//lint -e750 [advisory][Info] local macro not referenced
14
//lint -e765 [advisory][Info] XXX could be made static
15
//lint -e801 [advisory][Info] Use of goto is deprecated
16
//lint -e818 [advisory] Pointer parameter could be declared as pointing to const
17
//lint -e835 [advisory][Info] Use of goto is deprecated
18
//lint -e904 [advisory] Return statement before end of function
19
//lint -e954 [advisory] Pointer variable could be declared as pointing to const
20
//lint -e970 [advisory] Use of modifier or type '_Bool' outside of a typedef
21
//lint -e9003 [advisory] could define variable at block scope
22
//lint -e9011 [advisory] more than one 'break' terminates loop
23
//lint -e9016 [advisory] pointer arithmetic other than array indexing used
24
//lint -e9026 [advisory] Function-like macro defined
25
//lint -e9030 [advisory] Impermissible cast; cannot cast from 'essentially unsigned' to 'essentially Boolean'
26
//lint -e9045 [advisory] non-hidden definition of type 'xxx'
27
//lint -e9049 [advisory] increment/decrement operation combined with other operation with side-effects
28
//lint -e9050 [advisory] dependence placed on C/C++ operator precedence; operators '*' and '+'
29
//lint -e9058 [advisory] tag unused
30
//lint -e9078 [advisory] conversion between a pointer and integer type
31
//lint -e9079 [advisory] Conversion from pointer to void to pointer to other type
32
//lint -e701 [Info] Info 701: Shift left of signed quantity (int)
33
//lint -e716 [Info] while(1)
34
//lint -e717 [Info] do ... while(0);
35
//lint -e725 [Info] Expected positive indentation
36
//lint -e754 [Info] local struct member not referenced
37
//lint -e766 [Info] Header file not used in module
38
//lint -e788 [Info] enum constant not used within defaulted switch
39
//lint -e826 [Info] Suspicious pointer-to-pointer conversion (area too small)
40
//lint -e830 [Info] Location/Reference cited in prior message
41
//lint -e834 [Info] Operator is confusing. Use parentheses.
42
//lint -e835 [Info] A zero has been given as right argument to operator '<<'
43
//lint -e838 [Info] Previously assigned value has not been used
44
//lint -e845 [Info] The right argument to operator '|' is certain to be 0
45
46
/* Exported macro ------------------------------------------------------------*/
47
#ifdef USE_FULL_ASSERT
48
/**
49
* @brief The gr_assert_param macro is used for function's parameters check.
50
* @param expr If expr is false, it calls assert_failed function
51
* which reports the name of the source file and the source
52
* line number of the call that failed.
53
* If expr is true, it returns no value.
54
* @retval None
55
*/
56
#define gr_assert_param(expr) ((expr) ? (void)0U : assert_failed((char *)__FILE__, __LINE__))
57
/* Exported functions ------------------------------------------------------- */
58
__STATIC_INLINE
void
assert_failed(
char
*file, uint32_t line)
59
{
60
61
}
62
#else
63
#define gr_assert_param(expr) ((void)0U)
64
#endif
/* USE_FULL_ASSERT */
65
66
67
68
/** @brief Disable interrupts globally in the system(apart from the NMI).
69
* This macro must be used in conjunction with the @ref GLOBAL_EXCEPTION_ENABLE macro
70
* since this last one will close the brace that the current macro opens. This means
71
* that both macros must be located at the same scope level.
72
*/
73
#ifndef GLOBAL_EXCEPTION_DISABLE
74
#define GLOBAL_EXCEPTION_DISABLE() \
75
do { \
76
uint32_t __l_irq_rest = __get_PRIMASK(); \
77
__set_PRIMASK(1)
78
#endif
79
80
/** @brief Restore interrupts from the previous global disable(apart from the NMI).
81
* @sa GLOBAL_EXCEPTION_ENABLE
82
*/
83
#ifndef GLOBAL_EXCEPTION_ENABLE
84
//lint -e9036 while(0U) is right
85
#define GLOBAL_EXCEPTION_ENABLE() \
86
if(__l_irq_rest == (uint32_t)0) \
87
{ \
88
__set_PRIMASK(0); \
89
} \
90
else \
91
{ \
92
__set_PRIMASK(1); \
93
} \
94
} while(0)
95
#endif
96
97
/** @brief Disable interrupts globally in the system.
98
* This macro must be used in conjunction with the @ref GLOBAL_INT_RESTORE macro.
99
*/
100
#ifndef GLOBAL_INT_DISABLE
101
#define GLOBAL_INT_DISABLE() \
102
do { \
103
extern uint32_t global_int_disable(void); \
104
uint32_t __res_mask = global_int_disable()
105
#endif
106
107
/** @brief Restore global interrupt.
108
* @sa GLOBAL_INT_RESTORE
109
*/
110
#ifndef GLOBAL_INT_RESTORE
111
#define GLOBAL_INT_RESTORE() \
112
extern void global_int_enable(uint32_t mask); \
113
global_int_enable(__res_mask); \
114
} while(0)
115
#endif
116
117
/** @brief Disable external interrupts with a priority lower than IRQn_Type in the system.
118
* This macro must be used in conjunction with the @ref LOCAL_INT_RESTORE macro
119
* since this last one will close the brace that the current macro opens. This
120
* means that both macros must be located at the same scope level.
121
*/
122
#define LOCAL_INT_DISABLE(IRQn_Type) \
123
do { \
124
uint32_t __l_irq_rest = __get_BASEPRI(); \
125
__set_BASEPRI(NVIC_GetPriority(IRQn_Type) + \
126
(1 << (NVIC_GetPriorityGrouping() + 1))); \
127
128
/** @brief Restore external interrupts(apart from the BLE) from the previous disable.
129
* @sa EXP_BLE_INT_RESTORE
130
*/
131
#define LOCAL_INT_RESTORE() \
132
__set_BASEPRI(__l_irq_rest); \
133
} while(0)
134
135
136
/**
137
* @brief HAL Status structures definition
138
*/
139
typedef
enum
140
{
141
HAL_OK
= 0x00U,
/**< Operation is OK. */
142
HAL_ERROR
= 0x01U,
/**< Parameter error or operation is not supported. */
143
HAL_BUSY
= 0x02U,
/**< Driver is busy. */
144
HAL_TIMEOUT
= 0x03
/**< Timeout occurred. */
145
}
hal_status_t
;
146
147
148
#endif
HAL_TIMEOUT
@ HAL_TIMEOUT
Definition:
gr_common.h:144
HAL_OK
@ HAL_OK
Definition:
gr_common.h:141
HAL_BUSY
@ HAL_BUSY
Definition:
gr_common.h:143
HAL_ERROR
@ HAL_ERROR
Definition:
gr_common.h:142
gr5x.h
CMSIS Cortex-M# Core Peripheral Access Layer Header File for Device GR5405.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition:
gr_common.h:140