Basic UART Example
Echo characters received on a UART
- SDK directory:
- Zentri App Store:
API Features Demonstrated
- Event Handling API
This app works on:
- AMW004 - Zentri Mackerel evaluation board
- AMW106 - Zentri Moray evaluation board
- NXP-SCCK - NXP Secure Cloud Connectivity Kit
Requirements and Prerequisites
This app requires a ZentriOS device, such as an AMWx06 (Moray) evaluation board.
The app configures the UART and echoes characters received on the UART. Keys typed into a ZentriOS terminal are echoed back to the terminal.
Connect a serial terminal application to the ZentriOS device UART.
The terminal application should be set to match the ZentriOS app configuration:
- Baud: 115200
- Data bits: 8
- Parity: None
- Stop bits: 1
- Flow control: Disabled
On running the app displays on the ZentriOS terminal:
>UART App Ready. Type something ...
Each character you type appears on the terminal.
- Sets up a UART configuration and a UART buffer.
- Calls zn_event_enable_irq_events to enable IRQ events
- Configures the UART with a call to zn_uart_configure
- Executes in the hardware IRQ context, where it is recommended to limit processing to avoid missing subsequent IRQ events. It immediately issues an event
uart_rx_event_handlerto move execution to the ZAP thread context.
- calls zn_uart_peek_bytes to determine the bytes available.
- calls zn_uart_receive_bytes to buffer received bytes in
- calls zn_uart_transmit_bytes to transmit the contents of
- calls zn_uart_register_rx_callback with a
NULLcallback function to deregister the callback and clean up.
Note that the uart makefile
uart.mk contains the line:
GLOBAL_DEFINES := ZOS_FLAGS=ZOS_FLAG_DISABLE_CMD_CONSOLE
This adds, to the ZentriOS app, a header that disables the command console when the ZentriOS app is running. This prevents conflict between the app and the serial command console.