aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-15 14:28:21 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-15 14:28:21 +0200
commit30171b5c84dd90ee9de9f3efc395766497a86c85 (patch)
treebf6ccd036d4eaa5e1a2f1ab892ac116b8874ce72
parentb9599d6cbaf924b2c9f73511d5c7604ed57a755d (diff)
restore arduino compatibility
-rw-r--r--lib/pbdrv/drv/arduino/mod.cpp11
-rw-r--r--puzzle/dummy/main.cpp14
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/pbdrv/drv/arduino/mod.cpp b/lib/pbdrv/drv/arduino/mod.cpp
index 21834d9..8766444 100644
--- a/lib/pbdrv/drv/arduino/mod.cpp
+++ b/lib/pbdrv/drv/arduino/mod.cpp
@@ -52,14 +52,25 @@ __weak void pb_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) {
//! Arduino setup function
extern void setup(void);
+//! Arduino loop function
+extern void loop(void);
//! Arduino internal initialization
void init(void);
+//! FreeRTOS loop task
+void loop_task() {
+ for(;;) {
+ loop();
+ if (serialEventRun) serialEventRun();
+ }
+}
+
//! Application entrypoint
int main(void) {
init(); // call arduino internal setup
setup(); // call regular arduino setup
pb_setup(); // call pbdrv-mod setup
+ xTaskCreate((TaskFunction_t) loop_task, "loop", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
vTaskStartScheduler(); // start freertos scheduler
return 0;
}
diff --git a/puzzle/dummy/main.cpp b/puzzle/dummy/main.cpp
index 61c7b5b..3c713d6 100644
--- a/puzzle/dummy/main.cpp
+++ b/puzzle/dummy/main.cpp
@@ -1,5 +1,4 @@
#include <Arduino.h>
-#include <Wire.h>
#include <FreeRTOS.h>
#include <task.h>
@@ -9,15 +8,12 @@
const char * PB_MOD_NAME = "dummy";
const i2c_addr_t PB_MOD_ADDR = 0x69;
-void testTask() {
- while(1) {
- vTaskDelay(1000 / portTICK_PERIOD_MS);
- Serial.write("Hello world!\r\n");
- }
-}
-
void setup() {
Serial.begin(115200);
- xTaskCreate((TaskFunction_t) testTask, "test", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);
+}
+
+void loop() {
+ Serial.write("Hello world!\r\n");
+ vTaskDelay(1000 / portTICK_PERIOD_MS);
}