Revision 7021191e periphALtypes.h
periphALtypes.h | ||
---|---|---|
51 | 51 |
* @brief Status values used as return value for all (or most) function calls. |
52 | 52 |
* @note The status can be used as mask of flags. |
53 | 53 |
*/ |
54 |
typedef enum { |
|
55 |
APAL_STATUS_OK = 0x00u, /**< success, no error occurred */ |
|
56 |
APAL_STATUS_SUCCESS = 0x00u, /**< success, no error occurred */ |
|
57 |
APAL_STATUS_ERROR = 0x01u, /**< failed, some unspecified error occured */ |
|
58 |
APAL_STATUS_FAILURE = 0x01u, /**< failed, some unspecified error occured */ |
|
59 |
APAL_STATUS_TIMEOUT = 0x02u, /**< failed, timeout occurred */ |
|
60 |
APAL_STATUS_INVALIDARGUMENTS = 0x04u, /**< failed, invalid arguments */ |
|
61 |
APAL_STATUS_UNAVAILABLE = 0x08u, /**< failed, function unavailable */ |
|
62 |
APAL_STATUS_WARNING = 0x10u, /**< success, but the result is probably not as expected */ |
|
63 |
} apalExitStatus_t; |
|
54 |
typedef int8_t apalExitStatus_t; |
|
55 |
|
|
56 |
/** |
|
57 |
* @brief Status value for success (no error or warning occurred). |
|
58 |
*/ |
|
59 |
#define APAL_STATUS_OK ((apalExitStatus_t)0) |
|
60 |
#define APAL_STATUS_SUCCESS ((apalExitStatus_t)0) |
|
61 |
|
|
62 |
/** |
|
63 |
* @brief Status value for unspecified failure. |
|
64 |
*/ |
|
65 |
#define APAL_STATUS_ERROR ((apalExitStatus_t)-1) |
|
66 |
#define APAL_STATUS_FAILURE ((apalExitStatus_t)-1) |
|
67 |
|
|
68 |
/** |
|
69 |
* @brief Status value for timeout failure. |
|
70 |
*/ |
|
71 |
#define APAL_STATUS_TIMEOUT ((apalExitStatus_t)-2) |
|
72 |
|
|
73 |
/** |
|
74 |
* @brief Status value for failure because of invalid arguments. |
|
75 |
*/ |
|
76 |
#define APAL_STATUS_INVALIDARGUMENTS ((apalExitStatus_t)-4) |
|
77 |
|
|
78 |
/** |
|
79 |
* @brief Status value for failure because the function is not available/implemented. |
|
80 |
*/ |
|
81 |
#define APAL_STATUS_UNAVAILABLE ((apalExitStatus_t)-8) |
|
82 |
|
|
83 |
/** |
|
84 |
* @brief Status value for unspecified warning. |
|
85 |
*/ |
|
86 |
#define APAL_STATUS_WARNING ((apalExitStatus_t)1) |
|
64 | 87 |
|
65 | 88 |
/*============================================================================*/ |
66 | 89 |
/* GPIO */ |
... | ... | |
75 | 98 |
/** |
76 | 99 |
* @brief Status values to read/write a GPIO port. |
77 | 100 |
*/ |
78 |
typedef enum { |
|
79 |
APAL_GPIO_LOW = 0, /**< logical low state */ |
|
80 |
APAL_GPIO_HIGH = 1, /**< logical high state */ |
|
81 |
} apalGpioState_t; |
|
101 |
typedef uint8_t apalGpioState_t; |
|
102 |
|
|
103 |
/** |
|
104 |
* @brief GPIO physical low state. |
|
105 |
*/ |
|
106 |
#define APAL_GPIO_LOW ((apalGpioState_t)0) |
|
82 | 107 |
|
83 | 108 |
/** |
84 |
* @brief Status values to turn a control GPIO 'on' and 'off'.
|
|
109 |
* @brief GPIO physical high state.
|
|
85 | 110 |
*/ |
86 |
typedef enum { |
|
87 |
APAL_GPIO_OFF = 0, /**< logical 'turned off' state */ |
|
88 |
APAL_GPIO_ON = 1, /**< logical 'turned on' state */ |
|
89 |
} apalControlGpioState_t; |
|
111 |
#define APAL_GPIO_HIGH ((apalGpioState_t)1) |
|
112 |
|
|
113 |
/** |
|
114 |
* @brief Invert a physical GPIO state. |
|
115 |
* |
|
116 |
* @param[in] state GPIO state to invert. |
|
117 |
* |
|
118 |
* @return Inverted physical GPIO state. |
|
119 |
*/ |
|
120 |
#define APAL_GPIO_STATE_INVERT(state) ( \ |
|
121 |
(apalGpioState_t)state ^ APAL_GPIO_HIGH \ |
|
122 |
) |
|
123 |
|
|
124 |
/** |
|
125 |
* @brief Logical status values to turn a control GPIO 'on' and 'off'. |
|
126 |
*/ |
|
127 |
typedef uint8_t apalControlGpioState_t; |
|
128 |
|
|
129 |
/** |
|
130 |
* @brief GPIO logical off state. |
|
131 |
*/ |
|
132 |
#define APAL_GPIO_OFF ((apalControlGpioState_t)0) |
|
133 |
|
|
134 |
/** |
|
135 |
* @brief GPIO logical on state. |
|
136 |
*/ |
|
137 |
#define APAL_GPIO_ON ((apalControlGpioState_t)1) |
|
90 | 138 |
|
91 | 139 |
/** |
92 | 140 |
* @brief Polarity state of the control GPIO. |
93 | 141 |
*/ |
94 |
typedef enum { |
|
95 |
APAL_GPIO_ACTIVE_LOW = 0x00, /**< A logically low state is defined as 'on'. */ |
|
96 |
APAL_GPIO_ACTIVE_HIGH = 0x01, /**< A locically high state is defined as 'on'. */ |
|
97 |
} apalGpioActive_t; |
|
142 |
typedef uint8_t apalGpioActive_t; |
|
143 |
|
|
144 |
/** |
|
145 |
* @brief The control GPIO is never defined to be 'on' (does not apply). |
|
146 |
*/ |
|
147 |
#define APAL_GPIO_ACTIVE_NONE ((apalGpioActive_t)0) |
|
148 |
|
|
149 |
/** |
|
150 |
* @brief The control GPIO is defined to be 'on' when it is phsically low. |
|
151 |
*/ |
|
152 |
#define APAL_GPIO_ACTIVE_LOW ((apalGpioActive_t)1) |
|
153 |
|
|
154 |
/** |
|
155 |
* @brief The control GPIO is defined to be 'on' when it is physically high. |
|
156 |
*/ |
|
157 |
#define APAL_GPIO_ACTIVE_HIGH ((apalGpioActive_t)2) |
|
158 |
|
|
159 |
/** |
|
160 |
* @brief The control GPIO is defined to be always 'on'. |
|
161 |
*/ |
|
162 |
#define APAL_GPIO_ACTIVE_ANY ((apalGpioActive_t)3) |
|
163 |
|
|
164 |
/** |
|
165 |
* @brief Invert a GPIO active state. |
|
166 |
* @details The active state is inverted only if it was either low or high. |
|
167 |
* In case it was set to none or any, the value is not modified. |
|
168 |
* |
|
169 |
* @param[in] active Active state to be inverted. |
|
170 |
* |
|
171 |
* @return Inverted active state. |
|
172 |
*/ |
|
173 |
#define APAL_GPIO_ACTIVE_INVERT(active) ( \ |
|
174 |
(((apalGpioActive_t)active & APAL_GPIO_ACTIVE_LOW) ^ \ |
|
175 |
((apalGpioActive_t)active & APAL_GPIO_ACTIVE_HIGH)) ? \ |
|
176 |
((apalGpioActive_t)active ^ APAL_GPIO_ACTIVE_ANY) : \ |
|
177 |
((apalGpioActive_t)active) \ |
|
178 |
) |
|
98 | 179 |
|
99 | 180 |
/** |
100 | 181 |
* @brief Signal direction for the control GPIO. |
101 | 182 |
*/ |
102 |
typedef enum { |
|
103 |
APAL_GPIO_DIRECTION_UNDEFINED = 0x00, /**< Signal direction is undefined. */ |
|
104 |
APAL_GPIO_DIRECTION_INPUT = 0x01, /**< Signal direction is input only. */ |
|
105 |
APAL_GPIO_DIRECTION_OUTPUT = 0x02, /**< Signal direction is output only */ |
|
106 |
APAL_GPIO_DIRECTION_BIDIRECTIONAL = 0x03, /**< Signal direction is bidirectional. */ |
|
107 |
} apalGpioDirection_t; |
|
183 |
typedef uint8_t apalGpioDirection_t; |
|
184 |
|
|
185 |
/** |
|
186 |
* @brief Signal direction for the control GPIO is undefined. |
|
187 |
*/ |
|
188 |
#define APAL_GPIO_DIRECTION_UNDEFINED ((apalGpioDirection_t)0) |
|
189 |
|
|
190 |
/** |
|
191 |
* @brief Signal direction for the control GPIO is input only. |
|
192 |
*/ |
|
193 |
#define APAL_GPIO_DIRECTION_INPUT ((apalGpioDirection_t)1) |
|
194 |
|
|
195 |
/** |
|
196 |
* @brief Signal direction for the control GPIO is output only. |
|
197 |
*/ |
|
198 |
#define APAL_GPIO_DIRECTION_OUTPUT ((apalGpioDirection_t)2) |
|
199 |
|
|
200 |
/** |
|
201 |
* @brief Signal direction for the control GPIO is didirectional. |
|
202 |
*/ |
|
203 |
#define APAL_GPIO_DIRECTION_BIDIRECTIONAL ((apalGpioDirection_t)3) |
|
204 |
|
|
205 |
/** |
|
206 |
* @brief Informative or effective signal edge for control GPIOs. |
|
207 |
*/ |
|
208 |
typedef uint8_t apalGpioEdge_t; |
|
108 | 209 |
|
109 | 210 |
/** |
110 |
* @brief Informative signal edge for input control GPIOs.
|
|
211 |
* @brief No edges indicate an interrupt or trigger an action.
|
|
111 | 212 |
*/ |
112 |
typedef enum { |
|
113 |
APAL_GPIO_EDGE_NONE = 0x00, /**< No edge indicates an interrupt. */ |
|
114 |
APAL_GPIO_EDGE_RISING = 0x01, /**< Rising edges indicate an interrupt. */ |
|
115 |
APAL_GPIO_EDGE_FALLING = 0x02, /**< Falling edges indicate an interrupt. */ |
|
116 |
APAL_GPIO_EDGE_BOTH = 0x03, /**< Both rising and falling edges indicate an interrupt. */ |
|
117 |
} apalGpioEdge_t; |
|
213 |
#define APAL_GPIO_EDGE_NONE ((apalGpioEdge_t)0) |
|
118 | 214 |
|
119 | 215 |
/** |
120 |
* @brief Inverts the value of the informative signal edge for interrupts. |
|
216 |
* @brief Rising edges indicate an interrupt or trigger an action. |
|
217 |
*/ |
|
218 |
#define APAL_GPIO_EDGE_RISING ((apalGpioEdge_t)1) |
|
219 |
|
|
220 |
/** |
|
221 |
* @brief Falling edges indicate an interrupt or trigger an action. |
|
222 |
*/ |
|
223 |
#define APAL_GPIO_EDGE_FALLING ((apalGpioEdge_t)2) |
|
224 |
|
|
225 |
/** |
|
226 |
* @brief Both rising and falling edges indicate an interrupt or trigger an action. |
|
227 |
*/ |
|
228 |
#define APAL_GPIO_EDGE_BOTH ((apalGpioEdge_t)3) |
|
229 |
|
|
230 |
/** |
|
231 |
* @brief Inverts the value of the informative or effective signal edge for interrupts. |
|
121 | 232 |
* @details Rising edge is inverted to falling and vice versa. |
122 | 233 |
* If none or both edges are enabled, the identical value is returned. |
123 | 234 |
*/ |
124 |
#define APAL_GPIO_EDGE_INVERT(edge) \ |
|
125 |
((edge == APAL_GPIO_EDGE_RISING) ? APAL_GPIO_EDGE_FALLING : \ |
|
126 |
(edge == APAL_GPIO_EDGE_FALLING) ? APAL_GPIO_EDGE_RISING : edge) \ |
|
235 |
#define APAL_GPIO_EDGE_INVERT(edge) ( \ |
|
236 |
(((apalGpioEdge_t)edge & APAL_GPIO_EDGE_RISING) ^ \ |
|
237 |
((apalGpioEdge_t)edge & APAL_GPIO_EDGE_FALLING)) ? \ |
|
238 |
((apalGpioEdge_t)edge ^ APAL_GPIO_EDGE_BOTH) : \ |
|
239 |
((apalGpioEdge_t)edge) \ |
|
240 |
) |
|
127 | 241 |
|
128 | 242 |
/** |
129 | 243 |
* @brief Control GPIO meta information |
130 | 244 |
*/ |
131 | 245 |
typedef struct { |
132 | 246 |
apalGpioDirection_t direction : 2; /**< Direction configuration for according signals */ |
133 |
apalGpioActive_t active : 1; /**< Active state of the GPIO */
|
|
247 |
apalGpioActive_t active : 2; /**< Active state of the GPIO */
|
|
134 | 248 |
apalGpioEdge_t edge : 2; /**< Edge configuration for according signals */ |
135 | 249 |
} apalGpioMeta_t; |
136 | 250 |
|
... | ... | |
167 | 281 |
typedef uint32_t apalPWMperiod_t; |
168 | 282 |
|
169 | 283 |
/** |
170 |
* @brief PWM width limits and special values.
|
|
284 |
* @brief PWM width to turn off the PWM.
|
|
171 | 285 |
*/ |
172 |
typedef enum { |
|
173 |
APAL_PWM_WIDTH_OFF = 0x0000u, /**< PWM off */ |
|
174 |
APAL_PWM_WIDTH_MIN = 0x0000u, /**< PWM minimum width */ |
|
175 |
APAL_PWM_WIDTH_MAX = 0xFFFFu, /**< PWM maximum width */ |
|
176 |
} apalPWMWidthLimit_t; |
|
286 |
#define APAL_PWM_WIDTH_OFF ((apalPWMwidth_t)0x0000u) |
|
287 |
|
|
288 |
/** |
|
289 |
* @brief Minimum allowed PWM width. |
|
290 |
*/ |
|
291 |
#define APAL_PWM_WIDTH_MIN ((apalPWMwidth_t)0x0000u) |
|
292 |
|
|
293 |
/** |
|
294 |
* @brief Maximum allowed PWM width. |
|
295 |
*/ |
|
296 |
#define APAL_PWM_WIDTH_MAX ((apalPWMwidth_t)0xFFFFu) |
|
177 | 297 |
|
178 | 298 |
/*============================================================================*/ |
179 | 299 |
/* QEI */ |
... | ... | |
187 | 307 |
/** |
188 | 308 |
* @brief Direction of the QEI. |
189 | 309 |
*/ |
190 |
typedef enum { |
|
191 |
APAL_QEI_DIRECTION_UP = 0, /**< QEI counted up */ |
|
192 |
APAL_QEI_DIRECTION_DOWN = 1, /**< QEI counted down */ |
|
193 |
} apalQEIDirection_t; |
|
310 |
typedef uint8_t apalQEIDirection_t; |
|
311 |
|
|
312 |
/* |
|
313 |
* @brief QEI counts upwards. |
|
314 |
*/ |
|
315 |
#define APAL_QEI_DIRECTION_UP ((apalQEIDirection_t)0) |
|
316 |
|
|
317 |
/* |
|
318 |
* @brief QEI counts downwards. |
|
319 |
*/ |
|
320 |
#define APAL_QEI_DIRECTION_DOWN ((apalQEIDirection_t)1) |
|
194 | 321 |
|
195 | 322 |
/*============================================================================*/ |
196 | 323 |
/* I2C */ |
... | ... | |
205 | 332 |
/* SPI */ |
206 | 333 |
/*============================================================================*/ |
207 | 334 |
|
335 |
/* nothing defined for SPI */ |
|
208 | 336 |
|
209 | 337 |
#endif /* AMIROLLD_PERIPHALTYPES_H */ |
Also available in: Unified diff