From 4568db72dc3f9694ecae3506fc3de6ffc948b24f Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 24 May 2023 15:51:25 +0200 Subject: WIP zumo<-nicla communication --- nicla/serial_test.py | 21 +++++++++++++++++++++ zumo/zumo.ino | 7 +++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 nicla/serial_test.py diff --git a/nicla/serial_test.py b/nicla/serial_test.py new file mode 100644 index 0000000..bef43a2 --- /dev/null +++ b/nicla/serial_test.py @@ -0,0 +1,21 @@ +from pyb import Pin, delay + +zumo_tx = Pin("PA10", Pin.IN) +zumo_rx = Pin("PA9", Pin.OUT_PP) + +def uart_send(s): + zumo_rx.value(0) + byte = ord(s) + print("START BIT") + delay(2) + for x in range(8): + bit = (byte & (1 << 7)) >> 7 + byte <<= 1 + zumo_rx.value(bit) + print(f"BIT[{x}] = {bit}") + delay(2) + print("STOP BIT") + zumo_rx.value(1) + +while True: + uart_send("a") diff --git a/zumo/zumo.ino b/zumo/zumo.ino index f59bd36..c65c2f9 100644 --- a/zumo/zumo.ino +++ b/zumo/zumo.ino @@ -5,6 +5,9 @@ #include "protocol.h" #include "pid.h" +#define DUI_PINOUT_NICLA_TX 13 +#define DUI_PINOUT_NICLA_RX 14 + dui_state_t g_dui_target_state = { .steer = 1.0f, .speed = 1.0f, @@ -19,6 +22,8 @@ dui_state_t g_dui_current_state = { }; void setup() { + pinMode(DUI_PINOUT_NICLA_TX, OUTPUT); + pinMode(DUI_PINOUT_NICLA_RX, INPUT_PULLUP); } void loop() { @@ -29,6 +34,4 @@ void loop() { apply_pid(&g_dui_target_state, &g_dui_current_state); apply_state(&g_dui_current_state); - - delay(10); } -- cgit v1.2.3