From ff3fa235236f2d6d92f7869fb4f55e3655b0502a Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 31 May 2024 10:33:56 +0200 Subject: firmware: Separate data link related code --- firmware/src/data_link.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 firmware/src/data_link.c (limited to 'firmware/src/data_link.c') diff --git a/firmware/src/data_link.c b/firmware/src/data_link.c new file mode 100644 index 0000000..a6d091a --- /dev/null +++ b/firmware/src/data_link.c @@ -0,0 +1,24 @@ +#include + +#include "data_link.h" + +void dl_send_frame(const struct device *const uart_dev, uint8_t *buffer, + size_t len) { + for (size_t i = 0; i < len; i++) { + uint8_t octet = *(buffer + i); + switch (octet) { + case DL_SLIP_END: + uart_poll_out(uart_dev, DL_SLIP_ESC); + uart_poll_out(uart_dev, DL_SLIP_ESC_END); + break; + case DL_SLIP_ESC: + uart_poll_out(uart_dev, DL_SLIP_ESC); + uart_poll_out(uart_dev, DL_SLIP_ESC_ESC); + break; + default: + uart_poll_out(uart_dev, octet); + break; + } + } + uart_poll_out(uart_dev, DL_SLIP_END); +} -- cgit v1.2.3-70-g09d2