Revision cda14729 README.txt
README.txt | ||
---|---|---|
300 | 300 |
Next, you have to configure the main thread to whitelist the event flag (all I/O |
301 | 301 |
events are blacklisted by default). While system relevant events like power down |
302 | 302 |
are whitelisted by the OS, any custom events need to be added exl´plicitely. |
303 |
This is done via the optional AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK macro, which
|
|
304 |
should be defined in the module.h file. Example: |
|
305 |
|
|
306 |
#define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK \
|
|
307 |
(AOS_IOEVENT_FLAG(padX) | AOS_IOEVENT_FLAG(padY) | AOS_IOEVENT_FLAG(padZ))
|
|
308 |
|
|
309 |
When AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK has been defined correctly, the main
|
|
310 |
thread will be notified by the according events and execute its event handling
|
|
311 |
routine. Hence you have to implement another macro in module.h to handle the
|
|
312 |
custom event(s) appropriately: MODULE_MAIN_LOOP_IO_EVENT(eventflags). As you can
|
|
313 |
see, the variable 'eventflags' is propagated to the hook. This variable is a
|
|
314 |
mask, that allows to identify the GPIO pad(s), which caused the event, by the
|
|
315 |
bits set. Following the example above, you can check which GPIOs have caused
|
|
316 |
events by using if-clauses in the implementation of the hook: |
|
317 |
|
|
318 |
#define MODULE_MAIN_LOOP_IO_EVENT(eventflags) { \
|
|
319 |
if (eventflags & AOS_IOEVENT_FLAG(padX)) { \
|
|
303 |
This is done via the optional AMIROOS_CFG_MAIN_LOOP_GPIOEVENT_FLAGSMASK macro,
|
|
304 |
which should be defined in the module.h file. Example:
|
|
305 |
|
|
306 |
#define AMIROOS_CFG_MAIN_LOOP_GPIOEVENT_FLAGSMASK \
|
|
307 |
(AOS_GPIOEVENT_FLAG(padX) | AOS_GPIOEVENT_FLAG(padY) | AOS_GPIOEVENT_FLAG(padZ))
|
|
308 |
|
|
309 |
When AMIROOS_CFG_MAIN_LOOP_GPIOEVENT_FLAGSMASK has been defined correctly, the
|
|
310 |
main thread will be notified by the according events and execute its event
|
|
311 |
handling routine. Hence you have to implement another macro in module.h to
|
|
312 |
handle the custom event(s) appropriately: MODULE_MAIN_LOOP_GPIOEVENT(eventflags).
|
|
313 |
As you can see, the variable 'eventflags' is propagated to the hook. This
|
|
314 |
variable is a mask, that allows to identify the GPIO pad(s), which caused the
|
|
315 |
event, by the bits set. Following the example above, you can check which GPIOs
|
|
316 |
have caused events by using if-clauses in the implementation of the hook:
|
|
317 |
|
|
318 |
#define MODULE_MAIN_LOOP_GPIOEVENT(eventflags) { \
|
|
319 |
if (eventflags & AOS_GPIOEVENT_FLAG(padX)) { \
|
|
320 | 320 |
/* handle event */ \ |
321 | 321 |
} \ |
322 | 322 |
if (eventflags & (AOS_IOEVENT_FLAG(padY) | \ |
323 |
AOS_IOEVENT_FLAG(padZ))) { \
|
|
323 |
AOS_GPIOEVENT_FLAG(padZ))) { \
|
|
324 | 324 |
/* handle combined event */ \ |
325 | 325 |
} \ |
326 | 326 |
} |
327 | 327 |
|
328 | 328 |
Summing up, you have to |
329 | 329 |
1) configure and enable the GPIO interrupt. |
330 |
2) define the AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK macro.
|
|
331 |
3) implement the MODULE_MAIN_LOOP_IO_EVENT(eventflags) hook.
|
|
330 |
2) define the AMIROOS_CFG_MAIN_LOOP_GPIOEVENT_FLAGSMASK macro.
|
|
331 |
3) implement the MODULE_MAIN_LOOP_GPIOEVENT(eventflags) hook.
|
|
332 | 332 |
|
333 | 333 |
|
334 | 334 |
4.3 Implementing a New Low-Level Driver |
Also available in: Unified diff