diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-15 14:15:36 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-15 14:15:36 +0200 |
commit | b9599d6cbaf924b2c9f73511d5c7604ed57a755d (patch) | |
tree | 941a5e91ec460c5dcee9ddd4b72ad5cd1223d978 | |
parent | 20f442e5f5aa6a4fcf07f65e2f446a3c0ff8e4f2 (diff) |
compiling works again :cry:
-rw-r--r-- | lib/pbdrv/drv/arduino/mod.cpp | 39 | ||||
-rw-r--r-- | lib/pbdrv/drv/arduino/mod.h | 22 | ||||
-rw-r--r-- | puzzle/dummy/main.cpp | 3 |
3 files changed, 22 insertions, 42 deletions
diff --git a/lib/pbdrv/drv/arduino/mod.cpp b/lib/pbdrv/drv/arduino/mod.cpp index d281495..21834d9 100644 --- a/lib/pbdrv/drv/arduino/mod.cpp +++ b/lib/pbdrv/drv/arduino/mod.cpp @@ -16,11 +16,6 @@ #include "../../pb.h" #include "../../pb-mod.h" #include "../../pb-buf.h" -#include "mod.h" - -//! Arduino setup function -extern void setup(void); -void loop(void) {} static void async_pb_i2c_recv(void * _msg, uint32_t _) { pb_buf_t * msg = (pb_buf_t *) _msg; @@ -48,18 +43,6 @@ static void pb_setup() { Wire.onReceive(recv_event); } -void initVariant(void) { - // call regular arduino setup - setup(); - Serial.print("regular setup done and in initVariant\r\n"); // DEBUG - - // call pbdrv-mod setup - pb_setup(); - - // start freertos scheduler - vTaskStartScheduler(); -} - __weak void pb_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) { Wire.beginTransmission((int) addr); Wire.write(buf, sz); @@ -67,3 +50,25 @@ __weak void pb_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) { Wire.setWireTimeout(PB_TIMEOUT_US, true); } +//! Arduino setup function +extern void setup(void); +//! Arduino internal initialization +void init(void); + +//! Application entrypoint +int main(void) { + init(); // call arduino internal setup + setup(); // call regular arduino setup + pb_setup(); // call pbdrv-mod setup + vTaskStartScheduler(); // start freertos scheduler + return 0; +} + +/** + * \note I should really be able to use Arduino's initVariant function for + * this, but I can't seem to get it to link properly using the CMake setup in + * this repository. Overriding the main() function seems to work, and the + * USBCON thing in the default Arduino main() function isn't needed because + * puzzle modules are likely not using USB. + */ + diff --git a/lib/pbdrv/drv/arduino/mod.h b/lib/pbdrv/drv/arduino/mod.h deleted file mode 100644 index 87b5724..0000000 --- a/lib/pbdrv/drv/arduino/mod.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -//! Arduino init variant (called before user setup) -void initVariant(void); - -/** - * \brief Arduino loop function - * - * Loop won't run because everything is handled by the freertos scheduler. It - * is defined in this driver to cause compiler warnings if the user has defined - * the loop() function anyways. - */ -extern void loop(void); - -#ifdef __cplusplus -} -#endif - diff --git a/puzzle/dummy/main.cpp b/puzzle/dummy/main.cpp index ddf3bf0..61c7b5b 100644 --- a/puzzle/dummy/main.cpp +++ b/puzzle/dummy/main.cpp @@ -4,7 +4,6 @@ #include <FreeRTOS.h> #include <task.h> -#include "drv/arduino/mod.h" #include "pb-mod.h" const char * PB_MOD_NAME = "dummy"; @@ -19,8 +18,6 @@ void testTask() { void setup() { Serial.begin(115200); - Serial.write("setup called\r\n"); xTaskCreate((TaskFunction_t) testTask, "test", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); - Serial.write("setup done\r\n"); } |