From 3f1e5a5c6a594601e597a43a125883d5e3c618c1 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 7 Jun 2024 16:56:19 +0200 Subject: added pull-up resistors (code works, commit for safety) --- lib/pbdrv/drv/arduino/mod.cpp | 3 +++ puzzle/dummy/main.cpp | 24 +++++++++++------------- puzzle/dummy/makefile | 14 +++++++++++++- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/lib/pbdrv/drv/arduino/mod.cpp b/lib/pbdrv/drv/arduino/mod.cpp index 2113ba2..a522ff8 100644 --- a/lib/pbdrv/drv/arduino/mod.cpp +++ b/lib/pbdrv/drv/arduino/mod.cpp @@ -43,5 +43,8 @@ __weak void pbdrv_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) { if(retry == 0) break; retry--; } while (error); + + if (error) + Serial.print(error, DEC); } diff --git a/puzzle/dummy/main.cpp b/puzzle/dummy/main.cpp index 688549f..4abe47a 100644 --- a/puzzle/dummy/main.cpp +++ b/puzzle/dummy/main.cpp @@ -3,18 +3,20 @@ #include "drv/arduino/mod.h" -// #define THOMAS - -#ifdef THOMAS +#ifdef TEST_A #define ADDR_RX 0x69 #define ADDR_TX 0x20 -#define MSG "hoi" +#define MSG "aa" +#define MSG_SIZE 3 #define MSG_DELAY 10 -#else +#endif + +#ifdef TEST_B #define ADDR_TX 0x69 #define ADDR_RX 0x20 -#define MSG "dag" -#define MSG_DELAY 9 +#define MSG "bbbbbbbb" +#define MSG_SIZE 9 +#define MSG_DELAY 10 #endif const char * PBDRV_MOD_NAME = "dummy"; @@ -23,16 +25,12 @@ const i2c_addr_t PBDRV_MOD_ADDR = ADDR_RX; void setup() { pbdrv_setup(); Serial.begin(115200); - pinMode(4, OUTPUT); - digitalWrite(4, LOW); } void loop() { - pbdrv_i2c_send(ADDR_TX, (uint8_t *) MSG, 4); + pbdrv_i2c_send(ADDR_TX, (uint8_t *) MSG, MSG_SIZE); delay(MSG_DELAY); } -void pbdrv_i2c_recv(const uint8_t * data, size_t size) { - Serial.println((char *) data); -} +void pbdrv_i2c_recv(const uint8_t * data, size_t size) { } diff --git a/puzzle/dummy/makefile b/puzzle/dummy/makefile index a971dfb..041054e 100644 --- a/puzzle/dummy/makefile +++ b/puzzle/dummy/makefile @@ -2,6 +2,18 @@ TARGET = $(BUILD_DIR)/main.elf include ../../lazy.mk -export SERIAL_PORT = /dev/ttyACM0 +export SERIAL_PORT ?= /dev/ttyACM0 flash: upload-main; +test: test_a test_b; + +test_a: + $(MAKE) -C . clean + $(MAKE) -E CMFLAGS+=-D\ CMAKE_CXX_FLAGS=-DTEST_A -C . + $(MAKE) -E SERIAL_PORT=/dev/ttyACM0 -C . flash + +test_b: + $(MAKE) -C . clean + $(MAKE) -E CMFLAGS+=-D\ CMAKE_CXX_FLAGS=-DTEST_B -C . + $(MAKE) -E SERIAL_PORT=/dev/ttyACM1 -C . flash + -- cgit v1.2.3