summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-05-30 20:42:20 +0200
committerxengineering <me@xengineering.eu>2024-05-30 20:42:20 +0200
commit17008662c08e8e99aefc1814dd80d366872d7ded (patch)
treee33735323be004e963eed130dc2e96cc64031c38
parentd9c7e352d9268e12f6c1d19dbc68c047842acdf1 (diff)
downloadiot-core-17008662c08e8e99aefc1814dd80d366872d7ded.tar
iot-core-17008662c08e8e99aefc1814dd80d366872d7ded.tar.zst
iot-core-17008662c08e8e99aefc1814dd80d366872d7ded.zip
firmware: Replace shell by empty frame emitting
The shell should not be used anyway since the USB UART port is required for communication with the software. Emitting 0xC0 as termination byte of the Serial Line Internet Protocol (SLIP) every second triggers output in the SLIP-receiving software.
-rw-r--r--firmware/prj.conf3
-rw-r--r--firmware/src/main.c44
2 files changed, 16 insertions, 31 deletions
diff --git a/firmware/prj.conf b/firmware/prj.conf
index 7dfd087..ef2861c 100644
--- a/firmware/prj.conf
+++ b/firmware/prj.conf
@@ -1,2 +1 @@
-CONFIG_SHELL=y
-CONFIG_SHELL_PROMPT_UART="[iot-core] "
+CONFIG_SERIAL=y
diff --git a/firmware/src/main.c b/firmware/src/main.c
index 702c8d5..a9721ef 100644
--- a/firmware/src/main.c
+++ b/firmware/src/main.c
@@ -1,39 +1,25 @@
-#include <stdio.h>
-#include <stdint.h>
+#include <stdbool.h>
#include <zephyr/kernel.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/shell/shell_backend.h>
+#include <zephyr/device.h>
+#include <zephyr/drivers/uart.h>
-#include "uid64.h"
+#define UART_DEVICE_NODE DT_CHOSEN(zephyr_shell_uart)
+static const struct device *const uart_dev = DEVICE_DT_GET(UART_DEVICE_NODE);
-static uint64_t uid = 0;
-static char uid_str[UID64_STR_LEN];
-
-#define MAX_PROMPT_SIZE 80
-char prompt[MAX_PROMPT_SIZE];
-
-void init_uid64(void) {
- uid = uid64_get();
- uid64_to_string(uid, uid_str);
-}
-
-void init_shell_prompt(void) {
- if (uid64_available()) {
- snprintf(prompt, MAX_PROMPT_SIZE, "[iot-core %s] ", uid_str);
- } else {
- strncpy(prompt, "[iot-core without MAC] ", MAX_PROMPT_SIZE);
- }
- for (int i = 0; i < shell_backend_count_get(); i++) {
- const struct shell *sh = shell_backend_get(i);
- (void) shell_prompt_change(sh, (const char *)prompt);
- }
-}
+#define SLIP_END 0xC0
int main(void)
{
- init_uid64();
- init_shell_prompt();
+ if (!device_is_ready(uart_dev)) {
+ printk("UART device not found!");
+ return 0;
+ }
+
+ while (true) {
+ k_sleep(K_MSEC(1000));
+ uart_poll_out(uart_dev, SLIP_END);
+ }
return 0;
}