Skip to main content

uart-echo

UART RX → TX echo loop. The minimal demo for <alp/peripheral.h>'s UART class.

Source: examples/uart-echo/.

board.yaml

schema_version: 2

som:
sku: E1M-AEN701

carrier:
name: E1M-EVK

cores:
m55_hp:
os: zephyr
app: ./src
peripherals: [uart]

diagnostics:
log_level: info

Source (abbreviated)

#include <alp/peripheral.h>
#include <alp/e1m_pinout.h>

int main(void) {
alp_uart_t *uart = alp_uart_open(&(alp_uart_config_t){
.bus_id = E1M_UART0,
.baudrate = 115200u,
.data_bits = 8,
.stop_bits = ALP_UART_STOP_1,
.parity = ALP_UART_PARITY_NONE,
.flow_control= ALP_UART_FLOW_NONE,
});
if (uart == NULL) return -1;

uint8_t byte;
size_t got;
while (1) {
if (alp_uart_read(uart, &byte, 1, &got) == ALP_OK && got == 1) {
alp_uart_write(uart, &byte, 1);
}
}
}

See also

Questions about this page? Discuss in Community Forum