Demo UART Blaster
Custom commands and variables to blast test data from the UART.
- SDK directory:
- Zentri App Store:
API Features Demonstrated
- Core/Memory API
- Custom Commands API
- Event Handling API
Requirements and Prerequisites
This app requires a ZentriOS module, such as a AMW004 (Wallaby) or AMW106 (Numbat 106).
This app demonstrates setting up custom commands and variables.
It also demonstrates issuing events from the command context and the IRQ context, in order to perform more complex processing tasks in the event loop ZAP context.
Note that custom commands are also accessible from the REST API and remote terminal, as well as from the standard UART console, or ZentriOS terminal.
In commands.c, note that the
uart_blaster_settings structure is defined with zn_load_ro_memory, so it is loaded into Read-Only Memory: a global data struct is stored in serial flash only (i.e. it is not loaded into RAM with the app image). This saves precious RAM, and is a technique suitable for large, rarely accessed data structures.
In commands.c, the following macros define custom blaster variables. The macros to set up the variable structures are:
The following macros define the getter and setter functions:
The following macros define the blaster custom command. To set up the custom command structure:
To define the command functions:
The setter and getter functions execute in the command context.
(uart_blast) definition specifies that issuing the blaster command results in the
toggle_uart_blasting function (defined in uart_blaster.c) executing in the command context. This issues the
uart_blast_event which is handled by the
uart_blast_event_handler in the event loop, or ZAP context.
Note also that the IRQ callback
uart_rx_irq_callback (defined in uart_blaster.c) is executed in the IRQ context. It issues an event,
uart_rx_event_handler, to be executed in the event loop, or ZAP context, in order to minimize processing in the IRQ context. See Execution Context, Hardware IRQ.