Move driver listing to Module definition

This commit is contained in:
Ken Van Hoeylandt 2026-08-18 21:47:48 +02:00
parent b03759a111
commit 9299df004f
3 changed files with 41 additions and 116 deletions

View File

@ -46,14 +46,11 @@
## Medium Priority ## Medium Priority
- `platform-esp32`'s module drivers are declared in start/stop of the module but they should be set via `Module::drivers`
- `struct Driver` has an `.owner`, but it's not always set. Either validate on Module construct that it matches, or otherwise set it during module start. The problem: NULL parent currently means that driver is not removable. This clashes with setting it dynamically. Consider some kind of flag to determine removability. - `struct Driver` has an `.owner`, but it's not always set. Either validate on Module construct that it matches, or otherwise set it during module start. The problem: NULL parent currently means that driver is not removable. This clashes with setting it dynamically. Consider some kind of flag to determine removability.
- Consider moving certain drivers into separate modules: audio, bt, wifi, etc - Consider moving certain drivers into separate modules: audio, bt, wifi, etc
- Consider using https://github.com/Graphify-Labs/graphify - Consider using https://github.com/Graphify-Labs/graphify
- Consider implementing LVGL gridnav in apps https://lvgl.io/docs/open/9.3/details/auxiliary-modules/gridnav.html - Consider implementing LVGL gridnav in apps https://lvgl.io/docs/open/9.3/details/auxiliary-modules/gridnav.html
- Make USB host driver disabled by default, so it doesn't consume memory - Make USB host driver disabled by default, so it doesn't consume memory
- Filtering for apps in App Hub:
- apps that only work on a specific device
- Diceware app has large "+" and "-' buttons on Cardputer. It should be smaller. - Diceware app has large "+" and "-' buttons on Cardputer. It should be smaller.
- TactilityTool: Make API compatibility table (and check for compatibility in the tool itself) - TactilityTool: Make API compatibility table (and check for compatibility in the tool itself)
- Improve EspLcdDisplay to contain all the standard configuration options, and implement a default init function. Add a configuration class. - Improve EspLcdDisplay to contain all the standard configuration options, and implement a default init function. Add a configuration class.

View File

@ -2,9 +2,6 @@
#include <sdkconfig.h> #include <sdkconfig.h>
#endif #endif
#include <tactility/check.h>
#include <tactility/device.h>
#include <tactility/driver.h>
#include <tactility/module.h> #include <tactility/module.h>
#include <soc/soc_caps.h> #include <soc/soc_caps.h>
@ -60,122 +57,61 @@ extern Driver esp32_usb_midi_device_driver;
extern Driver esp32_usb_cdc_device_driver; extern Driver esp32_usb_cdc_device_driver;
#endif #endif
static error_t start() { static Driver* const platform_esp32_drivers[] = {
/* We crash when construct fails, because if a single driver fails to construct, &esp32_adc_oneshot_driver,
* there is no guarantee that the previously constructed drivers can be destroyed */ &esp32_gpio_driver,
check(driver_construct_add(&esp32_adc_oneshot_driver) == ERROR_NONE); &esp32_i2c_driver,
check(driver_construct_add(&esp32_gpio_driver) == ERROR_NONE); &esp32_i2c_master_driver,
check(driver_construct_add(&esp32_i2c_driver) == ERROR_NONE); &esp32_i2s_driver,
check(driver_construct_add(&esp32_i2c_master_driver) == ERROR_NONE);
check(driver_construct_add(&esp32_i2s_driver) == ERROR_NONE);
#if SOC_LCD_I80_SUPPORTED #if SOC_LCD_I80_SUPPORTED
check(driver_construct_add(&esp32_i8080_driver) == ERROR_NONE); &esp32_i8080_driver,
#endif #endif
check(driver_construct_add(&esp32_pwm_ledc_driver) == ERROR_NONE); &esp32_pwm_ledc_driver,
#if SOC_SDMMC_HOST_SUPPORTED #if SOC_SDMMC_HOST_SUPPORTED
check(driver_construct_add(&esp32_sdmmc_driver) == ERROR_NONE); &esp32_sdmmc_driver,
#endif #endif
check(driver_construct_add(&esp32_sdspi_driver) == ERROR_NONE); &esp32_sdspi_driver,
check(driver_construct_add(&esp32_spi_driver) == ERROR_NONE); &esp32_spi_driver,
check(driver_construct_add(&esp32_uart_driver) == ERROR_NONE); &esp32_uart_driver,
check(driver_construct_add(&esp32_grove_driver) == ERROR_NONE); &esp32_grove_driver,
#if defined(CONFIG_SOC_WIFI_SUPPORTED) || defined(CONFIG_SLAVE_SOC_WIFI_SUPPORTED) #if defined(CONFIG_SOC_WIFI_SUPPORTED) || defined(CONFIG_SLAVE_SOC_WIFI_SUPPORTED)
check(driver_construct_add(&esp32_wifi_driver) == ERROR_NONE); &esp32_wifi_driver,
check(driver_construct_add(&esp32_wifi_pinned_driver) == ERROR_NONE); &esp32_wifi_pinned_driver,
#endif #endif
#if defined(CONFIG_BT_NIMBLE_ENABLED) #if defined(CONFIG_BT_NIMBLE_ENABLED)
check(driver_construct_add(&esp32_bluetooth_driver) == ERROR_NONE); &esp32_bluetooth_driver,
check(driver_construct_add(&esp32_ble_serial_driver) == ERROR_NONE); &esp32_ble_serial_driver,
check(driver_construct_add(&esp32_ble_midi_driver) == ERROR_NONE); &esp32_ble_midi_driver,
check(driver_construct_add(&esp32_ble_hid_device_driver) == ERROR_NONE); &esp32_ble_hid_device_driver,
#endif #endif
#if SOC_USB_OTG_SUPPORTED #if SOC_USB_OTG_SUPPORTED
check(driver_construct_add(&esp32_usbhost_driver) == ERROR_NONE); &esp32_usbhost_driver,
check(driver_construct_add(&esp32_usbhost_hid_driver) == ERROR_NONE); &esp32_usbhost_hid_driver,
check(driver_construct_add(&esp32_usbhost_hid_keyboard_driver) == ERROR_NONE); &esp32_usbhost_hid_keyboard_driver,
check(driver_construct_add(&esp32_usbhost_midi_driver) == ERROR_NONE); &esp32_usbhost_midi_driver,
check(driver_construct_add(&esp32_usbhost_msc_driver) == ERROR_NONE); &esp32_usbhost_msc_driver,
#endif
// usbdevice0 and its children (usbdevicehid0, usbdevicemsc0, ...) are declared per-board in
// .dts, same pattern as usbhost0 above - the devicetree compiler constructs/adds/starts their
// Device instances and wires parent/child relationships. Only driver registration happens
// here.
#if SOC_USB_OTG_SUPPORTED && (CONFIG_TINYUSB_HID_COUNT || CONFIG_TINYUSB_MSC_ENABLED || CONFIG_TINYUSB_MIDI_COUNT || CONFIG_TINYUSB_CDC_ENABLED)
check(driver_construct_add(&esp32_usb_device_controller_driver) == ERROR_NONE);
#endif
#if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_HID_COUNT
check(driver_construct_add(&esp32_usb_hid_device_driver) == ERROR_NONE);
#endif
#if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_MSC_ENABLED
check(driver_construct_add(&esp32_usb_msc_device_driver) == ERROR_NONE);
#endif
#if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_MIDI_COUNT
check(driver_construct_add(&esp32_usb_midi_device_driver) == ERROR_NONE);
#endif
#if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_CDC_ENABLED
check(driver_construct_add(&esp32_usb_cdc_device_driver) == ERROR_NONE);
#endif
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 */
#if defined(CONFIG_SOC_WIFI_SUPPORTED) || defined(CONFIG_SLAVE_SOC_WIFI_SUPPORTED)
check(driver_remove_destruct(&esp32_wifi_pinned_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_wifi_driver) == ERROR_NONE);
#endif
#if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_CDC_ENABLED
check(driver_remove_destruct(&esp32_usb_cdc_device_driver) == ERROR_NONE);
#endif
#if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_MIDI_COUNT
check(driver_remove_destruct(&esp32_usb_midi_device_driver) == ERROR_NONE);
#endif
#if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_MSC_ENABLED
check(driver_remove_destruct(&esp32_usb_msc_device_driver) == ERROR_NONE);
#endif
#if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_HID_COUNT
check(driver_remove_destruct(&esp32_usb_hid_device_driver) == ERROR_NONE);
#endif #endif
#if SOC_USB_OTG_SUPPORTED && (CONFIG_TINYUSB_HID_COUNT || CONFIG_TINYUSB_MSC_ENABLED || CONFIG_TINYUSB_MIDI_COUNT || CONFIG_TINYUSB_CDC_ENABLED) #if SOC_USB_OTG_SUPPORTED && (CONFIG_TINYUSB_HID_COUNT || CONFIG_TINYUSB_MSC_ENABLED || CONFIG_TINYUSB_MIDI_COUNT || CONFIG_TINYUSB_CDC_ENABLED)
check(driver_remove_destruct(&esp32_usb_device_controller_driver) == ERROR_NONE); &esp32_usb_device_controller_driver,
#endif #endif
#if SOC_USB_OTG_SUPPORTED #if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_HID_COUNT
check(driver_remove_destruct(&esp32_usbhost_msc_driver) == ERROR_NONE); &esp32_usb_hid_device_driver,
check(driver_remove_destruct(&esp32_usbhost_midi_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_usbhost_hid_keyboard_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_usbhost_hid_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_usbhost_driver) == ERROR_NONE);
#endif #endif
#if defined(CONFIG_BT_NIMBLE_ENABLED) #if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_MSC_ENABLED
check(driver_remove_destruct(&esp32_ble_hid_device_driver) == ERROR_NONE); &esp32_usb_msc_device_driver,
check(driver_remove_destruct(&esp32_ble_midi_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_ble_serial_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_bluetooth_driver) == ERROR_NONE);
#endif #endif
check(driver_remove_destruct(&esp32_adc_oneshot_driver) == ERROR_NONE); #if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_MIDI_COUNT
check(driver_remove_destruct(&esp32_gpio_driver) == ERROR_NONE); &esp32_usb_midi_device_driver,
check(driver_remove_destruct(&esp32_i2c_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_i2c_master_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_i2s_driver) == ERROR_NONE);
#if SOC_LCD_I80_SUPPORTED
check(driver_remove_destruct(&esp32_i8080_driver) == ERROR_NONE);
#endif #endif
check(driver_remove_destruct(&esp32_pwm_ledc_driver) == ERROR_NONE); #if SOC_USB_OTG_SUPPORTED && CONFIG_TINYUSB_CDC_ENABLED
#if SOC_SDMMC_HOST_SUPPORTED &esp32_usb_cdc_device_driver,
check(driver_remove_destruct(&esp32_sdmmc_driver) == ERROR_NONE);
#endif #endif
check(driver_remove_destruct(&esp32_sdspi_driver) == ERROR_NONE); nullptr
check(driver_remove_destruct(&esp32_spi_driver) == ERROR_NONE); };
check(driver_remove_destruct(&esp32_uart_driver) == ERROR_NONE);
check(driver_remove_destruct(&esp32_grove_driver) == ERROR_NONE);
return ERROR_NONE;
}
Module platform_esp32_module = { Module platform_esp32_module = {
.name = "platform-esp32", .name = "platform-esp32",
.start = start, .drivers = platform_esp32_drivers,
.stop = stop,
.symbols = nullptr, .symbols = nullptr,
.internal = nullptr .internal = nullptr
}; };

View File

@ -1,26 +1,18 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#include <tactility/check.h>
#include <tactility/driver.h>
#include <tactility/module.h> #include <tactility/module.h>
extern "C" { extern "C" {
extern Driver posix_wifi_driver; extern Driver posix_wifi_driver;
static error_t start() { static Driver* const platform_posix_drivers[] = {
check(driver_construct_add(&posix_wifi_driver) == ERROR_NONE); &posix_wifi_driver,
return ERROR_NONE; nullptr
} };
static error_t stop() {
check(driver_remove_destruct(&posix_wifi_driver) == ERROR_NONE);
return ERROR_NONE;
}
struct Module platform_posix_module = { struct Module platform_posix_module = {
.name = "platform-posix", .name = "platform-posix",
.start = start, .drivers = platform_posix_drivers,
.stop = stop,
.symbols = nullptr, .symbols = nullptr,
.internal = nullptr .internal = nullptr
}; };