uart-rx-ringbuf
Interrupt-driven UART RX with a caller-supplied byte-granular ring buffer. Demonstrates the alp_uart_rx_ringbuf_* pattern for when the consumer can't keep up with the line rate.
Source: examples/uart-rx-ringbuf/.
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
Enable the ring-buffer path with CONFIG_ALP_SDK_UART_RX_RINGBUF=y in prj.conf or as a CMake flag.
Source (abbreviated)
#include <alp/peripheral.h>
#include <alp/e1m_pinout.h>
static uint8_t rx_ring_storage[256];
int main(void) {
alp_uart_t *uart = alp_uart_open(&(alp_uart_config_t){
.bus_id = E1M_UART0,
.baudrate = 115200u,
.data_bits = 8,
});
if (uart == NULL) return -1;
alp_uart_rx_ringbuf_t ring;
alp_uart_rx_ringbuf_init(&ring, rx_ring_storage, sizeof(rx_ring_storage));
alp_uart_rx_ringbuf_attach(uart, &ring);
uint8_t buf[64];
while (1) {
size_t got = alp_uart_rx_ringbuf_pop(&ring, buf, sizeof(buf));
if (got > 0) {
alp_uart_write(uart, buf, got);
} else {
k_msleep(10);
}
}
}
See also
<alp/peripheral.h>reference — UARTuart-echo— polled variant- Examples overview
Questions about this page? Discuss in Community Forum