Basic UART Example
Echo characters received on a UART
- SDK directory:
apps/basic/uart
- Zentri App Store:
ZENTRI-BAUART
API Features Demonstrated
Platforms
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.
Description
The app configures the UART and echoes characters received on the UART. Keys typed into a ZentriOS terminal are echoed back to the terminal.
Usage Instructions
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.
Implementation
zn_app_init
:
- 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
uart_rx_callback
:
- 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_handler
to move execution to the ZAP thread context.
uart_rx_event_handler
:
- calls zn_uart_peek_bytes to determine the bytes available.
- calls zn_uart_receive_bytes to buffer received bytes in
rx_buffer
- calls zn_uart_transmit_bytes to transmit the contents of
rx_buffer
zn_app_deinit
:
- calls zn_uart_register_rx_callback with a
NULL
callback function to deregister the callback and clean up.
Notes
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.
Source
See: