From 9b020ffb36781e20fa5250e9a674945f8236b6c8 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Thu, 23 Jul 2026 00:15:40 +0200 Subject: [PATCH 1/2] Add drivers to module and make start/stop optional --- Devices/btt-panda-touch/source/module.cpp | 9 +- Devices/cyd-2432s024c/source/module.cpp | 5 - Devices/cyd-2432s024r/source/module.cpp | 9 +- Devices/cyd-2432s028r/source/module.cpp | 9 +- Devices/cyd-2432s028rv3/source/module.cpp | 9 +- Devices/cyd-2432s032c/source/module.cpp | 7 +- Devices/cyd-3248s035c/source/module.cpp | 7 +- Devices/cyd-4848s040c/source/module.cpp | 7 +- Devices/cyd-8048s043c/source/module.cpp | 7 +- Devices/cyd-e32r28t/source/module.cpp | 7 +- Devices/cyd-e32r32p/source/module.cpp | 7 +- .../source/module.cpp | 6 +- .../source/module.cpp | 7 +- .../source/module.cpp | 7 +- .../source/module.cpp | 7 +- .../source/module.cpp | 7 +- .../source/module.cpp | 7 +- Devices/es3c28p/source/module.cpp | 7 +- Devices/generic-esp32/source/module.cpp | 7 +- Devices/generic-esp32c6/source/module.cpp | 7 +- Devices/generic-esp32p4/source/module.cpp | 7 +- Devices/generic-esp32s3/source/module.cpp | 7 +- .../guition-jc1060p470ciwy/source/module.cpp | 7 +- Devices/guition-jc2432w328c/source/module.cpp | 7 +- Devices/guition-jc8048w550c/source/module.cpp | 7 +- .../heltec-wifi-lora-32-v3/source/module.cpp | 7 +- Devices/lilygo-tdeck-max/source/module.cpp | 18 +- Devices/lilygo-tdeck-plus/device.properties | 2 + Devices/lilygo-tdeck-plus/source/module.cpp | 3 - Devices/lilygo-tdeck/device.properties | 2 + Devices/lilygo-tdeck/source/module.cpp | 7 +- Devices/lilygo-tdisplay-s3/source/module.cpp | 11 +- Devices/lilygo-tdisplay/source/module.cpp | 18 +- Devices/lilygo-tdongle-s3/source/module.cpp | 18 +- Devices/lilygo-thmi/source/module.cpp | 18 +- Devices/lilygo-tlora-pager/device.properties | 2 + Devices/lilygo-tlora-pager/source/module.cpp | 24 +- .../m5stack-cardputer-adv/source/module.cpp | 18 +- Devices/m5stack-cardputer/source/module.cpp | 16 +- Devices/m5stack-core2/source/module.cpp | 7 +- Devices/m5stack-cores3/source/module.cpp | 11 +- Devices/m5stack-papers3/source/module.cpp | 26 +- Devices/m5stack-stackchan/source/module.cpp | 4 +- .../m5stack-stickc-plus2/source/module.cpp | 17 +- Devices/m5stack-sticks3/source/module.cpp | 7 +- Devices/m5stack-tab5/Source/module.cpp | 29 +-- Devices/unphone/source/module.cpp | 19 +- .../waveshare-esp32-s3-geek/source/module.cpp | 18 +- Devices/waveshare-s3-lcd-13/source/module.cpp | 7 +- .../source/module.cpp | 7 +- .../source/module.cpp | 7 +- .../source/module.cpp | 7 +- .../source/module.cpp | 7 +- Documentation/ideas.md | 1 + Drivers/EspLcdCompat/CMakeLists.txt | 5 - Drivers/EspLcdCompat/README.md | 3 - Drivers/EspLcdCompat/Source/EspLcdDisplay.cpp | 130 ---------- Drivers/EspLcdCompat/Source/EspLcdDisplay.h | 64 ----- .../EspLcdCompat/Source/EspLcdDisplayDriver.h | 47 ---- .../EspLcdCompat/Source/EspLcdDisplayV2.cpp | 231 ------------------ Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h | 114 --------- .../EspLcdCompat/Source/EspLcdSpiDisplay.cpp | 70 ------ .../EspLcdCompat/Source/EspLcdSpiDisplay.h | 49 ---- Drivers/EspLcdCompat/Source/EspLcdTouch.cpp | 93 ------- Drivers/EspLcdCompat/Source/EspLcdTouch.h | 44 ---- .../EspLcdCompat/Source/EspLcdTouchDriver.cpp | 13 - .../EspLcdCompat/Source/EspLcdTouchDriver.h | 15 -- Drivers/audio-codec-module/README.md | 23 +- Drivers/audio-stream-module/source/module.cpp | 3 +- Drivers/aw88298-module/source/module.cpp | 22 +- Drivers/aw9523b-module/source/module.cpp | 19 +- Drivers/axp192-module/source/module.cpp | 29 +-- Drivers/axp2101-module/source/module.cpp | 32 +-- Drivers/axs5106-module/source/module.cpp | 23 +- Drivers/bm8563-module/source/module.cpp | 23 +- Drivers/bmi270-module/source/module.cpp | 24 +- Drivers/bq24295-module/source/module.cpp | 26 +- Drivers/bq25896-module/source/module.cpp | 26 +- Drivers/bq27220-module/source/module.cpp | 26 +- .../button-control-module/source/module.cpp | 23 +- Drivers/ch422g-module/source/module.cpp | 23 +- Drivers/cst328-module/source/module.cpp | 23 +- Drivers/cst66xx-module/source/module.cpp | 23 +- Drivers/cst816s-module/source/module.cpp | 23 +- Drivers/cst816t-module/source/module.cpp | 17 +- Drivers/drv2605-module/source/module.cpp | 19 +- .../dummy-i2s-amp-module/source/module.cpp | 20 +- Drivers/es7210-module/source/module.cpp | 18 +- Drivers/es8311-module/source/module.cpp | 20 +- Drivers/es8388-module/source/module.cpp | 20 +- Drivers/ft5x06-module/source/module.cpp | 23 +- Drivers/ft6x36-module/source/module.cpp | 23 +- Drivers/gc9a01-module/source/module.cpp | 23 +- Drivers/gt911-module/source/module.cpp | 23 +- Drivers/hx8357-module/source/module.cpp | 25 +- Drivers/ili9341-module/source/module.cpp | 23 +- Drivers/ili9488-module/source/module.cpp | 23 +- Drivers/ili9881c-module/source/module.cpp | 23 +- Drivers/ina226-module/source/module.cpp | 25 +- Drivers/jd9165-module/source/module.cpp | 23 +- Drivers/jd9853-module/source/module.cpp | 23 +- Drivers/lilygo-module/source/module.cpp | 32 +-- Drivers/m5pm1-module/source/module.cpp | 27 +- Drivers/m5stack-module/source/module.cpp | 26 +- Drivers/mpu6886-module/source/module.cpp | 10 +- Drivers/pdm-mic-module/source/module.cpp | 18 +- Drivers/pi4ioe5v6408-module/source/module.cpp | 23 +- .../py32ioexpander-module/source/module.cpp | 19 +- Drivers/qmi8658-module/source/module.cpp | 22 +- Drivers/rgb-display-module/source/module.cpp | 23 +- Drivers/rx8130ce-module/source/module.cpp | 23 +- Drivers/sc2356-module/source/module.cpp | 19 +- Drivers/ssd1306-module/source/module.cpp | 23 +- Drivers/st7123-module/source/module.cpp | 26 +- Drivers/st7701-module/source/module.cpp | 23 +- Drivers/st7735-module/source/module.cpp | 23 +- Drivers/st7789-i8080-module/source/module.cpp | 23 +- Drivers/st7789-module/source/module.cpp | 23 +- Drivers/st7796-i8080-module/source/module.cpp | 23 +- Drivers/st7796-module/source/module.cpp | 23 +- Drivers/sy6970-module/source/module.cpp | 26 +- Drivers/tca8418-module/source/module.cpp | 23 +- Drivers/tca9534-module/source/module.cpp | 23 +- .../tca95xx-16bit-module/source/module.cpp | 23 +- Drivers/xl9555-module/source/module.cpp | 23 +- Drivers/xpt2046-module/source/module.cpp | 26 +- .../xpt2046-softspi-module/source/module.cpp | 26 +- Modules/crypt-module/source/module.cpp | 6 +- Modules/hal-device-module/source/module.cpp | 25 +- TactilityKernel/include/tactility/module.h | 14 +- TactilityKernel/source/module.cpp | 52 +++- 131 files changed, 486 insertions(+), 2368 deletions(-) delete mode 100644 Drivers/EspLcdCompat/CMakeLists.txt delete mode 100644 Drivers/EspLcdCompat/README.md delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdDisplay.cpp delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdDisplay.h delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdDisplayDriver.h delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdDisplayV2.cpp delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.cpp delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.h delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdTouch.cpp delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdTouch.h delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdTouchDriver.cpp delete mode 100644 Drivers/EspLcdCompat/Source/EspLcdTouchDriver.h diff --git a/Devices/btt-panda-touch/source/module.cpp b/Devices/btt-panda-touch/source/module.cpp index 052e86b99..1f1981f58 100644 --- a/Devices/btt-panda-touch/source/module.cpp +++ b/Devices/btt-panda-touch/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { -struct Module btt_panda_touch_module = { - .name = "btt-panda-touch", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr +Module btt_panda_touch_module = { + .name = "btt-panda-touch" }; } diff --git a/Devices/cyd-2432s024c/source/module.cpp b/Devices/cyd-2432s024c/source/module.cpp index e158f9a37..538fe2447 100644 --- a/Devices/cyd-2432s024c/source/module.cpp +++ b/Devices/cyd-2432s024c/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module cyd_2432s024c_module = { .name = "cyd-2432s024c", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr }; } diff --git a/Devices/cyd-2432s024r/source/module.cpp b/Devices/cyd-2432s024r/source/module.cpp index 6384f70bc..c816de82a 100644 --- a/Devices/cyd-2432s024r/source/module.cpp +++ b/Devices/cyd-2432s024r/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { -struct Module cyd_2432s024r_module = { - .name = "cyd-2432s024r", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr +Module cyd_2432s024r_module = { + .name = "cyd-2432s024r" }; } diff --git a/Devices/cyd-2432s028r/source/module.cpp b/Devices/cyd-2432s028r/source/module.cpp index 4c5c41b85..047fd86f4 100644 --- a/Devices/cyd-2432s028r/source/module.cpp +++ b/Devices/cyd-2432s028r/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { -struct Module cyd_2432s028r_module = { - .name = "cyd-2432s028r", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr +Module cyd_2432s028r_module = { + .name = "cyd-2432s028r" }; } diff --git a/Devices/cyd-2432s028rv3/source/module.cpp b/Devices/cyd-2432s028rv3/source/module.cpp index 1ca100b49..00f233932 100644 --- a/Devices/cyd-2432s028rv3/source/module.cpp +++ b/Devices/cyd-2432s028rv3/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { -struct Module cyd_2432s028rv3_module = { - .name = "cyd-2432s028rv3", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr +Module cyd_2432s028rv3_module = { + .name = "cyd-2432s028rv3" }; } diff --git a/Devices/cyd-2432s032c/source/module.cpp b/Devices/cyd-2432s032c/source/module.cpp index c19d0845d..966c1da99 100644 --- a/Devices/cyd-2432s032c/source/module.cpp +++ b/Devices/cyd-2432s032c/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module cyd_2432s032c_module = { - .name = "cyd-2432s032c", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "cyd-2432s032c" }; } diff --git a/Devices/cyd-3248s035c/source/module.cpp b/Devices/cyd-3248s035c/source/module.cpp index 9103ae2f1..d43c57edf 100644 --- a/Devices/cyd-3248s035c/source/module.cpp +++ b/Devices/cyd-3248s035c/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module cyd_3248s035c_module = { - .name = "cyd-3248s035c", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "cyd-3248s035c" }; } diff --git a/Devices/cyd-4848s040c/source/module.cpp b/Devices/cyd-4848s040c/source/module.cpp index d3ef66280..da3236374 100644 --- a/Devices/cyd-4848s040c/source/module.cpp +++ b/Devices/cyd-4848s040c/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module cyd_4848s040c_module = { - .name = "cyd-4848s040c", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "cyd-4848s040c" }; } diff --git a/Devices/cyd-8048s043c/source/module.cpp b/Devices/cyd-8048s043c/source/module.cpp index 366490834..6d8e1ea31 100644 --- a/Devices/cyd-8048s043c/source/module.cpp +++ b/Devices/cyd-8048s043c/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module cyd_8048s043c_module = { - .name = "cyd-8048s043c", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "cyd-8048s043c" }; } diff --git a/Devices/cyd-e32r28t/source/module.cpp b/Devices/cyd-e32r28t/source/module.cpp index a8eaf1cb1..3ba363950 100644 --- a/Devices/cyd-e32r28t/source/module.cpp +++ b/Devices/cyd-e32r28t/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module cyd_e32r28t_module = { - .name = "cyd-e32r28t", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "cyd-e32r28t" }; } diff --git a/Devices/cyd-e32r32p/source/module.cpp b/Devices/cyd-e32r32p/source/module.cpp index c6936a064..7c259cbc2 100644 --- a/Devices/cyd-e32r32p/source/module.cpp +++ b/Devices/cyd-e32r32p/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module cyd_e32r32p_module = { - .name = "cyd-e32r32p", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "cyd-e32r32p" }; } diff --git a/Devices/elecrow-crowpanel-advance-28/source/module.cpp b/Devices/elecrow-crowpanel-advance-28/source/module.cpp index 5db3093d0..14294e236 100644 --- a/Devices/elecrow-crowpanel-advance-28/source/module.cpp +++ b/Devices/elecrow-crowpanel-advance-28/source/module.cpp @@ -1,13 +1,9 @@ -#include #include extern "C" { Module elecrow_crowpanel_advance_28_module = { - .name = "elecrow-crowpanel-advance-28", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr + .name = "elecrow-crowpanel-advance-28" }; } diff --git a/Devices/elecrow-crowpanel-advance-35/source/module.cpp b/Devices/elecrow-crowpanel-advance-35/source/module.cpp index e70e4928d..5a3b45fad 100644 --- a/Devices/elecrow-crowpanel-advance-35/source/module.cpp +++ b/Devices/elecrow-crowpanel-advance-35/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module elecrow_crowpanel_advance_35_module = { - .name = "elecrow-crowpanel-advance-35", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "elecrow-crowpanel-advance-35" }; } diff --git a/Devices/elecrow-crowpanel-advance-50/source/module.cpp b/Devices/elecrow-crowpanel-advance-50/source/module.cpp index e9e8077a0..30b4008fb 100644 --- a/Devices/elecrow-crowpanel-advance-50/source/module.cpp +++ b/Devices/elecrow-crowpanel-advance-50/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module elecrow_crowpanel_advance_50_module = { - .name = "elecrow-crowpanel-advance-50", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "elecrow-crowpanel-advance-50" }; } diff --git a/Devices/elecrow-crowpanel-basic-28/source/module.cpp b/Devices/elecrow-crowpanel-basic-28/source/module.cpp index baa050aba..fe05be7b8 100644 --- a/Devices/elecrow-crowpanel-basic-28/source/module.cpp +++ b/Devices/elecrow-crowpanel-basic-28/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module elecrow_crowpanel_basic_28_module = { - .name = "elecrow-crowpanel-basic-28", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "elecrow-crowpanel-basic-28" }; } diff --git a/Devices/elecrow-crowpanel-basic-35/source/module.cpp b/Devices/elecrow-crowpanel-basic-35/source/module.cpp index 0b6605872..b0292a47a 100644 --- a/Devices/elecrow-crowpanel-basic-35/source/module.cpp +++ b/Devices/elecrow-crowpanel-basic-35/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module elecrow_crowpanel_basic_35_module = { - .name = "elecrow-crowpanel-basic-35", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "elecrow-crowpanel-basic-35" }; } diff --git a/Devices/elecrow-crowpanel-basic-50/source/module.cpp b/Devices/elecrow-crowpanel-basic-50/source/module.cpp index a678c7272..68ce47a1b 100644 --- a/Devices/elecrow-crowpanel-basic-50/source/module.cpp +++ b/Devices/elecrow-crowpanel-basic-50/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module elecrow_crowpanel_basic_50_module = { - .name = "elecrow-crowpanel-basic-50", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "elecrow-crowpanel-basic-50" }; } diff --git a/Devices/es3c28p/source/module.cpp b/Devices/es3c28p/source/module.cpp index 431983863..7b4335bf9 100644 --- a/Devices/es3c28p/source/module.cpp +++ b/Devices/es3c28p/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module es3c28p_module = { - .name = "es3c28p", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "es3c28p" }; } diff --git a/Devices/generic-esp32/source/module.cpp b/Devices/generic-esp32/source/module.cpp index 8d1f99746..360b5608f 100644 --- a/Devices/generic-esp32/source/module.cpp +++ b/Devices/generic-esp32/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module generic_esp32_module = { - .name = "generic-esp32", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "generic-esp32" }; } diff --git a/Devices/generic-esp32c6/source/module.cpp b/Devices/generic-esp32c6/source/module.cpp index 64a3a0225..46aab4331 100644 --- a/Devices/generic-esp32c6/source/module.cpp +++ b/Devices/generic-esp32c6/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module generic_esp32c6_module = { - .name = "generic-esp32c6", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "generic-esp32c6" }; } diff --git a/Devices/generic-esp32p4/source/module.cpp b/Devices/generic-esp32p4/source/module.cpp index 8ba83f6e8..fb38fb0fb 100644 --- a/Devices/generic-esp32p4/source/module.cpp +++ b/Devices/generic-esp32p4/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module generic_esp32p4_module = { - .name = "generic-esp32p4", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "generic-esp32p4" }; } diff --git a/Devices/generic-esp32s3/source/module.cpp b/Devices/generic-esp32s3/source/module.cpp index b27e472d4..1392f3419 100644 --- a/Devices/generic-esp32s3/source/module.cpp +++ b/Devices/generic-esp32s3/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module generic_esp32s3_module = { - .name = "generic-esp32s3", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "generic-esp32s3" }; } diff --git a/Devices/guition-jc1060p470ciwy/source/module.cpp b/Devices/guition-jc1060p470ciwy/source/module.cpp index 727886881..2750b3005 100644 --- a/Devices/guition-jc1060p470ciwy/source/module.cpp +++ b/Devices/guition-jc1060p470ciwy/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module guition_jc1060p470ciwy_module = { - .name = "guition-jc1060p470ciwy", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "guition-jc1060p470ciwy" }; } diff --git a/Devices/guition-jc2432w328c/source/module.cpp b/Devices/guition-jc2432w328c/source/module.cpp index d875db137..445cd4c4f 100644 --- a/Devices/guition-jc2432w328c/source/module.cpp +++ b/Devices/guition-jc2432w328c/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module guition_jc2432w328c_module = { - .name = "guition-jc2432w328c", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "guition-jc2432w328c" }; } diff --git a/Devices/guition-jc8048w550c/source/module.cpp b/Devices/guition-jc8048w550c/source/module.cpp index 34a67026f..76b649b38 100644 --- a/Devices/guition-jc8048w550c/source/module.cpp +++ b/Devices/guition-jc8048w550c/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module guition_jc8048w550c_module = { - .name = "guition-jc8048w550c", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "guition-jc8048w550c" }; } diff --git a/Devices/heltec-wifi-lora-32-v3/source/module.cpp b/Devices/heltec-wifi-lora-32-v3/source/module.cpp index 52648e29b..f90445949 100644 --- a/Devices/heltec-wifi-lora-32-v3/source/module.cpp +++ b/Devices/heltec-wifi-lora-32-v3/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module heltec_wifi_lora_32_v3_module = { - .name = "heltec-wifi-lora-32-v3", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "heltec-wifi-lora-32-v3" }; } diff --git a/Devices/lilygo-tdeck-max/source/module.cpp b/Devices/lilygo-tdeck-max/source/module.cpp index c9ffbeb82..2fec15e34 100644 --- a/Devices/lilygo-tdeck-max/source/module.cpp +++ b/Devices/lilygo-tdeck-max/source/module.cpp @@ -2,22 +2,8 @@ extern "C" { -static error_t start() { - // Empty for now - return ERROR_NONE; -} - -static error_t stop() { - // Empty for now - return ERROR_NONE; -} - -struct Module lilygo_tdeck_max_module = { - .name = "lilygo-tdeck-max", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr +Module lilygo_tdeck_max_module = { + .name = "lilygo-tdeck-max" }; } diff --git a/Devices/lilygo-tdeck-plus/device.properties b/Devices/lilygo-tdeck-plus/device.properties index 3aaf6fbba..2734ad476 100644 --- a/Devices/lilygo-tdeck-plus/device.properties +++ b/Devices/lilygo-tdeck-plus/device.properties @@ -12,6 +12,8 @@ hardware.tinyUsb=true hardware.esptoolFlashFreq=120M hardware.bluetooth=true +dependencies.useDeprecatedHal=false + storage.userDataLocation=SD display.size=2.8" diff --git a/Devices/lilygo-tdeck-plus/source/module.cpp b/Devices/lilygo-tdeck-plus/source/module.cpp index 89f684cc6..8b3e97a7a 100644 --- a/Devices/lilygo-tdeck-plus/source/module.cpp +++ b/Devices/lilygo-tdeck-plus/source/module.cpp @@ -19,9 +19,6 @@ constexpr auto* TAG = "tdeck-plus"; -// Legacy placeholder (required until legacy HAL is cleaned up everywhere) -extern const tt::hal::Configuration hardwareConfiguration = {}; - extern "C" { void subscribe_events() { diff --git a/Devices/lilygo-tdeck/device.properties b/Devices/lilygo-tdeck/device.properties index 7f4b9e457..7153bf982 100644 --- a/Devices/lilygo-tdeck/device.properties +++ b/Devices/lilygo-tdeck/device.properties @@ -12,6 +12,8 @@ hardware.tinyUsb=true hardware.esptoolFlashFreq=120M hardware.bluetooth=true +dependencies.useDeprecatedHal=false + storage.userDataLocation=SD display.size=2.8" diff --git a/Devices/lilygo-tdeck/source/module.cpp b/Devices/lilygo-tdeck/source/module.cpp index 623e97253..0566fcec8 100644 --- a/Devices/lilygo-tdeck/source/module.cpp +++ b/Devices/lilygo-tdeck/source/module.cpp @@ -18,9 +18,6 @@ constexpr auto* TAG = "tdeck"; -// Legacy placeholder (required until legacy HAL is cleaned up everywhere) -extern const tt::hal::Configuration hardwareConfiguration = {}; - extern "C" { void subscribe_events() { @@ -63,9 +60,7 @@ static error_t stop() { Module lilygo_tdeck_module = { .name = "lilygo-tdeck", .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .stop = stop }; } diff --git a/Devices/lilygo-tdisplay-s3/source/module.cpp b/Devices/lilygo-tdisplay-s3/source/module.cpp index 615dd1878..305988fc6 100644 --- a/Devices/lilygo-tdisplay-s3/source/module.cpp +++ b/Devices/lilygo-tdisplay-s3/source/module.cpp @@ -30,16 +30,17 @@ static error_t start() { } static error_t stop() { - // Empty for now + if (gpio_set_level(POWER_ON_PIN, 0) != ESP_OK) { + return ERROR_RESOURCE; + } + return ERROR_NONE; } -struct Module lilygo_tdisplay_s3_module = { +Module lilygo_tdisplay_s3_module = { .name = "lilygo-tdisplay-s3", .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .stop = stop }; } diff --git a/Devices/lilygo-tdisplay/source/module.cpp b/Devices/lilygo-tdisplay/source/module.cpp index 6a3010f52..132360802 100644 --- a/Devices/lilygo-tdisplay/source/module.cpp +++ b/Devices/lilygo-tdisplay/source/module.cpp @@ -2,22 +2,8 @@ extern "C" { -static error_t start() { - // Empty for now - return ERROR_NONE; -} - -static error_t stop() { - // Empty for now - return ERROR_NONE; -} - -struct Module lilygo_tdisplay_module = { - .name = "lilygo-tdisplay", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr +Module lilygo_tdisplay_module = { + .name = "lilygo-tdisplay" }; } diff --git a/Devices/lilygo-tdongle-s3/source/module.cpp b/Devices/lilygo-tdongle-s3/source/module.cpp index ee0732cd0..53d5600ee 100644 --- a/Devices/lilygo-tdongle-s3/source/module.cpp +++ b/Devices/lilygo-tdongle-s3/source/module.cpp @@ -2,22 +2,8 @@ extern "C" { -static error_t start() { - // Empty for now - return ERROR_NONE; -} - -static error_t stop() { - // Empty for now - return ERROR_NONE; -} - -struct Module lilygo_tdongle_s3_module = { - .name = "lilygo-tdongle-s3", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr +Module lilygo_tdongle_s3_module = { + .name = "lilygo-tdongle-s3" }; } diff --git a/Devices/lilygo-thmi/source/module.cpp b/Devices/lilygo-thmi/source/module.cpp index 8cc6172bc..02bd8a6bd 100644 --- a/Devices/lilygo-thmi/source/module.cpp +++ b/Devices/lilygo-thmi/source/module.cpp @@ -2,22 +2,8 @@ extern "C" { -static error_t start() { - // Empty for now - return ERROR_NONE; -} - -static error_t stop() { - // Empty for now - return ERROR_NONE; -} - -struct Module lilygo_thmi_module = { - .name = "lilygo-thmi", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr +Module lilygo_thmi_module = { + .name = "lilygo-thmi" }; } diff --git a/Devices/lilygo-tlora-pager/device.properties b/Devices/lilygo-tlora-pager/device.properties index 1e363302f..9e985e17d 100644 --- a/Devices/lilygo-tlora-pager/device.properties +++ b/Devices/lilygo-tlora-pager/device.properties @@ -13,6 +13,8 @@ hardware.tinyUsb=true hardware.esptoolFlashFreq=40M hardware.bluetooth=true +dependencies.useDeprecatedHal=false + storage.userDataLocation=SD display.size=2.33" diff --git a/Devices/lilygo-tlora-pager/source/module.cpp b/Devices/lilygo-tlora-pager/source/module.cpp index c8f05431b..b5408b87e 100644 --- a/Devices/lilygo-tlora-pager/source/module.cpp +++ b/Devices/lilygo-tlora-pager/source/module.cpp @@ -15,18 +15,15 @@ constexpr auto* TAG = "T-Lora Pager"; -// Legacy placeholder (required until legacy HAL is cleaned up everywhere). All board -// peripherals are kernel drivers now (see the .dts): display (st7796), battery (bq27220), -// charger power-off (bq25896), haptics (drv2605), keyboard (tca8418) and the encoder wheel -// (lilygo,tpager-encoder, bound to LVGL below). -extern const tt::hal::Configuration hardwareConfiguration = {}; - extern "C" { -static void subscribe_events() { +tt::kernel::SystemEventSubscription event_subscription; + +static error_t start() { + LOG_I(TAG, LOG_MESSAGE_POWER_ON_START); - tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent) { + event_subscription = tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent) { // The kernel tpager_encoder device is already started by kernel_init(); this just // registers it as an LVGL input device, which requires LVGL to be up first. lvgl_lock(); @@ -50,23 +47,18 @@ static void subscribe_events() { } } }); -} - -static error_t start() { - subscribe_events(); return ERROR_NONE; } static error_t stop() { + tt::kernel::unsubscribeSystemEvent(event_subscription); return ERROR_NONE; } -struct Module lilygo_tlora_pager_module = { +Module lilygo_tlora_pager_module = { .name = "lilygo-tlora-pager", .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .stop = stop }; } diff --git a/Devices/m5stack-cardputer-adv/source/module.cpp b/Devices/m5stack-cardputer-adv/source/module.cpp index e582ab610..e1d4845e4 100644 --- a/Devices/m5stack-cardputer-adv/source/module.cpp +++ b/Devices/m5stack-cardputer-adv/source/module.cpp @@ -2,22 +2,8 @@ extern "C" { -static error_t start() { - // Empty for now - return ERROR_NONE; -} - -static error_t stop() { - // Empty for now - return ERROR_NONE; -} - -struct Module m5stack_cardputer_adv_module = { - .name = "m5stack-cardputer-adv", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr +Module m5stack_cardputer_adv_module = { + .name = "m5stack-cardputer-adv" }; } diff --git a/Devices/m5stack-cardputer/source/module.cpp b/Devices/m5stack-cardputer/source/module.cpp index 76d48d2cb..c1e7f7ca7 100644 --- a/Devices/m5stack-cardputer/source/module.cpp +++ b/Devices/m5stack-cardputer/source/module.cpp @@ -2,22 +2,8 @@ extern "C" { -static error_t start() { - // Empty for now - return ERROR_NONE; -} - -static error_t stop() { - // Empty for now - return ERROR_NONE; -} - Module m5stack_cardputer_module = { - .name = "m5stack-cardputer", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .name = "m5stack-cardputer" }; } diff --git a/Devices/m5stack-core2/source/module.cpp b/Devices/m5stack-core2/source/module.cpp index c1276986c..d574d630e 100644 --- a/Devices/m5stack-core2/source/module.cpp +++ b/Devices/m5stack-core2/source/module.cpp @@ -1,4 +1,3 @@ -#include #include extern "C" { @@ -7,11 +6,7 @@ extern "C" { // and axp192-module's start()), replacing what used to be done by hand here via a // DEVICE_EVENT_STARTED device_listener. Module m5stack_core2_module = { - .name = "m5stack-core2", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "m5stack-core2" }; } diff --git a/Devices/m5stack-cores3/source/module.cpp b/Devices/m5stack-cores3/source/module.cpp index 738c1cde7..56828ac30 100644 --- a/Devices/m5stack-cores3/source/module.cpp +++ b/Devices/m5stack-cores3/source/module.cpp @@ -1,16 +1,9 @@ -#include #include -#include - extern "C" { -struct Module m5stack_cores3_module = { - .name = "m5stack-cores3", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr +Module m5stack_cores3_module = { + .name = "m5stack-cores3" }; } diff --git a/Devices/m5stack-papers3/source/module.cpp b/Devices/m5stack-papers3/source/module.cpp index 00841b137..0a887f5b4 100644 --- a/Devices/m5stack-papers3/source/module.cpp +++ b/Devices/m5stack-papers3/source/module.cpp @@ -1,6 +1,4 @@ -#include #include -#include #include extern "C" { @@ -9,26 +7,16 @@ extern Driver papers3_power_driver; extern Driver papers3_power_supply_driver; extern Driver papers3_display_driver; -static error_t start() { - check(driver_construct_add(&papers3_power_supply_driver) == ERROR_NONE); - check(driver_construct_add(&papers3_power_driver) == ERROR_NONE); - check(driver_construct_add(&papers3_display_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&papers3_display_driver) == ERROR_NONE); - check(driver_remove_destruct(&papers3_power_driver) == ERROR_NONE); - check(driver_remove_destruct(&papers3_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* papers3_drivers[] = { + &papers3_display_driver, + &papers3_power_driver, + &papers3_power_supply_driver, + nullptr +}; Module m5stack_papers3_module = { .name = "m5stack-papers3", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = papers3_drivers }; } diff --git a/Devices/m5stack-stackchan/source/module.cpp b/Devices/m5stack-stackchan/source/module.cpp index 93212b4d0..367b38487 100644 --- a/Devices/m5stack-stackchan/source/module.cpp +++ b/Devices/m5stack-stackchan/source/module.cpp @@ -56,9 +56,7 @@ static error_t stop() { Module m5stack_stackchan_module = { .name = "m5stack-stackchan", .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .stop = stop }; } diff --git a/Devices/m5stack-stickc-plus2/source/module.cpp b/Devices/m5stack-stickc-plus2/source/module.cpp index 97b6903af..abb6e4cdf 100644 --- a/Devices/m5stack-stickc-plus2/source/module.cpp +++ b/Devices/m5stack-stickc-plus2/source/module.cpp @@ -7,7 +7,7 @@ constexpr auto* TAG = "StickCPlus2"; extern "C" { -static bool init_power() { +static error_t init_power() { // CH552 applies 4 V to GPIO 0, which reduces Wi-Fi sensitivity. // Setting output to high adds a bias of 3.3 V and suppresses over-voltage: gpio_set_direction(GPIO_NUM_0, GPIO_MODE_OUTPUT); @@ -17,25 +17,12 @@ static bool init_power() { gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT); gpio_set_level(GPIO_NUM_4, 1); - return true; -} - -static error_t start() { - init_power(); - return ERROR_NONE; -} - -static error_t stop() { - // Empty for now return ERROR_NONE; } Module m5stack_stickc_plus2_module = { .name = "m5stack-stickc-plus2", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .start = init_power }; } diff --git a/Devices/m5stack-sticks3/source/module.cpp b/Devices/m5stack-sticks3/source/module.cpp index 5592c4a4f..047c0a97b 100644 --- a/Devices/m5stack-sticks3/source/module.cpp +++ b/Devices/m5stack-sticks3/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module m5stack_sticks3_module = { - .name = "m5stack-sticks3", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "m5stack-sticks3" }; } diff --git a/Devices/m5stack-tab5/Source/module.cpp b/Devices/m5stack-tab5/Source/module.cpp index 5c498d0e4..e96d5b354 100644 --- a/Devices/m5stack-tab5/Source/module.cpp +++ b/Devices/m5stack-tab5/Source/module.cpp @@ -16,7 +16,7 @@ #include "devices/tab5_power_control.h" #include "devices/tab_5_camera.h" -#define TAG "Tab5" +constexpr auto* TAG = "Tab5"; // PI4IOE5V6408-0 (0x43) bit 1 constexpr auto GPIO_EXP0_PIN_SPEAKER_ENABLE = 1; @@ -65,44 +65,31 @@ static void on_io_expander0_started(Device* device, DeviceEvent event, void* con extern "C" { static error_t start() { - - /* Crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&tab5_keyboard_driver) == ERROR_NONE); - check(driver_construct_add(&tab5_power_control_driver) == ERROR_NONE); - tab5_detect_start(); - tab5_camera_init(); - device_listener_add(on_io_expander0_started, nullptr); - tab5_headphone_detect_start(); - return ERROR_NONE; } static error_t stop() { tab5_headphone_detect_stop(); - device_listener_remove(on_io_expander0_started); - tab5_detect_stop(); - - /* Crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&tab5_keyboard_driver) == ERROR_NONE); - check(driver_remove_destruct(&tab5_power_control_driver) == ERROR_NONE); - return ERROR_NONE; } +static const Driver* tab5_drivers[] = { + &tab5_keyboard_driver, + &tab5_power_control_driver, + nullptr +}; + Module m5stack_tab5_module = { .name = "m5stack-tab5", .start = start, .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = const_cast(tab5_drivers) }; } diff --git a/Devices/unphone/source/module.cpp b/Devices/unphone/source/module.cpp index 46a922f84..e3298b5f9 100644 --- a/Devices/unphone/source/module.cpp +++ b/Devices/unphone/source/module.cpp @@ -38,29 +38,26 @@ static void on_device_event(Device* device, DeviceEvent event, void* context) { } static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&unphone_power_switch_driver) == ERROR_NONE); - check(driver_construct_add(&unphone_nav_buttons_driver) == ERROR_NONE); device_listener_add(on_device_event, nullptr); return ERROR_NONE; } static error_t stop() { device_listener_remove(&on_device_event); - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&unphone_nav_buttons_driver) == ERROR_NONE); - check(driver_remove_destruct(&unphone_power_switch_driver) == ERROR_NONE); return ERROR_NONE; } -struct Module unphone_module = { +static const Driver* unphone_drivers[] = { + &unphone_nav_buttons_driver, + &unphone_power_switch_driver, + nullptr +}; + +Module unphone_module = { .name = "unphone", .start = start, .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = unphone_drivers }; } diff --git a/Devices/waveshare-esp32-s3-geek/source/module.cpp b/Devices/waveshare-esp32-s3-geek/source/module.cpp index b216db42d..a71bbd9bc 100644 --- a/Devices/waveshare-esp32-s3-geek/source/module.cpp +++ b/Devices/waveshare-esp32-s3-geek/source/module.cpp @@ -2,22 +2,8 @@ extern "C" { -static error_t start() { - // Empty for now - return ERROR_NONE; -} - -static error_t stop() { - // Empty for now - return ERROR_NONE; -} - -struct Module waveshare_esp32_s3_geek_module = { - .name = "waveshare-esp32-s3-geek", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr +Module waveshare_esp32_s3_geek_module = { + .name = "waveshare-esp32-s3-geek" }; } diff --git a/Devices/waveshare-s3-lcd-13/source/module.cpp b/Devices/waveshare-s3-lcd-13/source/module.cpp index 421dc26e7..2e534e615 100644 --- a/Devices/waveshare-s3-lcd-13/source/module.cpp +++ b/Devices/waveshare-s3-lcd-13/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module waveshare_s3_lcd_13_module = { - .name = "waveshare-s3-lcd-13", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "waveshare-s3-lcd-13" }; } diff --git a/Devices/waveshare-s3-touch-lcd-128/source/module.cpp b/Devices/waveshare-s3-touch-lcd-128/source/module.cpp index 4d594ac77..5a7a9ed90 100644 --- a/Devices/waveshare-s3-touch-lcd-128/source/module.cpp +++ b/Devices/waveshare-s3-touch-lcd-128/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module waveshare_s3_touch_lcd_128_module = { - .name = "waveshare-s3-touch-lcd-128", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "waveshare-s3-touch-lcd-128" }; } diff --git a/Devices/waveshare-s3-touch-lcd-147/source/module.cpp b/Devices/waveshare-s3-touch-lcd-147/source/module.cpp index 7af30a280..3547f718a 100644 --- a/Devices/waveshare-s3-touch-lcd-147/source/module.cpp +++ b/Devices/waveshare-s3-touch-lcd-147/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module waveshare_s3_touch_lcd_147_module = { - .name = "waveshare-s3-touch-lcd-147", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "waveshare-s3-touch-lcd-147" }; } diff --git a/Devices/waveshare-s3-touch-lcd-43/source/module.cpp b/Devices/waveshare-s3-touch-lcd-43/source/module.cpp index aafff1cb6..d2f335e70 100644 --- a/Devices/waveshare-s3-touch-lcd-43/source/module.cpp +++ b/Devices/waveshare-s3-touch-lcd-43/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module waveshare_s3_touch_lcd_43_module = { - .name = "waveshare-s3-touch-lcd-43", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "waveshare-s3-touch-lcd-43" }; } diff --git a/Devices/wireless-tag-wt32-sc01-plus/source/module.cpp b/Devices/wireless-tag-wt32-sc01-plus/source/module.cpp index 5a028e619..f3a438cbd 100644 --- a/Devices/wireless-tag-wt32-sc01-plus/source/module.cpp +++ b/Devices/wireless-tag-wt32-sc01-plus/source/module.cpp @@ -1,14 +1,9 @@ -#include #include extern "C" { Module wireless_tag_wt32_sc01_plus_module = { - .name = "wireless-tag-wt32-sc01-plus", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = nullptr, - .internal = nullptr + .name = "wireless-tag-wt32-sc01-plus" }; } diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 95bd34e2d..f418b7563 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -13,6 +13,7 @@ ## Higher Priority +- Drivers/audio-codec-module is not a module. Move it somewhere else. Or make it an actual module. - LilyGO T-Dongle S3: 1 button control, stop auto-launching web server - Core2: support power off via software - Create `#define` for empty module (for modules that fully rely on device.properties and don't define drivers or have start/stop logic) diff --git a/Drivers/EspLcdCompat/CMakeLists.txt b/Drivers/EspLcdCompat/CMakeLists.txt deleted file mode 100644 index efefad7ba..000000000 --- a/Drivers/EspLcdCompat/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -idf_component_register( - SRC_DIRS "Source" - INCLUDE_DIRS "Source" - REQUIRES Tactility esp_lcd esp_lcd_touch esp_lvgl_port -) diff --git a/Drivers/EspLcdCompat/README.md b/Drivers/EspLcdCompat/README.md deleted file mode 100644 index 4d2bfbd5c..000000000 --- a/Drivers/EspLcdCompat/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# EspLcdCompat - -A set of helper classes to implement `esp_lcd` drivers in Tactility. diff --git a/Drivers/EspLcdCompat/Source/EspLcdDisplay.cpp b/Drivers/EspLcdCompat/Source/EspLcdDisplay.cpp deleted file mode 100644 index 66ffef8de..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdDisplay.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "EspLcdDisplay.h" -#include "EspLcdDisplayDriver.h" - -#include -#include -#include -#include -#include - -constexpr auto* TAG = "EspLcdDisplay"; - -EspLcdDisplay::~EspLcdDisplay() { - check( - displayDriver == nullptr || displayDriver.use_count() < 2, // 1 reference is held by this class - "DisplayDriver is still in use. This will cause memory access violations." - ); -} - -bool EspLcdDisplay::start() { - if (!createIoHandle(ioHandle)) { - LOG_E(TAG, "Failed to create IO handle"); - return false; - } - - if (!createPanelHandle(ioHandle, panelHandle)) { - LOG_E(TAG, "Failed to create panel handle"); - esp_lcd_panel_io_del(ioHandle); - return false; - } - - return true; -} - -bool EspLcdDisplay::stop() { - if (lvglDisplay != nullptr) { - stopLvgl(); - lvglDisplay = nullptr; - } - - if (panelHandle != nullptr && esp_lcd_panel_del(panelHandle) != ESP_OK) { - return false; - } - - if (ioHandle != nullptr && esp_lcd_panel_io_del(ioHandle) != ESP_OK) { - return false; - } - - if (displayDriver != nullptr && displayDriver.use_count() > 1) { - LOG_W(TAG, "DisplayDriver is still in use."); - } - - return true; -} - -bool EspLcdDisplay::startLvgl() { - assert(lvglDisplay == nullptr); - - if (displayDriver != nullptr && displayDriver.use_count() > 1) { - LOG_W(TAG, "DisplayDriver is still in use."); - } - - auto lvgl_port_config = getLvglPortDisplayConfig(ioHandle, panelHandle); - - if (isRgbPanel()) { - auto rgb_config = getLvglPortDisplayRgbConfig(ioHandle, panelHandle); - lvglDisplay = lvgl_port_add_disp_rgb(&lvgl_port_config , &rgb_config); - } else { - lvglDisplay = lvgl_port_add_disp(&lvgl_port_config ); - } - - auto touch_device = getTouchDevice(); - if (touch_device != nullptr && touch_device->supportsLvgl()) { - touch_device->startLvgl(lvglDisplay); - } - - return lvglDisplay != nullptr; -} - -bool EspLcdDisplay::stopLvgl() { - if (lvglDisplay == nullptr) { - return false; - } - - auto touch_device = getTouchDevice(); - if (touch_device != nullptr) { - touch_device->stopLvgl(); - } - - lvgl_port_remove_disp(lvglDisplay); - lvglDisplay = nullptr; - return true; -} - -std::shared_ptr EspLcdDisplay::getDisplayDriver() { - assert(lvglDisplay == nullptr); // Still attached to LVGL context. Call stopLvgl() first. - if (displayDriver == nullptr) { - auto lvgl_port_config = getLvglPortDisplayConfig(ioHandle, panelHandle); - - tt::hal::display::ColorFormat color_format; - if (lvgl_port_config.color_format == LV_COLOR_FORMAT_I1) { - color_format = tt::hal::display::ColorFormat::Monochrome; - } else if (lvgl_port_config.color_format == LV_COLOR_FORMAT_RGB565) { - if (rgbElementOrder == LCD_RGB_ELEMENT_ORDER_RGB) { - if (lvgl_port_config.flags.swap_bytes) { - color_format = tt::hal::display::ColorFormat::RGB565Swapped; - } else { - color_format = tt::hal::display::ColorFormat::RGB565; - } - } else { - if (lvgl_port_config.flags.swap_bytes) { - color_format = tt::hal::display::ColorFormat::BGR565Swapped; - } else { - color_format = tt::hal::display::ColorFormat::BGR565; - } - } - } else if (lvgl_port_config.color_format == LV_COLOR_FORMAT_RGB888) { - color_format = tt::hal::display::ColorFormat::RGB888; - } else { - check(false, "unsupported driver"); - } - - displayDriver = std::make_shared( - panelHandle, - lvgl_port_config.hres, - lvgl_port_config.vres, - color_format - ); - } - return displayDriver; -} diff --git a/Drivers/EspLcdCompat/Source/EspLcdDisplay.h b/Drivers/EspLcdCompat/Source/EspLcdDisplay.h deleted file mode 100644 index b8144bd07..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdDisplay.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#include -#include - -#include -#include - -/** @deprecated use EspLcdDisplayV2 */ -class EspLcdDisplay : public tt::hal::display::DisplayDevice { - - esp_lcd_panel_io_handle_t ioHandle = nullptr; - esp_lcd_panel_handle_t panelHandle = nullptr; - lv_display_t* lvglDisplay = nullptr; - std::shared_ptr displayDriver; - /** @warning This is never changed, so a driver that needs BGR is not supported */ - lcd_rgb_element_order_t rgbElementOrder = LCD_RGB_ELEMENT_ORDER_RGB; - -protected: - - // Used for sending commands such as setting curves - esp_lcd_panel_io_handle_t getIoHandle() const { return ioHandle; } - - virtual bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle) = 0; - - virtual bool createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) = 0; - - virtual lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) = 0; - - virtual bool isRgbPanel() const { return false; } - - virtual lvgl_port_display_rgb_cfg_t getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) { check(false, "Not supported"); } - -public: - - EspLcdDisplay() = default; - - ~EspLcdDisplay() override; - - bool start() final; - - bool stop() final; - - // region LVGL - - bool supportsLvgl() const final { return true; } - - bool startLvgl() final; - - bool stopLvgl() final; - - lv_display_t* getLvglDisplay() const final { return lvglDisplay; } - - // endregion - - // region DisplayDriver - - bool supportsDisplayDriver() const override { return true; } - - /** @return a NativeDisplay instance if this device supports it */ - std::shared_ptr getDisplayDriver() final; - - // endregion -}; diff --git a/Drivers/EspLcdCompat/Source/EspLcdDisplayDriver.h b/Drivers/EspLcdCompat/Source/EspLcdDisplayDriver.h deleted file mode 100644 index c9c313a05..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdDisplayDriver.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include - -#include -#if CONFIG_SOC_MIPI_DSI_SUPPORTED -#include -#endif - -class EspLcdDisplayDriver : public tt::hal::display::DisplayDriver { - - esp_lcd_panel_handle_t panelHandle; - uint16_t hRes; - uint16_t vRes; - tt::hal::display::ColorFormat colorFormat; - -public: - - EspLcdDisplayDriver( - esp_lcd_panel_handle_t panelHandle, - uint16_t hRes, - uint16_t vRes, - tt::hal::display::ColorFormat colorFormat - ) : panelHandle(panelHandle), hRes(hRes), vRes(vRes), colorFormat(colorFormat) {} - - tt::hal::display::ColorFormat getColorFormat() const override { - return colorFormat; - } - - bool drawBitmap(int xStart, int yStart, int xEnd, int yEnd, const void* pixelData) override { - bool result = esp_lcd_panel_draw_bitmap(panelHandle, xStart, yStart, xEnd, yEnd, pixelData) == ESP_OK; - return result; - } - - uint16_t getPixelWidth() const override { return hRes; } - - uint16_t getPixelHeight() const override { return vRes; } - -#if CONFIG_SOC_MIPI_DSI_SUPPORTED - uint8_t getFrameBuffers(void* outBuffers[2]) const override { - if (outBuffers == nullptr) { - return 0; - } - return (esp_lcd_dpi_panel_get_frame_buffer(panelHandle, 2, &outBuffers[0], &outBuffers[1]) == ESP_OK) ? 2 : 0; - } -#endif -}; diff --git a/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.cpp b/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.cpp deleted file mode 100644 index c46a69c96..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.cpp +++ /dev/null @@ -1,231 +0,0 @@ -#include "EspLcdDisplayV2.h" -#include "EspLcdDisplayDriver.h" - -#include -#include -#include -#include -#include - -constexpr auto* TAG = "EspLcdDispV2"; - -inline unsigned int getBufferSize(const std::shared_ptr& configuration) { - if (configuration->bufferSize != DEFAULT_BUFFER_SIZE) { - return configuration->bufferSize; - } else { - return configuration->horizontalResolution * (configuration->verticalResolution / 10); - } -} - -EspLcdDisplayV2::~EspLcdDisplayV2() { - check( - displayDriver == nullptr || displayDriver.use_count() < 2, // 1 reference is held by this class - "DisplayDriver is still in use. This will cause memory access violations." - ); -} - -bool EspLcdDisplayV2::applyConfiguration() const { - if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { - LOG_E(TAG, "Failed to reset panel"); - return false; - } - - if (esp_lcd_panel_init(panelHandle) != ESP_OK) { - LOG_E(TAG, "Failed to init panel"); - return false; - } - - if (configuration->invertColor && esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { - LOG_E(TAG, "Failed to set panel to invert"); - return false; - } - - // Warning: it looks like LVGL rotation is broken when "gap" is set and the screen is moved to a non-default orientation - int gap_x = configuration->swapXY ? configuration->gapY : configuration->gapX; - int gap_y = configuration->swapXY ? configuration->gapX : configuration->gapY; - bool should_set_gap = gap_x != 0 || gap_y != 0; - if (should_set_gap && esp_lcd_panel_set_gap(panelHandle, gap_x, gap_y) != ESP_OK) { - LOG_E(TAG, "Failed to set panel gap"); - return false; - } - - if (configuration->swapXY && esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { - LOG_E(TAG, "Failed to swap XY "); - return false; - } - - bool should_set_mirror = configuration->mirrorX || configuration->mirrorY; - if (should_set_mirror && esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { - LOG_E(TAG, "Failed to set panel to mirror"); - return false; - } - - if (configuration->invertColor && esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { - LOG_E(TAG, "Failed to set panel to invert"); - return false; - } - - if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) { - LOG_E(TAG, "Failed to turn display on"); - return false; - } - - return true; -} - -bool EspLcdDisplayV2::start() { - if (!createIoHandle(ioHandle)) { - LOG_E(TAG, "Failed to create IO handle"); - return false; - } - - esp_lcd_panel_dev_config_t panel_config = createPanelConfig(configuration, configuration->resetPin); - - if (!createPanelHandle(ioHandle, panel_config, panelHandle)) { - LOG_E(TAG, "Failed to create panel handle"); - esp_lcd_panel_io_del(ioHandle); - ioHandle = nullptr; - return false; - } - - if (!applyConfiguration()) { - esp_lcd_panel_del(panelHandle); - panelHandle = nullptr; - esp_lcd_panel_io_del(ioHandle); - ioHandle = nullptr; - return false; - } - - return true; -} - -bool EspLcdDisplayV2::stop() { - if (lvglDisplay != nullptr) { - stopLvgl(); - lvglDisplay = nullptr; - } - - if (panelHandle != nullptr && esp_lcd_panel_del(panelHandle) != ESP_OK) { - return false; - } - - if (ioHandle != nullptr && esp_lcd_panel_io_del(ioHandle) != ESP_OK) { - return false; - } - - if (displayDriver != nullptr && displayDriver.use_count() > 1) { - LOG_W(TAG, "DisplayDriver is still in use."); - } - - return true; -} - -bool EspLcdDisplayV2::startLvgl() { - assert(lvglDisplay == nullptr); - - if (displayDriver != nullptr && displayDriver.use_count() > 1) { - LOG_W(TAG, "DisplayDriver is still in use."); - } - - auto lvgl_port_config = getLvglPortDisplayConfig(configuration, ioHandle, panelHandle); - - if (useDsiPanel()) { - auto dsi_config = getLvglPortDisplayDsiConfig(ioHandle, panelHandle); - lvglDisplay = lvgl_port_add_disp_dsi(&lvgl_port_config, &dsi_config); - } else if (isRgbPanel()) { - auto rgb_config = getLvglPortDisplayRgbConfig(ioHandle, panelHandle); - lvglDisplay = lvgl_port_add_disp_rgb(&lvgl_port_config, &rgb_config); - } else { - lvglDisplay = lvgl_port_add_disp(&lvgl_port_config); - } - - auto touch_device = getTouchDevice(); - if (touch_device != nullptr && touch_device->supportsLvgl()) { - touch_device->startLvgl(lvglDisplay); - } - - return lvglDisplay != nullptr; -} - -bool EspLcdDisplayV2::stopLvgl() { - if (lvglDisplay == nullptr) { - return false; - } - - auto touch_device = getTouchDevice(); - if (touch_device != nullptr) { - touch_device->stopLvgl(); - } - - lvgl_port_remove_disp(lvglDisplay); - lvglDisplay = nullptr; - return true; -} - -lvgl_port_display_cfg_t EspLcdDisplayV2::getLvglPortDisplayConfig(std::shared_ptr configuration, esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) { - return lvgl_port_display_cfg_t { - .io_handle = ioHandle, - .panel_handle = panelHandle, - .control_handle = nullptr, - .buffer_size = getBufferSize(configuration), - .double_buffer = false, - .trans_size = 0, - .hres = configuration->horizontalResolution, - .vres = configuration->verticalResolution, - .monochrome = configuration->monochrome, - .rotation = { - .swap_xy = configuration->swapXY, - .mirror_x = configuration->mirrorX, - .mirror_y = configuration->mirrorY, - }, - .color_format = configuration->lvglColorFormat, - .flags = { - .buff_dma = configuration->buffSpiram ? 0u : 1u, - .buff_spiram = configuration->buffSpiram ? 1u : 0u, - .sw_rotate = configuration->swRotate ? 1u : 0u, - .swap_bytes = configuration->lvglSwapBytes, - .full_refresh = 0, - .direct_mode = 0 - } - }; -} - -std::shared_ptr EspLcdDisplayV2::getDisplayDriver() { - assert(lvglDisplay == nullptr); // Still attached to LVGL context. Call stopLvgl() first. - if (displayDriver == nullptr) { - auto lvgl_port_config = getLvglPortDisplayConfig(configuration, ioHandle, panelHandle); - auto panel_config = createPanelConfig(configuration, GPIO_NUM_NC); - - tt::hal::display::ColorFormat color_format; - if (lvgl_port_config.color_format == LV_COLOR_FORMAT_I1) { - color_format = tt::hal::display::ColorFormat::Monochrome; - } else if (lvgl_port_config.color_format == LV_COLOR_FORMAT_RGB565) { - if (panel_config.rgb_ele_order == LCD_RGB_ELEMENT_ORDER_RGB) { - if (lvgl_port_config.flags.swap_bytes) { - color_format = tt::hal::display::ColorFormat::RGB565Swapped; - } else { - color_format = tt::hal::display::ColorFormat::RGB565; - } - } else { - if (lvgl_port_config.flags.swap_bytes) { - color_format = tt::hal::display::ColorFormat::BGR565Swapped; - } else { - color_format = tt::hal::display::ColorFormat::BGR565; - } - } - } else if (lvgl_port_config.color_format == LV_COLOR_FORMAT_RGB888) { - color_format = tt::hal::display::ColorFormat::RGB888; - } else { - check(false, "unsupported driver"); - } - - displayDriver = std::make_shared( - panelHandle, - lvgl_port_config.hres, - lvgl_port_config.vres, - color_format - ); - } - return displayDriver; -} - diff --git a/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h b/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h deleted file mode 100644 index 9f919171c..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h +++ /dev/null @@ -1,114 +0,0 @@ -#pragma once - -#include -#include -#include - -#include -#include - -constexpr auto DEFAULT_BUFFER_SIZE = 0; - -struct EspLcdConfiguration { - unsigned int horizontalResolution; - unsigned int verticalResolution; - int gapX; - int gapY; - bool monochrome; - bool swapXY; - bool mirrorX; - bool mirrorY; - bool invertColor; - uint32_t bufferSize; // Size in pixel count. 0 means default, which is 1/10 of the screen size - bool swRotate = false; // Use LVGL software rotation instead of hardware swap_xy (required for MIPI-DSI panels that don't support swap_xy) - bool buffSpiram = false; // Allocate LVGL draw buffers from PSRAM instead of DMA-capable internal SRAM (required when sw_rotate needs a 3rd buffer that won't fit in internal SRAM) - std::shared_ptr touch; - std::function _Nullable backlightDutyFunction; - gpio_num_t resetPin; - lv_color_format_t lvglColorFormat; - bool lvglSwapBytes; - lcd_rgb_element_order_t rgbElementOrder; - uint32_t bitsPerPixel; -}; - -class EspLcdDisplayV2 : public tt::hal::display::DisplayDevice { - esp_lcd_panel_io_handle_t _Nullable ioHandle = nullptr; - esp_lcd_panel_handle_t _Nullable panelHandle = nullptr; - lv_display_t* _Nullable lvglDisplay = nullptr; - std::shared_ptr _Nullable displayDriver; - std::shared_ptr configuration; - - bool applyConfiguration() const; - - lvgl_port_display_cfg_t getLvglPortDisplayConfig(std::shared_ptr configuration, esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle); - -protected: - - - virtual bool createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) = 0; - - virtual esp_lcd_panel_dev_config_t createPanelConfig(std::shared_ptr espLcdConfiguration, gpio_num_t resetPin) = 0; - - virtual bool createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_panel_dev_config_t& panelConfig, esp_lcd_panel_handle_t& panelHandle) = 0; - - virtual bool isRgbPanel() const { return false; } - - virtual lvgl_port_display_rgb_cfg_t getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) { check(false, "Not supported"); } - - // Hook for MIPI-DSI DPI panels to let LVGL port use DSI-specific path - virtual bool useDsiPanel() const { return false; } - - virtual lvgl_port_display_dsi_cfg_t getLvglPortDisplayDsiConfig(esp_lcd_panel_io_handle_t /*ioHandle*/, esp_lcd_panel_handle_t /*panelHandle*/) { - return lvgl_port_display_dsi_cfg_t{ .flags = { .avoid_tearing = 0 } }; - } - - // Used for sending commands such as setting curves - esp_lcd_panel_io_handle_t getIoHandle() const { return ioHandle; } - -public: - - explicit EspLcdDisplayV2(const std::shared_ptr& configuration) : - configuration(configuration) - {} - - ~EspLcdDisplayV2() override; - - bool start() final; - - bool stop() final; - - // region LVGL - - bool supportsLvgl() const final { return true; } - - bool startLvgl() final; - - bool stopLvgl() final; - - lv_display_t* _Nullable getLvglDisplay() const final { return lvglDisplay; } - - // endregion - - std::shared_ptr _Nullable getTouchDevice() override { return configuration->touch; } - - // region Backlight - - void setBacklightDuty(uint8_t backlightDuty) override { - if (configuration->backlightDutyFunction != nullptr) { - configuration->backlightDutyFunction(backlightDuty); - } - } - - bool supportsBacklightDuty() const override { return configuration->backlightDutyFunction != nullptr; } - - // endregion - - // region DisplayDriver - - bool supportsDisplayDriver() const override { return true; } - - /** @return a NativeDisplay instance if this device supports it */ - std::shared_ptr _Nullable getDisplayDriver() final; - - // endregion -}; diff --git a/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.cpp b/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.cpp deleted file mode 100644 index fbfc98cdb..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "EspLcdSpiDisplay.h" - -#include -#include - -constexpr auto* TAG = "EspLcdSpiDisplay"; - -bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { - LOG_I(TAG, "createIoHandle"); - - const esp_lcd_panel_io_spi_config_t panel_io_config = { - .cs_gpio_num = spiConfiguration->csPin, - .dc_gpio_num = spiConfiguration->dcPin, - .spi_mode = 0, - .pclk_hz = spiConfiguration->pixelClockFrequency, - .trans_queue_depth = spiConfiguration->transactionQueueDepth, - .on_color_trans_done = nullptr, - .user_ctx = nullptr, - .lcd_cmd_bits = 8, - .lcd_param_bits = 8, - .cs_ena_pretrans = 0, - .cs_ena_posttrans = 0, - .flags = { - .dc_high_on_cmd = 0, - .dc_low_on_data = 0, - .dc_low_on_param = 0, - .octal_mode = 0, - .quad_mode = 0, - .sio_mode = 1, - .lsb_first = 0, - .cs_high_active = 0 - } - }; - - if (esp_lcd_new_panel_io_spi(spiConfiguration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) { - LOG_E(TAG, "Failed to create panel"); - return false; - } - - return true; -} - -void EspLcdSpiDisplay::setGammaCurve(uint8_t index) { - uint8_t gamma_curve; - switch (index) { - case 0: - gamma_curve = 0x01; - break; - case 1: - gamma_curve = 0x04; - break; - case 2: - gamma_curve = 0x02; - break; - case 3: - gamma_curve = 0x08; - break; - default: - return; - } - const uint8_t param[] = { - gamma_curve - }; - - auto io_handle = getIoHandle(); - assert(io_handle != nullptr); - if (esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_GAMSET, param, 1) != ESP_OK) { - LOG_E(TAG, "Failed to set gamma"); - } -} diff --git a/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.h b/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.h deleted file mode 100644 index 1e855aff7..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include "EspLcdDisplayV2.h" - -#include - -#include -#include - -/** - * Adds IO implementations on top of EspLcdDisplayV2 - * @warning This is an abstract class. You need to extend it to use it. - */ -class EspLcdSpiDisplay : public EspLcdDisplayV2 { - -public: - - struct SpiConfiguration { - spi_host_device_t spiHostDevice; - gpio_num_t csPin; - gpio_num_t dcPin; - unsigned int pixelClockFrequency = 80'000'000; // Hertz - size_t transactionQueueDepth = 10; - }; - - explicit EspLcdSpiDisplay(const std::shared_ptr& configuration, const std::shared_ptr spiConfiguration, int gammaCurveCount) : - EspLcdDisplayV2(configuration), - spiConfiguration(spiConfiguration), - gammaCurveCount(gammaCurveCount) - {} - -private: - - std::shared_ptr spiConfiguration; - int gammaCurveCount; - -protected: - - bool createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) override; - - // region Gamma - - void setGammaCurve(uint8_t index) override; - - uint8_t getGammaCurveCount() const override { return gammaCurveCount; } - - // endregion -}; - diff --git a/Drivers/EspLcdCompat/Source/EspLcdTouch.cpp b/Drivers/EspLcdCompat/Source/EspLcdTouch.cpp deleted file mode 100644 index eaa6ba77b..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdTouch.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "EspLcdTouch.h" - - -#include -#include -#include - -constexpr auto* TAG = "EspLcdTouch"; - -bool EspLcdTouch::start() { - if (!createIoHandle(ioHandle) != ESP_OK) { - LOG_E(TAG, "Touch IO failed"); - return false; - } - - config = createEspLcdTouchConfig(); - - if (!createTouchHandle(ioHandle, config, touchHandle)) { - LOG_E(TAG, "Driver init failed"); - esp_lcd_panel_io_del(ioHandle); - ioHandle = nullptr; - return false; - } - - return true; -} - -bool EspLcdTouch::stop() { - if (lvglDevice != nullptr) { - stopLvgl(); - } - - if (ioHandle != nullptr) { - esp_lcd_panel_io_del(ioHandle); - ioHandle = nullptr; - } - - if (touchHandle != nullptr) { - esp_lcd_touch_del(touchHandle); - touchHandle = nullptr; - } - - return true; -} - -bool EspLcdTouch::startLvgl(lv_disp_t* display) { - if (lvglDevice != nullptr) { - return false; - } - - if (touchDriver != nullptr && touchDriver.use_count() > 1) { - LOG_W(TAG, "TouchDriver is still in use."); - } - - const lvgl_port_touch_cfg_t touch_cfg = { - .disp = display, - .handle = touchHandle, - }; - - LOG_I(TAG, "Adding touch to LVGL"); - lvglDevice = lvgl_port_add_touch(&touch_cfg); - if (lvglDevice == nullptr) { - LOG_E(TAG, "Adding touch failed"); - return false; - } - - return true; -} - -bool EspLcdTouch::stopLvgl() { - if (lvglDevice == nullptr) { - return false; - } - - lvgl_port_remove_touch(lvglDevice); - lvglDevice = nullptr; - - return true; -} - -std::shared_ptr _Nullable EspLcdTouch::getTouchDriver() { - assert(lvglDevice == nullptr); // Still attached to LVGL context. Call stopLvgl() first. - - if (touchHandle == nullptr) { - return nullptr; - } - - if (touchDriver == nullptr) { - touchDriver = std::make_shared(touchHandle); - } - - return touchDriver; -} diff --git a/Drivers/EspLcdCompat/Source/EspLcdTouch.h b/Drivers/EspLcdCompat/Source/EspLcdTouch.h deleted file mode 100644 index 3e7056b76..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdTouch.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -class EspLcdTouch : public tt::hal::touch::TouchDevice { - - esp_lcd_touch_config_t config; - esp_lcd_panel_io_handle_t _Nullable ioHandle = nullptr; - esp_lcd_touch_handle_t _Nullable touchHandle = nullptr; - lv_indev_t* lvglDevice = nullptr; - std::shared_ptr touchDriver; - -protected: - - esp_lcd_touch_handle_t _Nullable getTouchHandle() const { return touchHandle; } - - virtual bool createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) = 0; - - virtual bool createTouchHandle(esp_lcd_panel_io_handle_t ioHandle, const esp_lcd_touch_config_t& configuration, esp_lcd_touch_handle_t& touchHandle) = 0; - - virtual esp_lcd_touch_config_t createEspLcdTouchConfig() = 0; - -public: - - bool start() final; - - bool stop() final; - - bool supportsLvgl() const final { return true; } - - bool startLvgl(lv_display_t* display) final; - - bool stopLvgl() final; - - lv_indev_t* getLvglIndev() final { return lvglDevice; } - - bool supportsTouchDriver() override { return true; } - - std::shared_ptr _Nullable getTouchDriver() final; -}; diff --git a/Drivers/EspLcdCompat/Source/EspLcdTouchDriver.cpp b/Drivers/EspLcdCompat/Source/EspLcdTouchDriver.cpp deleted file mode 100644 index fe9cb4cfc..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdTouchDriver.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "EspLcdTouchDriver.h" - -#include - -constexpr auto* TAG = "EspLcdTouchDriver"; - -bool EspLcdTouchDriver::getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* _Nullable strength, uint8_t* pointCount, uint8_t maxPointCount) { - if (esp_lcd_touch_read_data(handle) != ESP_OK) { - LOG_E(TAG, "Read data failed"); - return false; - } - return esp_lcd_touch_get_coordinates(handle, x, y, strength, pointCount, maxPointCount); -} diff --git a/Drivers/EspLcdCompat/Source/EspLcdTouchDriver.h b/Drivers/EspLcdCompat/Source/EspLcdTouchDriver.h deleted file mode 100644 index 3b7d96050..000000000 --- a/Drivers/EspLcdCompat/Source/EspLcdTouchDriver.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include - -class EspLcdTouchDriver final : public tt::hal::touch::TouchDriver { - - esp_lcd_touch_handle_t handle; - -public: - - EspLcdTouchDriver(esp_lcd_touch_handle_t handle) : handle(handle) {} - - bool getTouchedPoints(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* pointCount, uint8_t maxPointCount) override; -}; diff --git a/Drivers/audio-codec-module/README.md b/Drivers/audio-codec-module/README.md index 48822bdca..1c830dc99 100644 --- a/Drivers/audio-codec-module/README.md +++ b/Drivers/audio-codec-module/README.md @@ -1,19 +1,14 @@ # Audio codec module -Defines `AUDIO_CODEC_TYPE` and the codec-agnostic `AudioCodecApi` (open/close/ -read/write/volume/mute/native-rate/native-channels/capabilities) that every -audio codec driver in this repo implements (ES8311, ES8388, ES7210, AW88298, -the dummy I2S amps, the PDM mic). This is intentionally low-level: no -resampling or mixing, one codec device per chip. Most app code should go -through `audio_stream` (see `Drivers/audio-stream-module`) instead of talking -to a codec device directly. +Defines codec-agnostic `AudioCodecApi` (open/close/read/write/volume/mute/native-rate/native-channels/capabilities) +that every audio codec driver in this repo implements (ES8311, ES8388, ES7210, AW88298, the dummy I2S amps, the PDM mic). +This is intentionally low-level: no resampling or mixing, one codec device per chip. Most app code should go through +`audio_stream` (see `Drivers/audio-stream-module`) instead of talking to a codec device directly. -Also provides `audio_codec_adapters.h`: glue that lets a codec driver build an -`esp_codec_dev` control/data/GPIO interface (`audio_codec_ctrl_if_t` / -`audio_codec_data_if_t` / `audio_codec_gpio_if_t`) directly from Tactility's -own I2C controller, I2S controller, and GPIO pin devices, so a codec driver -only ever needs `device_get_parent()`/`device_find_by_name()` plus a handful -of devicetree properties -- it never touches the platform I2C/I2S/GPIO APIs -directly. +Also provides `audio_codec_adapters.h`: glue that lets a codec driver build an `esp_codec_dev` control/data/GPIO +interface (`audio_codec_ctrl_if_t` / `audio_codec_data_if_t` / `audio_codec_gpio_if_t`) directly from Tactility's +own I2C controller, I2S controller, and GPIO pin devices, so a codec driver only ever needs +`device_get_parent()`/`device_find_by_name()` plus a handful of devicetree properties -- it never touches the platform +I2C/I2S/GPIO APIs directly. License: [Apache v2.0](LICENSE-Apache-2.0.md) diff --git a/Drivers/audio-stream-module/source/module.cpp b/Drivers/audio-stream-module/source/module.cpp index a0195d7c7..7cca7697e 100644 --- a/Drivers/audio-stream-module/source/module.cpp +++ b/Drivers/audio-stream-module/source/module.cpp @@ -44,8 +44,7 @@ Module audio_stream_module = { .name = "audio-stream", .start = start, .stop = stop, - .symbols = audio_stream_module_symbols, - .internal = nullptr + .symbols = audio_stream_module_symbols }; } diff --git a/Drivers/aw88298-module/source/module.cpp b/Drivers/aw88298-module/source/module.cpp index c07dcca63..d9885b483 100644 --- a/Drivers/aw88298-module/source/module.cpp +++ b/Drivers/aw88298-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,24 +6,17 @@ extern "C" { extern Driver aw88298_driver; -static error_t start() { - check(driver_construct_add(&aw88298_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&aw88298_driver) == ERROR_NONE); - return ERROR_NONE; -} - extern const ModuleSymbol aw88298_module_symbols[]; +static const Driver* aw88298_drivers[] = { + &aw88298_driver, + nullptr +}; + Module aw88298_module = { .name = "aw88298", - .start = start, - .stop = stop, - .symbols = aw88298_module_symbols, - .internal = nullptr + .drivers = aw88298_drivers, + .symbols = aw88298_module_symbols }; } diff --git a/Drivers/aw9523b-module/source/module.cpp b/Drivers/aw9523b-module/source/module.cpp index cbb916ed6..cc2d28c57 100644 --- a/Drivers/aw9523b-module/source/module.cpp +++ b/Drivers/aw9523b-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,22 +6,14 @@ extern "C" { extern Driver aw9523b_driver; -static error_t start() { - check(driver_construct_add(&aw9523b_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&aw9523b_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* aw9523b_drivers[] = { + &aw9523b_driver, + nullptr +}; Module aw9523b_module = { .name = "aw9523b", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = aw9523b_drivers }; } diff --git a/Drivers/axp192-module/source/module.cpp b/Drivers/axp192-module/source/module.cpp index 6ed6069cb..d7e347b58 100644 --- a/Drivers/axp192-module/source/module.cpp +++ b/Drivers/axp192-module/source/module.cpp @@ -1,6 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include #include @@ -10,6 +9,13 @@ extern Driver axp192_driver; extern Driver axp192_power_supply_driver; extern Driver axp192_backlight_driver; +static const Driver* axp192_drivers[] = { + &axp192_driver, + &axp192_power_supply_driver, + &axp192_backlight_driver, + nullptr +}; + const struct ModuleSymbol axp192_module_symbols[] = { DEFINE_MODULE_SYMBOL(axp192_is_rail_enabled), DEFINE_MODULE_SYMBOL(axp192_set_rail_enabled), @@ -27,28 +33,9 @@ const struct ModuleSymbol axp192_module_symbols[] = { MODULE_SYMBOL_TERMINATOR }; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&axp192_driver) == ERROR_NONE); - check(driver_construct_add(&axp192_power_supply_driver) == ERROR_NONE); - check(driver_construct_add(&axp192_backlight_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&axp192_backlight_driver) == ERROR_NONE); - check(driver_remove_destruct(&axp192_power_supply_driver) == ERROR_NONE); - check(driver_remove_destruct(&axp192_driver) == ERROR_NONE); - return ERROR_NONE; -} - Module axp192_module = { .name = "axp192", - .start = start, - .stop = stop, + .drivers = axp192_drivers, .symbols = axp192_module_symbols, .internal = nullptr }; diff --git a/Drivers/axp2101-module/source/module.cpp b/Drivers/axp2101-module/source/module.cpp index daa0db564..c135f177d 100644 --- a/Drivers/axp2101-module/source/module.cpp +++ b/Drivers/axp2101-module/source/module.cpp @@ -1,6 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 #include -#include #include #include @@ -10,6 +9,13 @@ extern Driver axp2101_driver; extern Driver axp2101_power_supply_driver; extern Driver axp2101_backlight_driver; +static const Driver* axp2101_drivers[] = { + &axp2101_driver, + &axp2101_power_supply_driver, + &axp2101_backlight_driver, + nullptr +}; + const struct ModuleSymbol axp2101_module_symbols[] = { DEFINE_MODULE_SYMBOL(axp2101_is_dcdc_enabled), DEFINE_MODULE_SYMBOL(axp2101_set_dcdc_enabled), @@ -28,30 +34,10 @@ const struct ModuleSymbol axp2101_module_symbols[] = { MODULE_SYMBOL_TERMINATOR }; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&axp2101_driver) == ERROR_NONE); - check(driver_construct_add(&axp2101_power_supply_driver) == ERROR_NONE); - check(driver_construct_add(&axp2101_backlight_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&axp2101_backlight_driver) == ERROR_NONE); - check(driver_remove_destruct(&axp2101_power_supply_driver) == ERROR_NONE); - check(driver_remove_destruct(&axp2101_driver) == ERROR_NONE); - return ERROR_NONE; -} - Module axp2101_module = { .name = "axp2101", - .start = start, - .stop = stop, - .symbols = axp2101_module_symbols, - .internal = nullptr + .drivers = axp2101_drivers, + .symbols = axp2101_module_symbols }; } diff --git a/Drivers/axs5106-module/source/module.cpp b/Drivers/axs5106-module/source/module.cpp index 9d92a496b..3db546274 100644 --- a/Drivers/axs5106-module/source/module.cpp +++ b/Drivers/axs5106-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver axs5106_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&axs5106_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&axs5106_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* axs5106_drivers[] = { + &axs5106_driver, + nullptr +}; Module axs5106_module = { .name = "axs5106", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = axs5106_drivers }; } // extern "C" diff --git a/Drivers/bm8563-module/source/module.cpp b/Drivers/bm8563-module/source/module.cpp index 5d376792f..bd9e1ec67 100644 --- a/Drivers/bm8563-module/source/module.cpp +++ b/Drivers/bm8563-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver bm8563_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&bm8563_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&bm8563_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* bm8563_drivers[] = { + &bm8563_driver, + nullptr +}; Module bm8563_module = { .name = "bm8563", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = bm8563_drivers }; } diff --git a/Drivers/bmi270-module/source/module.cpp b/Drivers/bmi270-module/source/module.cpp index b77e8510b..e77fe8c64 100644 --- a/Drivers/bmi270-module/source/module.cpp +++ b/Drivers/bmi270-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,28 +6,17 @@ extern "C" { extern Driver bmi270_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&bmi270_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&bmi270_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* bmi270_drivers[] = { + &bmi270_driver, + nullptr +}; extern const ModuleSymbol bmi270_module_symbols[]; Module bmi270_module = { .name = "bmi270", - .start = start, - .stop = stop, - .symbols = bmi270_module_symbols, - .internal = nullptr + .drivers = bmi270_drivers, + .symbols = bmi270_module_symbols }; } diff --git a/Drivers/bq24295-module/source/module.cpp b/Drivers/bq24295-module/source/module.cpp index 09e7c8597..545c84e53 100644 --- a/Drivers/bq24295-module/source/module.cpp +++ b/Drivers/bq24295-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,28 +7,15 @@ extern "C" { extern Driver bq24295_driver; extern Driver bq24295_power_supply_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&bq24295_driver) == ERROR_NONE); - check(driver_construct_add(&bq24295_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&bq24295_power_supply_driver) == ERROR_NONE); - check(driver_remove_destruct(&bq24295_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* bq24295_drivers[] = { + &bq24295_driver, + &bq24295_power_supply_driver, + nullptr +}; Module bq24295_module = { .name = "bq24295", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = bq24295_drivers }; } diff --git a/Drivers/bq25896-module/source/module.cpp b/Drivers/bq25896-module/source/module.cpp index 7aefdf34b..d4a27efba 100644 --- a/Drivers/bq25896-module/source/module.cpp +++ b/Drivers/bq25896-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,28 +7,15 @@ extern "C" { extern Driver bq25896_driver; extern Driver bq25896_power_supply_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&bq25896_power_supply_driver) == ERROR_NONE); - check(driver_construct_add(&bq25896_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&bq25896_driver) == ERROR_NONE); - check(driver_remove_destruct(&bq25896_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* bq25896_drivers[] = { + &bq25896_driver, + &bq25896_power_supply_driver, + nullptr +}; Module bq25896_module = { .name = "bq25896", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = bq25896_drivers }; } // extern "C" diff --git a/Drivers/bq27220-module/source/module.cpp b/Drivers/bq27220-module/source/module.cpp index c287ab2d3..b6ee788c8 100644 --- a/Drivers/bq27220-module/source/module.cpp +++ b/Drivers/bq27220-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,28 +7,15 @@ extern "C" { extern Driver bq27220_driver; extern Driver bq27220_power_supply_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&bq27220_power_supply_driver) == ERROR_NONE); - check(driver_construct_add(&bq27220_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&bq27220_driver) == ERROR_NONE); - check(driver_remove_destruct(&bq27220_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* bq27220_drivers[] = { + &bq27220_driver, + &bq27220_power_supply_driver, + nullptr +}; Module bq27220_module = { .name = "bq27220", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = bq27220_drivers }; } // extern "C" diff --git a/Drivers/button-control-module/source/module.cpp b/Drivers/button-control-module/source/module.cpp index bd92f5dda..dd40acf02 100644 --- a/Drivers/button-control-module/source/module.cpp +++ b/Drivers/button-control-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver button_control_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&button_control_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&button_control_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* button_control_drivers[] = { + &button_control_driver, + nullptr +}; Module button_control_module = { .name = "button-control", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = button_control_drivers }; } // extern "C" diff --git a/Drivers/ch422g-module/source/module.cpp b/Drivers/ch422g-module/source/module.cpp index c22c90097..bc7cbdeb2 100644 --- a/Drivers/ch422g-module/source/module.cpp +++ b/Drivers/ch422g-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver ch422g_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&ch422g_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&ch422g_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* ch422g_drivers[] = { + &ch422g_driver, + nullptr +}; Module ch422g_module = { .name = "ch422g", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = ch422g_drivers }; } diff --git a/Drivers/cst328-module/source/module.cpp b/Drivers/cst328-module/source/module.cpp index 05b96ac19..1716c61f6 100644 --- a/Drivers/cst328-module/source/module.cpp +++ b/Drivers/cst328-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver cst328_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&cst328_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&cst328_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* cst328_drivers[] = { + &cst328_driver, + nullptr +}; Module cst328_module = { .name = "cst328", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = cst328_drivers }; } // extern "C" diff --git a/Drivers/cst66xx-module/source/module.cpp b/Drivers/cst66xx-module/source/module.cpp index a5c77be56..8c7238daa 100644 --- a/Drivers/cst66xx-module/source/module.cpp +++ b/Drivers/cst66xx-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver cst66xx_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&cst66xx_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&cst66xx_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* cst66xx_drivers[] = { + &cst66xx_driver, + nullptr +}; Module cst66xx_module = { .name = "cst66xx", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = cst66xx_drivers }; } // extern "C" diff --git a/Drivers/cst816s-module/source/module.cpp b/Drivers/cst816s-module/source/module.cpp index 79b17c2aa..45a952337 100644 --- a/Drivers/cst816s-module/source/module.cpp +++ b/Drivers/cst816s-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver cst816s_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&cst816s_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&cst816s_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* cst816s_drivers[] = { + &cst816s_driver, + nullptr +}; Module cst816s_module = { .name = "cst816s", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = cst816s_drivers }; } // extern "C" diff --git a/Drivers/cst816t-module/source/module.cpp b/Drivers/cst816t-module/source/module.cpp index 50cb3c15e..227885291 100644 --- a/Drivers/cst816t-module/source/module.cpp +++ b/Drivers/cst816t-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,20 +6,14 @@ extern "C" { extern Driver cst816t_driver; -static error_t start() { - return driver_construct_add(&cst816t_driver); -} - -static error_t stop() { - return driver_remove_destruct(&cst816t_driver); -} +static const Driver* cst816t_drivers[] = { + &cst816t_driver, + nullptr +}; Module cst816t_module = { .name = "cst816t", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = cst816t_drivers }; } // extern "C" diff --git a/Drivers/drv2605-module/source/module.cpp b/Drivers/drv2605-module/source/module.cpp index f4ecbfa49..4188781f8 100644 --- a/Drivers/drv2605-module/source/module.cpp +++ b/Drivers/drv2605-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,22 +6,14 @@ extern "C" { extern Driver drv2605_driver; -static error_t start() { - check(driver_construct_add(&drv2605_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&drv2605_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* drv2605_drivers[] = { + &drv2605_driver, + nullptr +}; Module drv2605_module = { .name = "drv2605", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = drv2605_drivers }; } // extern "C" diff --git a/Drivers/dummy-i2s-amp-module/source/module.cpp b/Drivers/dummy-i2s-amp-module/source/module.cpp index 45a9391ab..fe14fd7ba 100644 --- a/Drivers/dummy-i2s-amp-module/source/module.cpp +++ b/Drivers/dummy-i2s-amp-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,24 +6,17 @@ extern "C" { extern Driver dummy_i2s_amp_driver; -static error_t start() { - check(driver_construct_add(&dummy_i2s_amp_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&dummy_i2s_amp_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* dummy_drivers[] = { + &dummy_i2s_amp_driver, + nullptr +}; extern const ModuleSymbol dummy_i2s_amp_module_symbols[]; Module dummy_i2s_amp_module = { .name = "dummy_i2s_amp", - .start = start, - .stop = stop, - .symbols = dummy_i2s_amp_module_symbols, - .internal = nullptr + .drivers = dummy_drivers, + .symbols = dummy_i2s_amp_module_symbols }; } diff --git a/Drivers/es7210-module/source/module.cpp b/Drivers/es7210-module/source/module.cpp index a10c4334f..0c7e000e0 100644 --- a/Drivers/es7210-module/source/module.cpp +++ b/Drivers/es7210-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,24 +6,17 @@ extern "C" { extern Driver es7210_driver; -static error_t start() { - check(driver_construct_add(&es7210_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&es7210_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* es7210_drivers[] = { + &es7210_driver, + nullptr +}; extern const ModuleSymbol es7210_module_symbols[]; Module es7210_module = { .name = "es7210", - .start = start, - .stop = stop, + .drivers = es7210_drivers, .symbols = es7210_module_symbols, - .internal = nullptr }; } diff --git a/Drivers/es8311-module/source/module.cpp b/Drivers/es8311-module/source/module.cpp index e71eedd07..9907a258b 100644 --- a/Drivers/es8311-module/source/module.cpp +++ b/Drivers/es8311-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,24 +6,17 @@ extern "C" { extern Driver es8311_driver; -static error_t start() { - check(driver_construct_add(&es8311_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&es8311_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* es8311_drivers[] = { + &es8311_driver, + nullptr +}; extern const ModuleSymbol es8311_module_symbols[]; Module es8311_module = { .name = "es8311", - .start = start, - .stop = stop, - .symbols = es8311_module_symbols, - .internal = nullptr + .drivers = es8311_drivers, + .symbols = es8311_module_symbols }; } diff --git a/Drivers/es8388-module/source/module.cpp b/Drivers/es8388-module/source/module.cpp index 20f829f6b..8f3b5400b 100644 --- a/Drivers/es8388-module/source/module.cpp +++ b/Drivers/es8388-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,24 +6,17 @@ extern "C" { extern Driver es8388_driver; -static error_t start() { - check(driver_construct_add(&es8388_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&es8388_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* es8388_drivers[] = { + &es8388_driver, + nullptr +}; extern const ModuleSymbol es8388_module_symbols[]; Module es8388_module = { .name = "es8388", - .start = start, - .stop = stop, - .symbols = es8388_module_symbols, - .internal = nullptr + .drivers = es8388_drivers, + .symbols = es8388_module_symbols }; } diff --git a/Drivers/ft5x06-module/source/module.cpp b/Drivers/ft5x06-module/source/module.cpp index 2f0928c84..ee705df5a 100644 --- a/Drivers/ft5x06-module/source/module.cpp +++ b/Drivers/ft5x06-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver ft5x06_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&ft5x06_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&ft5x06_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* ft5x06_drivers[] = { + &ft5x06_driver, + nullptr +}; Module ft5x06_module = { .name = "ft5x06", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = ft5x06_drivers }; } // extern "C" diff --git a/Drivers/ft6x36-module/source/module.cpp b/Drivers/ft6x36-module/source/module.cpp index 1d9aaa2d0..11652be37 100644 --- a/Drivers/ft6x36-module/source/module.cpp +++ b/Drivers/ft6x36-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver ft6x36_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&ft6x36_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&ft6x36_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* ft6x36_drivers[] = { + &ft6x36_driver, + nullptr +}; Module ft6x36_module = { .name = "ft6x36", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = ft6x36_drivers }; } // extern "C" diff --git a/Drivers/gc9a01-module/source/module.cpp b/Drivers/gc9a01-module/source/module.cpp index 9c03f96f6..b6fcf4560 100644 --- a/Drivers/gc9a01-module/source/module.cpp +++ b/Drivers/gc9a01-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver gc9a01_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&gc9a01_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&gc9a01_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* gc9a01_drivers[] = { + &gc9a01_driver, + nullptr +}; Module gc9a01_module = { .name = "gc9a01", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = gc9a01_drivers }; } // extern "C" diff --git a/Drivers/gt911-module/source/module.cpp b/Drivers/gt911-module/source/module.cpp index ae2deaa75..fe8c7efee 100644 --- a/Drivers/gt911-module/source/module.cpp +++ b/Drivers/gt911-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver gt911_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(>911_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(>911_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* gt911_drivers[] = { + >911_driver, + nullptr +}; Module gt911_module = { .name = "gt911", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = gt911_drivers }; } // extern "C" diff --git a/Drivers/hx8357-module/source/module.cpp b/Drivers/hx8357-module/source/module.cpp index bbce76d58..3003f6f16 100644 --- a/Drivers/hx8357-module/source/module.cpp +++ b/Drivers/hx8357-module/source/module.cpp @@ -1,32 +1,19 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include extern Driver hx8357_driver; -extern "C" { - -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&hx8357_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* hx8357_drivers[] = { + &hx8357_driver, + nullptr +}; -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&hx8357_driver) == ERROR_NONE); - return ERROR_NONE; -} +extern "C" { Module hx8357_module = { .name = "hx8357", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = hx8357_drivers }; } // extern "C" diff --git a/Drivers/ili9341-module/source/module.cpp b/Drivers/ili9341-module/source/module.cpp index 5fdd1649a..715b9723d 100644 --- a/Drivers/ili9341-module/source/module.cpp +++ b/Drivers/ili9341-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver ili9341_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&ili9341_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&ili9341_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* ili9341_drivers[] = { + &ili9341_driver, + nullptr +}; Module ili9341_module = { .name = "ili9341", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = ili9341_drivers }; } // extern "C" diff --git a/Drivers/ili9488-module/source/module.cpp b/Drivers/ili9488-module/source/module.cpp index aa5a31c18..226cf49d1 100644 --- a/Drivers/ili9488-module/source/module.cpp +++ b/Drivers/ili9488-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver ili9488_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&ili9488_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&ili9488_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* ili9488_drivers[] = { + &ili9488_driver, + nullptr +}; Module ili9488_module = { .name = "ili9488", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = ili9488_drivers }; } // extern "C" diff --git a/Drivers/ili9881c-module/source/module.cpp b/Drivers/ili9881c-module/source/module.cpp index c8b799271..dc1ace654 100644 --- a/Drivers/ili9881c-module/source/module.cpp +++ b/Drivers/ili9881c-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver ili9881c_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&ili9881c_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&ili9881c_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* ili9881c_drivers[] = { + &ili9881c_driver, + nullptr +}; Module ili9881c_module = { .name = "ili9881c", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = ili9881c_drivers }; } // extern "C" diff --git a/Drivers/ina226-module/source/module.cpp b/Drivers/ina226-module/source/module.cpp index 1a5c5c4a8..092be9b99 100644 --- a/Drivers/ina226-module/source/module.cpp +++ b/Drivers/ina226-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,30 +7,18 @@ extern "C" { extern Driver ina226_driver; extern Driver ina226_power_supply_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&ina226_driver) == ERROR_NONE); - check(driver_construct_add(&ina226_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&ina226_power_supply_driver) == ERROR_NONE); - check(driver_remove_destruct(&ina226_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* ina226_drivers[] = { + &ina226_driver, + &ina226_power_supply_driver, + nullptr +}; extern const ModuleSymbol ina226_module_symbols[]; Module ina226_module = { .name = "ina226", - .start = start, - .stop = stop, + .drivers = ina226_drivers, .symbols = ina226_module_symbols, - .internal = nullptr }; } // extern "C" diff --git a/Drivers/jd9165-module/source/module.cpp b/Drivers/jd9165-module/source/module.cpp index 1171609f0..1a2ee89f6 100644 --- a/Drivers/jd9165-module/source/module.cpp +++ b/Drivers/jd9165-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver jd9165_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&jd9165_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&jd9165_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* jd9165_drivers[] = { + &jd9165_driver, + nullptr +}; Module jd9165_module = { .name = "jd9165", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = jd9165_drivers }; } // extern "C" diff --git a/Drivers/jd9853-module/source/module.cpp b/Drivers/jd9853-module/source/module.cpp index 94f47489e..0522e53c4 100644 --- a/Drivers/jd9853-module/source/module.cpp +++ b/Drivers/jd9853-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver jd9853_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&jd9853_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&jd9853_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* jd9853_drivers[] = { + &jd9853_driver, + nullptr +}; Module jd9853_module = { .name = "jd9853", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = jd9853_drivers }; } // extern "C" diff --git a/Drivers/lilygo-module/source/module.cpp b/Drivers/lilygo-module/source/module.cpp index aae34d690..8090f1658 100644 --- a/Drivers/lilygo-module/source/module.cpp +++ b/Drivers/lilygo-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -10,32 +9,17 @@ extern Driver tdeck_keyboard_backlight_driver; extern Driver tdeck_trackball_driver; extern Driver tpager_encoder_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&tdeck_keyboard_driver) == ERROR_NONE); - check(driver_construct_add(&tdeck_keyboard_backlight_driver) == ERROR_NONE); - check(driver_construct_add(&tdeck_trackball_driver) == ERROR_NONE); - check(driver_construct_add(&tpager_encoder_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&tdeck_keyboard_driver) == ERROR_NONE); - check(driver_remove_destruct(&tdeck_keyboard_backlight_driver) == ERROR_NONE); - check(driver_remove_destruct(&tdeck_trackball_driver) == ERROR_NONE); - check(driver_remove_destruct(&tpager_encoder_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* lilygo_drivers[] = { + &tdeck_keyboard_driver, + &tdeck_keyboard_backlight_driver, + &tdeck_trackball_driver, + &tpager_encoder_driver, + nullptr +}; Module lilygo_module = { .name = "lilygo", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = lilygo_drivers }; } // extern "C" diff --git a/Drivers/m5pm1-module/source/module.cpp b/Drivers/m5pm1-module/source/module.cpp index eca02bf5e..65fc19903 100644 --- a/Drivers/m5pm1-module/source/module.cpp +++ b/Drivers/m5pm1-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,30 +7,18 @@ extern "C" { extern Driver m5pm1_driver; extern Driver m5pm1_power_supply_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&m5pm1_driver) == ERROR_NONE); - check(driver_construct_add(&m5pm1_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&m5pm1_power_supply_driver) == ERROR_NONE); - check(driver_remove_destruct(&m5pm1_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* m5pm1_drivers[] = { + &m5pm1_driver, + &m5pm1_power_supply_driver, + nullptr +}; extern const ModuleSymbol m5pm1_module_symbols[]; Module m5pm1_module = { .name = "m5pm1", - .start = start, - .stop = stop, - .symbols = m5pm1_module_symbols, - .internal = nullptr + .drivers = m5pm1_drivers, + .symbols = m5pm1_module_symbols }; } // extern "C" diff --git a/Drivers/m5stack-module/source/module.cpp b/Drivers/m5stack-module/source/module.cpp index f713c9d6c..1bd4c7ad9 100644 --- a/Drivers/m5stack-module/source/module.cpp +++ b/Drivers/m5stack-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,28 +7,15 @@ extern "C" { extern Driver cardputer_keyboard_driver; extern Driver cardputer_adv_keyboard_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&cardputer_keyboard_driver) == ERROR_NONE); - check(driver_construct_add(&cardputer_adv_keyboard_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&cardputer_keyboard_driver) == ERROR_NONE); - check(driver_remove_destruct(&cardputer_adv_keyboard_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* m5stack_drivers[] = { + &cardputer_keyboard_driver, + &cardputer_adv_keyboard_driver, + nullptr +}; Module m5stack_module = { .name = "m5stack", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = m5stack_drivers }; } // extern "C" diff --git a/Drivers/mpu6886-module/source/module.cpp b/Drivers/mpu6886-module/source/module.cpp index 044ea12db..05f41aeac 100644 --- a/Drivers/mpu6886-module/source/module.cpp +++ b/Drivers/mpu6886-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,6 +6,11 @@ extern "C" { extern Driver mpu6886_driver; +static const Driver* mpu6886_drivers[] = { + &mpu6886_driver, + nullptr +}; + static error_t start() { /* We crash when construct fails, because if a single driver fails to construct, * there is no guarantee that the previously constructed drivers can be destroyed */ @@ -25,10 +29,8 @@ extern const ModuleSymbol mpu6886_module_symbols[]; Module mpu6886_module = { .name = "mpu6886", - .start = start, - .stop = stop, + .drivers = mpu6886_drivers, .symbols = mpu6886_module_symbols, - .internal = nullptr }; } // extern "C" diff --git a/Drivers/pdm-mic-module/source/module.cpp b/Drivers/pdm-mic-module/source/module.cpp index da290481e..a64412372 100644 --- a/Drivers/pdm-mic-module/source/module.cpp +++ b/Drivers/pdm-mic-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,24 +6,17 @@ extern "C" { extern Driver pdm_mic_driver; -static error_t start() { - check(driver_construct_add(&pdm_mic_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&pdm_mic_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* pdm_mic_drivers[] = { + &pdm_mic_driver, + nullptr +}; extern const ModuleSymbol pdm_mic_module_symbols[]; Module pdm_mic_module = { .name = "pdm_mic", - .start = start, - .stop = stop, + .drivers = pdm_mic_drivers, .symbols = pdm_mic_module_symbols, - .internal = nullptr }; } diff --git a/Drivers/pi4ioe5v6408-module/source/module.cpp b/Drivers/pi4ioe5v6408-module/source/module.cpp index bb744edcb..a3a6234b5 100644 --- a/Drivers/pi4ioe5v6408-module/source/module.cpp +++ b/Drivers/pi4ioe5v6408-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver pi4ioe5v6408_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&pi4ioe5v6408_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&pi4ioe5v6408_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* pi4ioe5v6408_drivers[] = { + &pi4ioe5v6408_driver, + nullptr +}; Module pi4ioe5v6408_module = { .name = "pi4ioe5v6408", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = pi4ioe5v6408_drivers }; } diff --git a/Drivers/py32ioexpander-module/source/module.cpp b/Drivers/py32ioexpander-module/source/module.cpp index 5cbd2123a..90daf059c 100644 --- a/Drivers/py32ioexpander-module/source/module.cpp +++ b/Drivers/py32ioexpander-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,22 +6,14 @@ extern "C" { extern Driver py32ioexpander_driver; -static error_t start() { - check(driver_construct_add(&py32ioexpander_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&py32ioexpander_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* py32ioexpander_drivers[] = { + &py32ioexpander_driver, + nullptr +}; Module py32ioexpander_module = { .name = "py32ioexpander", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = py32ioexpander_drivers }; } // extern "C" diff --git a/Drivers/qmi8658-module/source/module.cpp b/Drivers/qmi8658-module/source/module.cpp index 5e2308c24..48ff9e51d 100644 --- a/Drivers/qmi8658-module/source/module.cpp +++ b/Drivers/qmi8658-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,28 +6,17 @@ extern "C" { extern Driver qmi8658_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&qmi8658_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&qmi8658_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* qmi8658_drivers[] = { + &qmi8658_driver, + nullptr +}; extern const ModuleSymbol qmi8658_module_symbols[]; Module qmi8658_module = { .name = "qmi8658", - .start = start, - .stop = stop, + .drivers = qmi8658_drivers, .symbols = qmi8658_module_symbols, - .internal = nullptr }; } // extern "C" diff --git a/Drivers/rgb-display-module/source/module.cpp b/Drivers/rgb-display-module/source/module.cpp index 79db516c4..97a26cb32 100644 --- a/Drivers/rgb-display-module/source/module.cpp +++ b/Drivers/rgb-display-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver rgb_display_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&rgb_display_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&rgb_display_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* rgbd_display_drivers[] = { + &rgb_display_driver, + nullptr +}; Module rgb_display_module = { .name = "rgb_display", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = rgbd_display_drivers }; } // extern "C" diff --git a/Drivers/rx8130ce-module/source/module.cpp b/Drivers/rx8130ce-module/source/module.cpp index e639b829b..ff732acda 100644 --- a/Drivers/rx8130ce-module/source/module.cpp +++ b/Drivers/rx8130ce-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver rx8130ce_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&rx8130ce_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&rx8130ce_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* rx8130ce_drivers[] = { + &rx8130ce_driver, + nullptr +}; Module rx8130ce_module = { .name = "rx8130ce", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = rx8130ce_drivers }; } // extern "C" diff --git a/Drivers/sc2356-module/source/module.cpp b/Drivers/sc2356-module/source/module.cpp index 693b34ea0..46f2cde93 100644 --- a/Drivers/sc2356-module/source/module.cpp +++ b/Drivers/sc2356-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,22 +6,14 @@ extern "C" { extern Driver sc2356_driver; -static error_t start() { - check(driver_construct_add(&sc2356_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - check(driver_remove_destruct(&sc2356_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* sc2356_drivers[] = { + &sc2356_driver, + nullptr +}; Module sc2356_module = { .name = "sc2356", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = sc2356_drivers }; } // extern "C" diff --git a/Drivers/ssd1306-module/source/module.cpp b/Drivers/ssd1306-module/source/module.cpp index 2ab1b0b25..6f3158eaa 100644 --- a/Drivers/ssd1306-module/source/module.cpp +++ b/Drivers/ssd1306-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver ssd1306_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&ssd1306_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&ssd1306_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* ssd1306_drivers[] = { + &ssd1306_driver, + nullptr +}; Module ssd1306_module = { .name = "ssd1306", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = ssd1306_drivers }; } // extern "C" diff --git a/Drivers/st7123-module/source/module.cpp b/Drivers/st7123-module/source/module.cpp index c74a4c119..c8e62e1b6 100644 --- a/Drivers/st7123-module/source/module.cpp +++ b/Drivers/st7123-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,28 +7,15 @@ extern "C" { extern Driver st7123_driver; extern Driver st7123_touch_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&st7123_driver) == ERROR_NONE); - check(driver_construct_add(&st7123_touch_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&st7123_touch_driver) == ERROR_NONE); - check(driver_remove_destruct(&st7123_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* st7123_drivers[] = { + &st7123_driver, + &st7123_touch_driver, + nullptr +}; Module st7123_module = { .name = "st7123", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = st7123_drivers }; } // extern "C" diff --git a/Drivers/st7701-module/source/module.cpp b/Drivers/st7701-module/source/module.cpp index 80c1e5cde..87099b5bd 100644 --- a/Drivers/st7701-module/source/module.cpp +++ b/Drivers/st7701-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver st7701_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&st7701_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&st7701_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* st7701_drivers[] = { + &st7701_driver, + nullptr +}; Module st7701_module = { .name = "st7701", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = st7701_drivers }; } // extern "C" diff --git a/Drivers/st7735-module/source/module.cpp b/Drivers/st7735-module/source/module.cpp index c867f4b60..118ee3ba5 100644 --- a/Drivers/st7735-module/source/module.cpp +++ b/Drivers/st7735-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver st7735_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&st7735_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&st7735_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* st7735_drivers[] = { + &st7735_driver, + nullptr +}; Module st7735_module = { .name = "st7735", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = st7735_drivers }; } // extern "C" diff --git a/Drivers/st7789-i8080-module/source/module.cpp b/Drivers/st7789-i8080-module/source/module.cpp index 0a1567d8e..19bccac96 100644 --- a/Drivers/st7789-i8080-module/source/module.cpp +++ b/Drivers/st7789-i8080-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver st7789_i8080_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&st7789_i8080_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&st7789_i8080_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* st7789_i8080_drivers[] = { + &st7789_i8080_driver, + nullptr +}; Module st7789_i8080_module = { .name = "st7789_i8080", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = st7789_i8080_drivers }; } // extern "C" diff --git a/Drivers/st7789-module/source/module.cpp b/Drivers/st7789-module/source/module.cpp index dcf6735a8..df376d492 100644 --- a/Drivers/st7789-module/source/module.cpp +++ b/Drivers/st7789-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver st7789_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&st7789_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&st7789_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* st7789_drivers[] = { + &st7789_driver, + nullptr +}; Module st7789_module = { .name = "st7789", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = st7789_drivers }; } // extern "C" diff --git a/Drivers/st7796-i8080-module/source/module.cpp b/Drivers/st7796-i8080-module/source/module.cpp index 037c4c28a..d499b12e6 100644 --- a/Drivers/st7796-i8080-module/source/module.cpp +++ b/Drivers/st7796-i8080-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver st7796_i8080_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&st7796_i8080_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&st7796_i8080_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* st7796_i8080_drivers[] = { + &st7796_i8080_driver, + nullptr +}; Module st7796_i8080_module = { .name = "st7796_i8080", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = st7796_i8080_drivers }; } // extern "C" diff --git a/Drivers/st7796-module/source/module.cpp b/Drivers/st7796-module/source/module.cpp index 271218a49..6968ae020 100644 --- a/Drivers/st7796-module/source/module.cpp +++ b/Drivers/st7796-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver st7796_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&st7796_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&st7796_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* st7796_drivers[] = { + &st7796_driver, + nullptr +}; Module st7796_module = { .name = "st7796", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = st7796_drivers }; } // extern "C" diff --git a/Drivers/sy6970-module/source/module.cpp b/Drivers/sy6970-module/source/module.cpp index b27fe0e93..45767ecf8 100644 --- a/Drivers/sy6970-module/source/module.cpp +++ b/Drivers/sy6970-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,28 +7,15 @@ extern "C" { extern Driver sy6970_driver; extern Driver sy6970_power_supply_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&sy6970_power_supply_driver) == ERROR_NONE); - check(driver_construct_add(&sy6970_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&sy6970_driver) == ERROR_NONE); - check(driver_remove_destruct(&sy6970_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* sy6970_drivers[] = { + &sy6970_driver, + &sy6970_power_supply_driver, + nullptr +}; Module sy6970_module = { .name = "sy6970", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = sy6970_drivers }; } // extern "C" diff --git a/Drivers/tca8418-module/source/module.cpp b/Drivers/tca8418-module/source/module.cpp index e5ab6e7e1..2efa8db00 100644 --- a/Drivers/tca8418-module/source/module.cpp +++ b/Drivers/tca8418-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver tca8418_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&tca8418_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&tca8418_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* tca8418_drivers[] = { + &tca8418_driver, + nullptr +}; Module tca8418_module = { .name = "tca8418", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = tca8418_drivers }; } // extern "C" diff --git a/Drivers/tca9534-module/source/module.cpp b/Drivers/tca9534-module/source/module.cpp index 96f43aa56..92aee836c 100644 --- a/Drivers/tca9534-module/source/module.cpp +++ b/Drivers/tca9534-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver tca9534_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&tca9534_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&tca9534_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* tca9534_drivers[] = { + &tca9534_driver, + nullptr +}; Module tca9534_module = { .name = "tca9534", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = tca9534_drivers }; } diff --git a/Drivers/tca95xx-16bit-module/source/module.cpp b/Drivers/tca95xx-16bit-module/source/module.cpp index 868430331..ab8de36f4 100644 --- a/Drivers/tca95xx-16bit-module/source/module.cpp +++ b/Drivers/tca95xx-16bit-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver tca95xx_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&tca95xx_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&tca95xx_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* tca95xx_drivers[] = { + &tca95xx_driver, + nullptr +}; Module tca95xx_16bit_module = { .name = "tca95xx", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = tca95xx_drivers }; } diff --git a/Drivers/xl9555-module/source/module.cpp b/Drivers/xl9555-module/source/module.cpp index 61915ee9b..b46726b71 100644 --- a/Drivers/xl9555-module/source/module.cpp +++ b/Drivers/xl9555-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver xl9555_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&xl9555_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&xl9555_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* xl9555_drivers[] = { + &xl9555_driver, + nullptr +}; Module xl9555_module = { .name = "xl9555", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = xl9555_drivers }; } diff --git a/Drivers/xpt2046-module/source/module.cpp b/Drivers/xpt2046-module/source/module.cpp index 5d5e8b532..f54432903 100644 --- a/Drivers/xpt2046-module/source/module.cpp +++ b/Drivers/xpt2046-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,28 +7,15 @@ extern "C" { extern Driver xpt2046_driver; extern Driver xpt2046_power_supply_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&xpt2046_driver) == ERROR_NONE); - check(driver_construct_add(&xpt2046_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&xpt2046_power_supply_driver) == ERROR_NONE); - check(driver_remove_destruct(&xpt2046_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* xpt2046_drivers[] = { + &xpt2046_driver, + &xpt2046_power_supply_driver, + nullptr +}; Module xpt2046_module = { .name = "xpt2046", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = xpt2046_drivers }; } // extern "C" diff --git a/Drivers/xpt2046-softspi-module/source/module.cpp b/Drivers/xpt2046-softspi-module/source/module.cpp index d7350a14b..974bf7004 100644 --- a/Drivers/xpt2046-softspi-module/source/module.cpp +++ b/Drivers/xpt2046-softspi-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -8,28 +7,15 @@ extern "C" { extern Driver xpt2046_softspi_driver; extern Driver xpt2046_softspi_power_supply_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&xpt2046_softspi_driver) == ERROR_NONE); - check(driver_construct_add(&xpt2046_softspi_power_supply_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&xpt2046_softspi_power_supply_driver) == ERROR_NONE); - check(driver_remove_destruct(&xpt2046_softspi_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* xpt2046_softspi_drivers[] = { + &xpt2046_softspi_driver, + &xpt2046_softspi_power_supply_driver, + nullptr +}; Module xpt2046_softspi_module = { .name = "xpt2046_softspi", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = xpt2046_softspi_drivers }; } // extern "C" diff --git a/Modules/crypt-module/source/module.cpp b/Modules/crypt-module/source/module.cpp index d1e413499..63b3d5063 100644 --- a/Modules/crypt-module/source/module.cpp +++ b/Modules/crypt-module/source/module.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 #include #include -#include #include extern "C" { @@ -18,10 +17,7 @@ static const ModuleSymbol crypt_module_symbols[] = { Module crypt_module = { .name = "crypt", - .start = [] -> error_t { return ERROR_NONE; }, - .stop = [] -> error_t { return ERROR_NONE; }, - .symbols = crypt_module_symbols, - .internal = nullptr + .symbols = crypt_module_symbols }; } diff --git a/Modules/hal-device-module/source/module.cpp b/Modules/hal-device-module/source/module.cpp index bf36c6b72..df3de8161 100644 --- a/Modules/hal-device-module/source/module.cpp +++ b/Modules/hal-device-module/source/module.cpp @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -#include #include #include @@ -7,26 +6,14 @@ extern "C" { extern Driver hal_device_driver; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&hal_device_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&hal_device_driver) == ERROR_NONE); - return ERROR_NONE; -} +static const Driver* hal_device_drivers[] = { + &hal_device_driver, + nullptr +}; -struct Module hal_device_module = { +Module hal_device_module = { .name = "hal-device", - .start = start, - .stop = stop, - .symbols = nullptr, - .internal = nullptr + .drivers = hal_device_drivers }; } diff --git a/TactilityKernel/include/tactility/module.h b/TactilityKernel/include/tactility/module.h index 910f29b45..ede109795 100644 --- a/TactilityKernel/include/tactility/module.h +++ b/TactilityKernel/include/tactility/module.h @@ -26,6 +26,7 @@ struct ModuleSymbol { const void* symbol; }; +struct Driver; struct ModuleInternal; /** @@ -40,18 +41,23 @@ struct Module { */ const char* name; /** - * A function to initialize the module. - * Should never be NULL. + * A function to initialize the module, or NULL. * This can be used to load drivers, initialize hardware, etc. * @return ERROR_NONE if successful */ error_t (*start)(void); /** - * Deinitializes the module. - * Should never be NULL. + * A function to deinitialize the module, or NULL. * @return ERROR_NONE if successful */ error_t (*stop)(void); + /** + * An array of driver pointers, or NULL. + * The list must be NULL-terminated. + * When the module is started, these drivers are constructed and added to the module. + * When the module is stopped, these drivers are removed from the module and destroyed. + */ + const struct Driver** drivers; /** * A list of symbols exported by the module. * Should be terminated by MODULE_SYMBOL_TERMINATOR. diff --git a/TactilityKernel/source/module.cpp b/TactilityKernel/source/module.cpp index 5275709dd..dc9a0962a 100644 --- a/TactilityKernel/source/module.cpp +++ b/TactilityKernel/source/module.cpp @@ -3,9 +3,12 @@ #include #include #include + +#include "tactility/driver.h" + #include -#define TAG "module" +constexpr auto* TAG = "module"; struct ModuleInternal { bool started = false; @@ -56,33 +59,60 @@ error_t module_start(Module* module) { if (internal == nullptr) return ERROR_INVALID_STATE; if (internal->started) return ERROR_NONE; - error_t error = module->start(); - internal->started = (error == ERROR_NONE); - return error; + if (module->start != nullptr) { + auto error = module->start(); + if (error != ERROR_NONE) { + return error; + } + } + + if (module->drivers != nullptr) { + auto* driver_location = module->drivers; + while (*driver_location != nullptr) { + auto driver = *driver_location; + driver_construct_add(driver); + driver_location++; + } + } + + internal->started = true; + return ERROR_NONE; } -bool module_is_started(struct Module* module) { +bool module_is_started(Module* module) { auto* internal = module->internal; return internal != nullptr && internal->started; } -error_t module_stop(struct Module* module) { +error_t module_stop(Module* module) { LOG_I(TAG, "stop %s", module->name); auto* internal = module->internal; if (internal == nullptr) return ERROR_INVALID_STATE; if (!internal->started) return ERROR_NONE; - error_t error = module->stop(); - if (error != ERROR_NONE) { - return error; + if (module->drivers != nullptr) { + auto* driver_location = module->drivers; + while (*driver_location != nullptr) { + auto driver = *driver_location; + driver_remove_destruct(driver); + driver_location++; + } + } + + if (module->stop != nullptr) { + auto error = module->stop(); + if (error != ERROR_NONE) { + return error; + } + } internal->started = false; - return error; + return ERROR_NONE; } -error_t module_construct_add_start(struct Module* module) { +error_t module_construct_add_start(Module* module) { error_t error = module_construct(module); if (error != ERROR_NONE) return error; error = module_add(module); From 74bcd979c561f09207b33fe7136a2f7993ff64bd Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Thu, 23 Jul 2026 00:42:49 +0200 Subject: [PATCH 2/2] Fixes --- Devices/m5stack-papers3/source/module.cpp | 2 +- Devices/m5stack-tab5/Source/module.cpp | 4 ++-- Devices/unphone/source/module.cpp | 2 +- Drivers/aw88298-module/source/module.cpp | 2 +- Drivers/aw9523b-module/source/module.cpp | 2 +- Drivers/axp192-module/source/module.cpp | 2 +- Drivers/axp2101-module/source/module.cpp | 2 +- Drivers/axs5106-module/source/module.cpp | 2 +- Drivers/bm8563-module/source/module.cpp | 2 +- Drivers/bmi270-module/source/module.cpp | 2 +- Drivers/bq24295-module/source/module.cpp | 2 +- Drivers/bq25896-module/source/module.cpp | 2 +- Drivers/bq27220-module/source/module.cpp | 2 +- Drivers/button-control-module/source/module.cpp | 2 +- Drivers/ch422g-module/source/module.cpp | 2 +- Drivers/cst328-module/source/module.cpp | 2 +- Drivers/cst66xx-module/source/module.cpp | 2 +- Drivers/cst816s-module/source/module.cpp | 2 +- Drivers/cst816t-module/source/module.cpp | 2 +- Drivers/drv2605-module/source/module.cpp | 2 +- Drivers/dummy-i2s-amp-module/source/module.cpp | 2 +- Drivers/es7210-module/source/module.cpp | 2 +- Drivers/es8311-module/source/module.cpp | 2 +- Drivers/es8388-module/source/module.cpp | 2 +- Drivers/ft5x06-module/source/module.cpp | 2 +- Drivers/ft6x36-module/source/module.cpp | 2 +- Drivers/gc9a01-module/source/module.cpp | 2 +- Drivers/gt911-module/source/module.cpp | 2 +- Drivers/hx8357-module/source/module.cpp | 2 +- Drivers/ili9341-module/source/module.cpp | 2 +- Drivers/ili9488-module/source/module.cpp | 2 +- Drivers/ili9881c-module/source/module.cpp | 2 +- Drivers/ina226-module/source/module.cpp | 2 +- Drivers/jd9165-module/source/module.cpp | 2 +- Drivers/jd9853-module/source/module.cpp | 2 +- Drivers/lilygo-module/source/module.cpp | 2 +- Drivers/m5pm1-module/source/module.cpp | 2 +- Drivers/m5stack-module/source/module.cpp | 2 +- Drivers/mpu6886-module/source/module.cpp | 16 +--------------- Drivers/pdm-mic-module/source/module.cpp | 2 +- Drivers/pi4ioe5v6408-module/source/module.cpp | 2 +- Drivers/py32ioexpander-module/source/module.cpp | 2 +- Drivers/qmi8658-module/source/module.cpp | 2 +- Drivers/rgb-display-module/source/module.cpp | 2 +- Drivers/rx8130ce-module/source/module.cpp | 2 +- Drivers/sc2356-module/source/module.cpp | 2 +- Drivers/ssd1306-module/source/module.cpp | 2 +- Drivers/st7123-module/source/module.cpp | 2 +- Drivers/st7701-module/source/module.cpp | 2 +- Drivers/st7735-module/source/module.cpp | 2 +- Drivers/st7789-i8080-module/source/module.cpp | 2 +- Drivers/st7789-module/source/module.cpp | 2 +- Drivers/st7796-i8080-module/source/module.cpp | 2 +- Drivers/st7796-module/source/module.cpp | 2 +- Drivers/sy6970-module/source/module.cpp | 2 +- Drivers/tca8418-module/source/module.cpp | 2 +- Drivers/tca9534-module/source/module.cpp | 2 +- Drivers/tca95xx-16bit-module/source/module.cpp | 2 +- Drivers/xl9555-module/source/module.cpp | 2 +- Drivers/xpt2046-module/source/module.cpp | 2 +- Drivers/xpt2046-softspi-module/source/module.cpp | 2 +- Modules/hal-device-module/source/module.cpp | 2 +- TactilityKernel/include/tactility/module.h | 2 +- TactilityKernel/source/module.cpp | 14 +++++++------- 64 files changed, 71 insertions(+), 85 deletions(-) diff --git a/Devices/m5stack-papers3/source/module.cpp b/Devices/m5stack-papers3/source/module.cpp index 0a887f5b4..0060cf9c0 100644 --- a/Devices/m5stack-papers3/source/module.cpp +++ b/Devices/m5stack-papers3/source/module.cpp @@ -7,7 +7,7 @@ extern Driver papers3_power_driver; extern Driver papers3_power_supply_driver; extern Driver papers3_display_driver; -static const Driver* papers3_drivers[] = { +static Driver* const papers3_drivers[] = { &papers3_display_driver, &papers3_power_driver, &papers3_power_supply_driver, diff --git a/Devices/m5stack-tab5/Source/module.cpp b/Devices/m5stack-tab5/Source/module.cpp index e96d5b354..3593123a4 100644 --- a/Devices/m5stack-tab5/Source/module.cpp +++ b/Devices/m5stack-tab5/Source/module.cpp @@ -79,7 +79,7 @@ static error_t stop() { return ERROR_NONE; } -static const Driver* tab5_drivers[] = { +static Driver* const tab5_drivers[] = { &tab5_keyboard_driver, &tab5_power_control_driver, nullptr @@ -89,7 +89,7 @@ Module m5stack_tab5_module = { .name = "m5stack-tab5", .start = start, .stop = stop, - .drivers = const_cast(tab5_drivers) + .drivers = tab5_drivers }; } diff --git a/Devices/unphone/source/module.cpp b/Devices/unphone/source/module.cpp index e3298b5f9..5969f540f 100644 --- a/Devices/unphone/source/module.cpp +++ b/Devices/unphone/source/module.cpp @@ -47,7 +47,7 @@ static error_t stop() { return ERROR_NONE; } -static const Driver* unphone_drivers[] = { +static Driver* const unphone_drivers[] = { &unphone_nav_buttons_driver, &unphone_power_switch_driver, nullptr diff --git a/Drivers/aw88298-module/source/module.cpp b/Drivers/aw88298-module/source/module.cpp index d9885b483..8e067a2d2 100644 --- a/Drivers/aw88298-module/source/module.cpp +++ b/Drivers/aw88298-module/source/module.cpp @@ -8,7 +8,7 @@ extern Driver aw88298_driver; extern const ModuleSymbol aw88298_module_symbols[]; -static const Driver* aw88298_drivers[] = { +static Driver* const aw88298_drivers[] = { &aw88298_driver, nullptr }; diff --git a/Drivers/aw9523b-module/source/module.cpp b/Drivers/aw9523b-module/source/module.cpp index cc2d28c57..e7b280106 100644 --- a/Drivers/aw9523b-module/source/module.cpp +++ b/Drivers/aw9523b-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver aw9523b_driver; -static const Driver* aw9523b_drivers[] = { +static Driver* const aw9523b_drivers[] = { &aw9523b_driver, nullptr }; diff --git a/Drivers/axp192-module/source/module.cpp b/Drivers/axp192-module/source/module.cpp index d7e347b58..b9997ab09 100644 --- a/Drivers/axp192-module/source/module.cpp +++ b/Drivers/axp192-module/source/module.cpp @@ -9,7 +9,7 @@ extern Driver axp192_driver; extern Driver axp192_power_supply_driver; extern Driver axp192_backlight_driver; -static const Driver* axp192_drivers[] = { +static Driver* const axp192_drivers[] = { &axp192_driver, &axp192_power_supply_driver, &axp192_backlight_driver, diff --git a/Drivers/axp2101-module/source/module.cpp b/Drivers/axp2101-module/source/module.cpp index c135f177d..fd2995e48 100644 --- a/Drivers/axp2101-module/source/module.cpp +++ b/Drivers/axp2101-module/source/module.cpp @@ -9,7 +9,7 @@ extern Driver axp2101_driver; extern Driver axp2101_power_supply_driver; extern Driver axp2101_backlight_driver; -static const Driver* axp2101_drivers[] = { +static Driver* const axp2101_drivers[] = { &axp2101_driver, &axp2101_power_supply_driver, &axp2101_backlight_driver, diff --git a/Drivers/axs5106-module/source/module.cpp b/Drivers/axs5106-module/source/module.cpp index 3db546274..0b465574d 100644 --- a/Drivers/axs5106-module/source/module.cpp +++ b/Drivers/axs5106-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver axs5106_driver; -static const Driver* axs5106_drivers[] = { +static Driver* const axs5106_drivers[] = { &axs5106_driver, nullptr }; diff --git a/Drivers/bm8563-module/source/module.cpp b/Drivers/bm8563-module/source/module.cpp index bd9e1ec67..7a73b962c 100644 --- a/Drivers/bm8563-module/source/module.cpp +++ b/Drivers/bm8563-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver bm8563_driver; -static const Driver* bm8563_drivers[] = { +static Driver* const bm8563_drivers[] = { &bm8563_driver, nullptr }; diff --git a/Drivers/bmi270-module/source/module.cpp b/Drivers/bmi270-module/source/module.cpp index e77fe8c64..9dfac1285 100644 --- a/Drivers/bmi270-module/source/module.cpp +++ b/Drivers/bmi270-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver bmi270_driver; -static const Driver* bmi270_drivers[] = { +static Driver* const bmi270_drivers[] = { &bmi270_driver, nullptr }; diff --git a/Drivers/bq24295-module/source/module.cpp b/Drivers/bq24295-module/source/module.cpp index 545c84e53..dc6710360 100644 --- a/Drivers/bq24295-module/source/module.cpp +++ b/Drivers/bq24295-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver bq24295_driver; extern Driver bq24295_power_supply_driver; -static const Driver* bq24295_drivers[] = { +static Driver* const bq24295_drivers[] = { &bq24295_driver, &bq24295_power_supply_driver, nullptr diff --git a/Drivers/bq25896-module/source/module.cpp b/Drivers/bq25896-module/source/module.cpp index d4a27efba..5a67a7ff9 100644 --- a/Drivers/bq25896-module/source/module.cpp +++ b/Drivers/bq25896-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver bq25896_driver; extern Driver bq25896_power_supply_driver; -static const Driver* bq25896_drivers[] = { +static Driver* const bq25896_drivers[] = { &bq25896_driver, &bq25896_power_supply_driver, nullptr diff --git a/Drivers/bq27220-module/source/module.cpp b/Drivers/bq27220-module/source/module.cpp index b6ee788c8..c4fae88d2 100644 --- a/Drivers/bq27220-module/source/module.cpp +++ b/Drivers/bq27220-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver bq27220_driver; extern Driver bq27220_power_supply_driver; -static const Driver* bq27220_drivers[] = { +static Driver* const bq27220_drivers[] = { &bq27220_driver, &bq27220_power_supply_driver, nullptr diff --git a/Drivers/button-control-module/source/module.cpp b/Drivers/button-control-module/source/module.cpp index dd40acf02..183f597de 100644 --- a/Drivers/button-control-module/source/module.cpp +++ b/Drivers/button-control-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver button_control_driver; -static const Driver* button_control_drivers[] = { +static Driver* const button_control_drivers[] = { &button_control_driver, nullptr }; diff --git a/Drivers/ch422g-module/source/module.cpp b/Drivers/ch422g-module/source/module.cpp index bc7cbdeb2..9e16d6641 100644 --- a/Drivers/ch422g-module/source/module.cpp +++ b/Drivers/ch422g-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver ch422g_driver; -static const Driver* ch422g_drivers[] = { +static Driver* const ch422g_drivers[] = { &ch422g_driver, nullptr }; diff --git a/Drivers/cst328-module/source/module.cpp b/Drivers/cst328-module/source/module.cpp index 1716c61f6..80529ec15 100644 --- a/Drivers/cst328-module/source/module.cpp +++ b/Drivers/cst328-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver cst328_driver; -static const Driver* cst328_drivers[] = { +static Driver* const cst328_drivers[] = { &cst328_driver, nullptr }; diff --git a/Drivers/cst66xx-module/source/module.cpp b/Drivers/cst66xx-module/source/module.cpp index 8c7238daa..f8ab86a73 100644 --- a/Drivers/cst66xx-module/source/module.cpp +++ b/Drivers/cst66xx-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver cst66xx_driver; -static const Driver* cst66xx_drivers[] = { +static Driver* const cst66xx_drivers[] = { &cst66xx_driver, nullptr }; diff --git a/Drivers/cst816s-module/source/module.cpp b/Drivers/cst816s-module/source/module.cpp index 45a952337..c2400011d 100644 --- a/Drivers/cst816s-module/source/module.cpp +++ b/Drivers/cst816s-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver cst816s_driver; -static const Driver* cst816s_drivers[] = { +static Driver* const cst816s_drivers[] = { &cst816s_driver, nullptr }; diff --git a/Drivers/cst816t-module/source/module.cpp b/Drivers/cst816t-module/source/module.cpp index 227885291..4e4af0ee1 100644 --- a/Drivers/cst816t-module/source/module.cpp +++ b/Drivers/cst816t-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver cst816t_driver; -static const Driver* cst816t_drivers[] = { +static Driver* const cst816t_drivers[] = { &cst816t_driver, nullptr }; diff --git a/Drivers/drv2605-module/source/module.cpp b/Drivers/drv2605-module/source/module.cpp index 4188781f8..f6e0f2752 100644 --- a/Drivers/drv2605-module/source/module.cpp +++ b/Drivers/drv2605-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver drv2605_driver; -static const Driver* drv2605_drivers[] = { +static Driver* const drv2605_drivers[] = { &drv2605_driver, nullptr }; diff --git a/Drivers/dummy-i2s-amp-module/source/module.cpp b/Drivers/dummy-i2s-amp-module/source/module.cpp index fe14fd7ba..efe4c34bd 100644 --- a/Drivers/dummy-i2s-amp-module/source/module.cpp +++ b/Drivers/dummy-i2s-amp-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver dummy_i2s_amp_driver; -static const Driver* dummy_drivers[] = { +static Driver* const dummy_drivers[] = { &dummy_i2s_amp_driver, nullptr }; diff --git a/Drivers/es7210-module/source/module.cpp b/Drivers/es7210-module/source/module.cpp index 0c7e000e0..833b67595 100644 --- a/Drivers/es7210-module/source/module.cpp +++ b/Drivers/es7210-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver es7210_driver; -static const Driver* es7210_drivers[] = { +static Driver* const es7210_drivers[] = { &es7210_driver, nullptr }; diff --git a/Drivers/es8311-module/source/module.cpp b/Drivers/es8311-module/source/module.cpp index 9907a258b..ab4208171 100644 --- a/Drivers/es8311-module/source/module.cpp +++ b/Drivers/es8311-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver es8311_driver; -static const Driver* es8311_drivers[] = { +static Driver* const es8311_drivers[] = { &es8311_driver, nullptr }; diff --git a/Drivers/es8388-module/source/module.cpp b/Drivers/es8388-module/source/module.cpp index 8f3b5400b..69bb68677 100644 --- a/Drivers/es8388-module/source/module.cpp +++ b/Drivers/es8388-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver es8388_driver; -static const Driver* es8388_drivers[] = { +static Driver* const es8388_drivers[] = { &es8388_driver, nullptr }; diff --git a/Drivers/ft5x06-module/source/module.cpp b/Drivers/ft5x06-module/source/module.cpp index ee705df5a..ce79913b2 100644 --- a/Drivers/ft5x06-module/source/module.cpp +++ b/Drivers/ft5x06-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver ft5x06_driver; -static const Driver* ft5x06_drivers[] = { +static Driver* const ft5x06_drivers[] = { &ft5x06_driver, nullptr }; diff --git a/Drivers/ft6x36-module/source/module.cpp b/Drivers/ft6x36-module/source/module.cpp index 11652be37..bd6c28e33 100644 --- a/Drivers/ft6x36-module/source/module.cpp +++ b/Drivers/ft6x36-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver ft6x36_driver; -static const Driver* ft6x36_drivers[] = { +static Driver* const ft6x36_drivers[] = { &ft6x36_driver, nullptr }; diff --git a/Drivers/gc9a01-module/source/module.cpp b/Drivers/gc9a01-module/source/module.cpp index b6fcf4560..164f6e2ae 100644 --- a/Drivers/gc9a01-module/source/module.cpp +++ b/Drivers/gc9a01-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver gc9a01_driver; -static const Driver* gc9a01_drivers[] = { +static Driver* const gc9a01_drivers[] = { &gc9a01_driver, nullptr }; diff --git a/Drivers/gt911-module/source/module.cpp b/Drivers/gt911-module/source/module.cpp index fe8c7efee..d9749a304 100644 --- a/Drivers/gt911-module/source/module.cpp +++ b/Drivers/gt911-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver gt911_driver; -static const Driver* gt911_drivers[] = { +static Driver* const gt911_drivers[] = { >911_driver, nullptr }; diff --git a/Drivers/hx8357-module/source/module.cpp b/Drivers/hx8357-module/source/module.cpp index 3003f6f16..fbd6cb5f5 100644 --- a/Drivers/hx8357-module/source/module.cpp +++ b/Drivers/hx8357-module/source/module.cpp @@ -4,7 +4,7 @@ extern Driver hx8357_driver; -static const Driver* hx8357_drivers[] = { +static Driver* const hx8357_drivers[] = { &hx8357_driver, nullptr }; diff --git a/Drivers/ili9341-module/source/module.cpp b/Drivers/ili9341-module/source/module.cpp index 715b9723d..9faaca4b4 100644 --- a/Drivers/ili9341-module/source/module.cpp +++ b/Drivers/ili9341-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver ili9341_driver; -static const Driver* ili9341_drivers[] = { +static Driver* const ili9341_drivers[] = { &ili9341_driver, nullptr }; diff --git a/Drivers/ili9488-module/source/module.cpp b/Drivers/ili9488-module/source/module.cpp index 226cf49d1..dbd7cade0 100644 --- a/Drivers/ili9488-module/source/module.cpp +++ b/Drivers/ili9488-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver ili9488_driver; -static const Driver* ili9488_drivers[] = { +static Driver* const ili9488_drivers[] = { &ili9488_driver, nullptr }; diff --git a/Drivers/ili9881c-module/source/module.cpp b/Drivers/ili9881c-module/source/module.cpp index dc1ace654..b4e2faf92 100644 --- a/Drivers/ili9881c-module/source/module.cpp +++ b/Drivers/ili9881c-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver ili9881c_driver; -static const Driver* ili9881c_drivers[] = { +static Driver* const ili9881c_drivers[] = { &ili9881c_driver, nullptr }; diff --git a/Drivers/ina226-module/source/module.cpp b/Drivers/ina226-module/source/module.cpp index 092be9b99..4159cfc76 100644 --- a/Drivers/ina226-module/source/module.cpp +++ b/Drivers/ina226-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver ina226_driver; extern Driver ina226_power_supply_driver; -static const Driver* ina226_drivers[] = { +static Driver* const ina226_drivers[] = { &ina226_driver, &ina226_power_supply_driver, nullptr diff --git a/Drivers/jd9165-module/source/module.cpp b/Drivers/jd9165-module/source/module.cpp index 1a2ee89f6..dd0393a37 100644 --- a/Drivers/jd9165-module/source/module.cpp +++ b/Drivers/jd9165-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver jd9165_driver; -static const Driver* jd9165_drivers[] = { +static Driver* const jd9165_drivers[] = { &jd9165_driver, nullptr }; diff --git a/Drivers/jd9853-module/source/module.cpp b/Drivers/jd9853-module/source/module.cpp index 0522e53c4..5571a427d 100644 --- a/Drivers/jd9853-module/source/module.cpp +++ b/Drivers/jd9853-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver jd9853_driver; -static const Driver* jd9853_drivers[] = { +static Driver* const jd9853_drivers[] = { &jd9853_driver, nullptr }; diff --git a/Drivers/lilygo-module/source/module.cpp b/Drivers/lilygo-module/source/module.cpp index 8090f1658..c68103fd8 100644 --- a/Drivers/lilygo-module/source/module.cpp +++ b/Drivers/lilygo-module/source/module.cpp @@ -9,7 +9,7 @@ extern Driver tdeck_keyboard_backlight_driver; extern Driver tdeck_trackball_driver; extern Driver tpager_encoder_driver; -static const Driver* lilygo_drivers[] = { +static Driver* const lilygo_drivers[] = { &tdeck_keyboard_driver, &tdeck_keyboard_backlight_driver, &tdeck_trackball_driver, diff --git a/Drivers/m5pm1-module/source/module.cpp b/Drivers/m5pm1-module/source/module.cpp index 65fc19903..8ca27f6fc 100644 --- a/Drivers/m5pm1-module/source/module.cpp +++ b/Drivers/m5pm1-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver m5pm1_driver; extern Driver m5pm1_power_supply_driver; -static const Driver* m5pm1_drivers[] = { +static Driver* const m5pm1_drivers[] = { &m5pm1_driver, &m5pm1_power_supply_driver, nullptr diff --git a/Drivers/m5stack-module/source/module.cpp b/Drivers/m5stack-module/source/module.cpp index 1bd4c7ad9..9bd877cab 100644 --- a/Drivers/m5stack-module/source/module.cpp +++ b/Drivers/m5stack-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver cardputer_keyboard_driver; extern Driver cardputer_adv_keyboard_driver; -static const Driver* m5stack_drivers[] = { +static Driver* const m5stack_drivers[] = { &cardputer_keyboard_driver, &cardputer_adv_keyboard_driver, nullptr diff --git a/Drivers/mpu6886-module/source/module.cpp b/Drivers/mpu6886-module/source/module.cpp index 05f41aeac..99b530f09 100644 --- a/Drivers/mpu6886-module/source/module.cpp +++ b/Drivers/mpu6886-module/source/module.cpp @@ -6,25 +6,11 @@ extern "C" { extern Driver mpu6886_driver; -static const Driver* mpu6886_drivers[] = { +static Driver* const mpu6886_drivers[] = { &mpu6886_driver, nullptr }; -static error_t start() { - /* We crash when construct fails, because if a single driver fails to construct, - * there is no guarantee that the previously constructed drivers can be destroyed */ - check(driver_construct_add(&mpu6886_driver) == ERROR_NONE); - return ERROR_NONE; -} - -static error_t stop() { - /* We crash when destruct fails, because if a single driver fails to destruct, - * there is no guarantee that the previously destroyed drivers can be recovered */ - check(driver_remove_destruct(&mpu6886_driver) == ERROR_NONE); - return ERROR_NONE; -} - extern const ModuleSymbol mpu6886_module_symbols[]; Module mpu6886_module = { diff --git a/Drivers/pdm-mic-module/source/module.cpp b/Drivers/pdm-mic-module/source/module.cpp index a64412372..76ade6a1f 100644 --- a/Drivers/pdm-mic-module/source/module.cpp +++ b/Drivers/pdm-mic-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver pdm_mic_driver; -static const Driver* pdm_mic_drivers[] = { +static Driver* const pdm_mic_drivers[] = { &pdm_mic_driver, nullptr }; diff --git a/Drivers/pi4ioe5v6408-module/source/module.cpp b/Drivers/pi4ioe5v6408-module/source/module.cpp index a3a6234b5..b13d61fa4 100644 --- a/Drivers/pi4ioe5v6408-module/source/module.cpp +++ b/Drivers/pi4ioe5v6408-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver pi4ioe5v6408_driver; -static const Driver* pi4ioe5v6408_drivers[] = { +static Driver* const pi4ioe5v6408_drivers[] = { &pi4ioe5v6408_driver, nullptr }; diff --git a/Drivers/py32ioexpander-module/source/module.cpp b/Drivers/py32ioexpander-module/source/module.cpp index 90daf059c..cc26ee12c 100644 --- a/Drivers/py32ioexpander-module/source/module.cpp +++ b/Drivers/py32ioexpander-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver py32ioexpander_driver; -static const Driver* py32ioexpander_drivers[] = { +static Driver* const py32ioexpander_drivers[] = { &py32ioexpander_driver, nullptr }; diff --git a/Drivers/qmi8658-module/source/module.cpp b/Drivers/qmi8658-module/source/module.cpp index 48ff9e51d..6f365a63d 100644 --- a/Drivers/qmi8658-module/source/module.cpp +++ b/Drivers/qmi8658-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver qmi8658_driver; -static const Driver* qmi8658_drivers[] = { +static Driver* const qmi8658_drivers[] = { &qmi8658_driver, nullptr }; diff --git a/Drivers/rgb-display-module/source/module.cpp b/Drivers/rgb-display-module/source/module.cpp index 97a26cb32..537bc2e1a 100644 --- a/Drivers/rgb-display-module/source/module.cpp +++ b/Drivers/rgb-display-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver rgb_display_driver; -static const Driver* rgbd_display_drivers[] = { +static Driver* const rgbd_display_drivers[] = { &rgb_display_driver, nullptr }; diff --git a/Drivers/rx8130ce-module/source/module.cpp b/Drivers/rx8130ce-module/source/module.cpp index ff732acda..cf3ffaa71 100644 --- a/Drivers/rx8130ce-module/source/module.cpp +++ b/Drivers/rx8130ce-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver rx8130ce_driver; -static const Driver* rx8130ce_drivers[] = { +static Driver* const rx8130ce_drivers[] = { &rx8130ce_driver, nullptr }; diff --git a/Drivers/sc2356-module/source/module.cpp b/Drivers/sc2356-module/source/module.cpp index 46f2cde93..c82bc9281 100644 --- a/Drivers/sc2356-module/source/module.cpp +++ b/Drivers/sc2356-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver sc2356_driver; -static const Driver* sc2356_drivers[] = { +static Driver* const sc2356_drivers[] = { &sc2356_driver, nullptr }; diff --git a/Drivers/ssd1306-module/source/module.cpp b/Drivers/ssd1306-module/source/module.cpp index 6f3158eaa..8e15db551 100644 --- a/Drivers/ssd1306-module/source/module.cpp +++ b/Drivers/ssd1306-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver ssd1306_driver; -static const Driver* ssd1306_drivers[] = { +static Driver* const ssd1306_drivers[] = { &ssd1306_driver, nullptr }; diff --git a/Drivers/st7123-module/source/module.cpp b/Drivers/st7123-module/source/module.cpp index c8e62e1b6..d5da2da00 100644 --- a/Drivers/st7123-module/source/module.cpp +++ b/Drivers/st7123-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver st7123_driver; extern Driver st7123_touch_driver; -static const Driver* st7123_drivers[] = { +static Driver* const st7123_drivers[] = { &st7123_driver, &st7123_touch_driver, nullptr diff --git a/Drivers/st7701-module/source/module.cpp b/Drivers/st7701-module/source/module.cpp index 87099b5bd..3428bb650 100644 --- a/Drivers/st7701-module/source/module.cpp +++ b/Drivers/st7701-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver st7701_driver; -static const Driver* st7701_drivers[] = { +static Driver* const st7701_drivers[] = { &st7701_driver, nullptr }; diff --git a/Drivers/st7735-module/source/module.cpp b/Drivers/st7735-module/source/module.cpp index 118ee3ba5..a65b0fdb2 100644 --- a/Drivers/st7735-module/source/module.cpp +++ b/Drivers/st7735-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver st7735_driver; -static const Driver* st7735_drivers[] = { +static Driver* const st7735_drivers[] = { &st7735_driver, nullptr }; diff --git a/Drivers/st7789-i8080-module/source/module.cpp b/Drivers/st7789-i8080-module/source/module.cpp index 19bccac96..335451a97 100644 --- a/Drivers/st7789-i8080-module/source/module.cpp +++ b/Drivers/st7789-i8080-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver st7789_i8080_driver; -static const Driver* st7789_i8080_drivers[] = { +static Driver* const st7789_i8080_drivers[] = { &st7789_i8080_driver, nullptr }; diff --git a/Drivers/st7789-module/source/module.cpp b/Drivers/st7789-module/source/module.cpp index df376d492..7d69faefe 100644 --- a/Drivers/st7789-module/source/module.cpp +++ b/Drivers/st7789-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver st7789_driver; -static const Driver* st7789_drivers[] = { +static Driver* const st7789_drivers[] = { &st7789_driver, nullptr }; diff --git a/Drivers/st7796-i8080-module/source/module.cpp b/Drivers/st7796-i8080-module/source/module.cpp index d499b12e6..fec096c55 100644 --- a/Drivers/st7796-i8080-module/source/module.cpp +++ b/Drivers/st7796-i8080-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver st7796_i8080_driver; -static const Driver* st7796_i8080_drivers[] = { +static Driver* const st7796_i8080_drivers[] = { &st7796_i8080_driver, nullptr }; diff --git a/Drivers/st7796-module/source/module.cpp b/Drivers/st7796-module/source/module.cpp index 6968ae020..9322efb9b 100644 --- a/Drivers/st7796-module/source/module.cpp +++ b/Drivers/st7796-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver st7796_driver; -static const Driver* st7796_drivers[] = { +static Driver* const st7796_drivers[] = { &st7796_driver, nullptr }; diff --git a/Drivers/sy6970-module/source/module.cpp b/Drivers/sy6970-module/source/module.cpp index 45767ecf8..770bcc0d4 100644 --- a/Drivers/sy6970-module/source/module.cpp +++ b/Drivers/sy6970-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver sy6970_driver; extern Driver sy6970_power_supply_driver; -static const Driver* sy6970_drivers[] = { +static Driver* const sy6970_drivers[] = { &sy6970_driver, &sy6970_power_supply_driver, nullptr diff --git a/Drivers/tca8418-module/source/module.cpp b/Drivers/tca8418-module/source/module.cpp index 2efa8db00..7ae1c09c4 100644 --- a/Drivers/tca8418-module/source/module.cpp +++ b/Drivers/tca8418-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver tca8418_driver; -static const Driver* tca8418_drivers[] = { +static Driver* const tca8418_drivers[] = { &tca8418_driver, nullptr }; diff --git a/Drivers/tca9534-module/source/module.cpp b/Drivers/tca9534-module/source/module.cpp index 92aee836c..74cf0204b 100644 --- a/Drivers/tca9534-module/source/module.cpp +++ b/Drivers/tca9534-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver tca9534_driver; -static const Driver* tca9534_drivers[] = { +static Driver* const tca9534_drivers[] = { &tca9534_driver, nullptr }; diff --git a/Drivers/tca95xx-16bit-module/source/module.cpp b/Drivers/tca95xx-16bit-module/source/module.cpp index ab8de36f4..5c8d2b0d9 100644 --- a/Drivers/tca95xx-16bit-module/source/module.cpp +++ b/Drivers/tca95xx-16bit-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver tca95xx_driver; -static const Driver* tca95xx_drivers[] = { +static Driver* const tca95xx_drivers[] = { &tca95xx_driver, nullptr }; diff --git a/Drivers/xl9555-module/source/module.cpp b/Drivers/xl9555-module/source/module.cpp index b46726b71..a87b92bfb 100644 --- a/Drivers/xl9555-module/source/module.cpp +++ b/Drivers/xl9555-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver xl9555_driver; -static const Driver* xl9555_drivers[] = { +static Driver* const xl9555_drivers[] = { &xl9555_driver, nullptr }; diff --git a/Drivers/xpt2046-module/source/module.cpp b/Drivers/xpt2046-module/source/module.cpp index f54432903..782d1a581 100644 --- a/Drivers/xpt2046-module/source/module.cpp +++ b/Drivers/xpt2046-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver xpt2046_driver; extern Driver xpt2046_power_supply_driver; -static const Driver* xpt2046_drivers[] = { +static Driver* const xpt2046_drivers[] = { &xpt2046_driver, &xpt2046_power_supply_driver, nullptr diff --git a/Drivers/xpt2046-softspi-module/source/module.cpp b/Drivers/xpt2046-softspi-module/source/module.cpp index 974bf7004..43ac4b845 100644 --- a/Drivers/xpt2046-softspi-module/source/module.cpp +++ b/Drivers/xpt2046-softspi-module/source/module.cpp @@ -7,7 +7,7 @@ extern "C" { extern Driver xpt2046_softspi_driver; extern Driver xpt2046_softspi_power_supply_driver; -static const Driver* xpt2046_softspi_drivers[] = { +static Driver* const xpt2046_softspi_drivers[] = { &xpt2046_softspi_driver, &xpt2046_softspi_power_supply_driver, nullptr diff --git a/Modules/hal-device-module/source/module.cpp b/Modules/hal-device-module/source/module.cpp index df3de8161..4aef46661 100644 --- a/Modules/hal-device-module/source/module.cpp +++ b/Modules/hal-device-module/source/module.cpp @@ -6,7 +6,7 @@ extern "C" { extern Driver hal_device_driver; -static const Driver* hal_device_drivers[] = { +static Driver* const hal_device_drivers[] = { &hal_device_driver, nullptr }; diff --git a/TactilityKernel/include/tactility/module.h b/TactilityKernel/include/tactility/module.h index ede109795..339ae7f53 100644 --- a/TactilityKernel/include/tactility/module.h +++ b/TactilityKernel/include/tactility/module.h @@ -57,7 +57,7 @@ struct Module { * When the module is started, these drivers are constructed and added to the module. * When the module is stopped, these drivers are removed from the module and destroyed. */ - const struct Driver** drivers; + struct Driver* const* drivers; /** * A list of symbols exported by the module. * Should be terminated by MODULE_SYMBOL_TERMINATOR. diff --git a/TactilityKernel/source/module.cpp b/TactilityKernel/source/module.cpp index dc9a0962a..e4ca7a650 100644 --- a/TactilityKernel/source/module.cpp +++ b/TactilityKernel/source/module.cpp @@ -70,7 +70,7 @@ error_t module_start(Module* module) { auto* driver_location = module->drivers; while (*driver_location != nullptr) { auto driver = *driver_location; - driver_construct_add(driver); + check(driver_construct_add(driver) == ERROR_NONE); driver_location++; } } @@ -92,11 +92,12 @@ error_t module_stop(Module* module) { if (!internal->started) return ERROR_NONE; if (module->drivers != nullptr) { - auto* driver_location = module->drivers; - while (*driver_location != nullptr) { - auto driver = *driver_location; - driver_remove_destruct(driver); - driver_location++; + size_t count = 0; + while (module->drivers[count] != nullptr) { + count++; + } + for (size_t i = count; i-- > 0;) { + check(driver_remove_destruct(module->drivers[i]) == ERROR_NONE); } } @@ -105,7 +106,6 @@ error_t module_stop(Module* module) { if (error != ERROR_NONE) { return error; } - } internal->started = false;