New kernel drivers and device implementation updates#561
Conversation
- add cst816s kernel driver - add ili9341 kernel driver
📝 WalkthroughWalkthroughThe change migrates several devices from legacy board-specific HAL implementations to device-tree-configured kernel modules. It adds display, touch, keyboard, and button drivers with bindings, lifecycle modules, and public configuration structures. Device trees now describe concrete peripherals, while device dependencies and CMake registration use modular targets. Firmware gains deprecated-HAL configuration handling, and LVGL plus SPI paths are updated for partial buffering, RGB565 byte swapping, and MISO pull-ups. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (2)
Devices/m5stack-stickc-plus2/source/module.cpp (1)
10-26: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueConsider checking GPIO return values or simplifying
init_power().
init_power()returnsboolbut always returnstrueregardless of whether thegpio_set_direction/gpio_set_levelcalls succeed. Additionally,start()ignores the return value entirely. Either check the ESP-IDF error codes and propagate failures, or simplifyinit_power()to returnvoidto avoid misleading callers.♻️ Optional refactor: propagate GPIO errors
static bool 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); - gpio_set_level(GPIO_NUM_0, 1); + if (gpio_set_direction(GPIO_NUM_0, GPIO_MODE_OUTPUT) != ESP_OK) return false; + if (gpio_set_level(GPIO_NUM_0, 1) != ESP_OK) return false; // "Hold power" pin: must be set to high to keep the device powered on: - gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT); - gpio_set_level(GPIO_NUM_4, 1); + if (gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT) != ESP_OK) return false; + if (gpio_set_level(GPIO_NUM_4, 1) != ESP_OK) return false; return true; } static error_t start() { - init_power(); - return ERROR_NONE; + return init_power() ? ERROR_NONE : ERROR_FAILURE; }Drivers/m5stack-module/source/module.cpp (1)
19-25: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winConsider reverse-order teardown in
stop().
start()constructscardputer_keyboard_driverfirst, thencardputer_adv_keyboard_driver.stop()removes them in the same order. If the advanced keyboard driver depends on the base keyboard driver being alive, removing the base first could cause issues. LIFO (reverse) order is the safer convention for resource teardown.♻️ Proposed reverse-order teardown
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); + check(driver_remove_destruct(&cardputer_keyboard_driver) == ERROR_NONE); return ERROR_NONE; }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0c82dfa6-ac87-4a62-a155-29f343e7efee
📒 Files selected for processing (119)
Devices/cyd-2432s024c/CMakeLists.txtDevices/cyd-2432s024c/Source/Configuration.cppDevices/cyd-2432s024c/Source/devices/Display.cppDevices/cyd-2432s024c/Source/devices/Display.hDevices/cyd-2432s024c/Source/module.cppDevices/cyd-2432s024c/cyd,2432s024c.dtsDevices/cyd-2432s024c/device.propertiesDevices/cyd-2432s024c/devicetree.yamlDevices/cyd-2432s024c/source/module.cppDevices/elecrow-crowpanel-advance-35/CMakeLists.txtDevices/elecrow-crowpanel-advance-35/Source/Configuration.cppDevices/elecrow-crowpanel-advance-35/Source/devices/Display.cppDevices/elecrow-crowpanel-advance-35/Source/devices/Display.hDevices/elecrow-crowpanel-advance-35/device.propertiesDevices/elecrow-crowpanel-advance-35/devicetree.yamlDevices/elecrow-crowpanel-advance-35/elecrow,crowpanel-advance-35.dtsDevices/elecrow-crowpanel-advance-35/source/module.cppDevices/m5stack-cardputer-adv/CMakeLists.txtDevices/m5stack-cardputer-adv/Source/Configuration.cppDevices/m5stack-cardputer-adv/Source/devices/CardputerKeyboard.cppDevices/m5stack-cardputer-adv/Source/devices/CardputerKeyboard.hDevices/m5stack-cardputer-adv/Source/devices/CardputerPower.cppDevices/m5stack-cardputer-adv/Source/devices/CardputerPower.hDevices/m5stack-cardputer-adv/Source/devices/Display.cppDevices/m5stack-cardputer-adv/Source/devices/Display.hDevices/m5stack-cardputer-adv/device.propertiesDevices/m5stack-cardputer-adv/devicetree.yamlDevices/m5stack-cardputer-adv/m5stack,cardputer-adv.dtsDevices/m5stack-cardputer-adv/source/module.cppDevices/m5stack-cardputer/CMakeLists.txtDevices/m5stack-cardputer/Source/Configuration.cppDevices/m5stack-cardputer/Source/devices/CardputerEncoder.cppDevices/m5stack-cardputer/Source/devices/CardputerEncoder.hDevices/m5stack-cardputer/Source/devices/CardputerKeyboard.cppDevices/m5stack-cardputer/Source/devices/CardputerKeyboard.hDevices/m5stack-cardputer/Source/devices/CardputerPower.cppDevices/m5stack-cardputer/Source/devices/CardputerPower.hDevices/m5stack-cardputer/Source/devices/Display.cppDevices/m5stack-cardputer/Source/devices/Display.hDevices/m5stack-cardputer/Source/keyboard/README.mdDevices/m5stack-cardputer/Source/keyboard/keyboard.cppDevices/m5stack-cardputer/Source/keyboard/keyboard.hDevices/m5stack-cardputer/Source/keyboard/keymap.hDevices/m5stack-cardputer/device.propertiesDevices/m5stack-cardputer/devicetree.yamlDevices/m5stack-cardputer/m5stack,cardputer.dtsDevices/m5stack-cardputer/source/module.cppDevices/m5stack-stickc-plus2/CMakeLists.txtDevices/m5stack-stickc-plus2/Source/Configuration.cppDevices/m5stack-stickc-plus2/Source/devices/Display.cppDevices/m5stack-stickc-plus2/Source/devices/Display.hDevices/m5stack-stickc-plus2/Source/module.cppDevices/m5stack-stickc-plus2/device.propertiesDevices/m5stack-stickc-plus2/devicetree.yamlDevices/m5stack-stickc-plus2/m5stack,stickc-plus2.dtsDevices/m5stack-stickc-plus2/source/module.cppDocumentation/ideas.mdDrivers/ButtonControl/Source/ButtonControl.hDrivers/button-control-module/CMakeLists.txtDrivers/button-control-module/LICENSE-Apache-2.0.mdDrivers/button-control-module/README.mdDrivers/button-control-module/bindings/tactility,button-control.yamlDrivers/button-control-module/devicetree.yamlDrivers/button-control-module/include/bindings/button_control.hDrivers/button-control-module/include/button_control_module.hDrivers/button-control-module/include/drivers/button_control.hDrivers/button-control-module/source/button_control.cppDrivers/button-control-module/source/module.cppDrivers/cst816s-module/CMakeLists.txtDrivers/cst816s-module/bindings/hynitron,cst816s.yamlDrivers/cst816s-module/devicetree.yamlDrivers/cst816s-module/include/bindings/cst816s.hDrivers/cst816s-module/include/cst816s_module.hDrivers/cst816s-module/include/drivers/cst816s.hDrivers/cst816s-module/source/cst816s.cppDrivers/cst816s-module/source/module.cppDrivers/gt911-module/LICENSE-Apache-2.0.mdDrivers/ili9341-module/CMakeLists.txtDrivers/ili9341-module/LICENSE-Apache-2.0.mdDrivers/ili9341-module/bindings/ilitek,ili9341.yamlDrivers/ili9341-module/devicetree.yamlDrivers/ili9341-module/include/bindings/ili9341.hDrivers/ili9341-module/include/drivers/ili9341.hDrivers/ili9341-module/include/ili9341_module.hDrivers/ili9341-module/source/ili9341.cppDrivers/ili9341-module/source/module.cppDrivers/ili9488-module/CMakeLists.txtDrivers/ili9488-module/LICENSE-Apache-2.0.mdDrivers/ili9488-module/bindings/ilitek,ili9488.yamlDrivers/ili9488-module/devicetree.yamlDrivers/ili9488-module/include/bindings/ili9488.hDrivers/ili9488-module/include/drivers/ili9488.hDrivers/ili9488-module/include/ili9488_module.hDrivers/ili9488-module/source/ili9488.cppDrivers/ili9488-module/source/module.cppDrivers/ina226-module/LICENSE-Apache-2.0.mdDrivers/lilygo-module/LICENSE-Apache-2.0.mdDrivers/m5stack-module/CMakeLists.txtDrivers/m5stack-module/LICENSE-Apache-2.0.mdDrivers/m5stack-module/bindings/m5stack,cardputer-adv-keyboard.yamlDrivers/m5stack-module/bindings/m5stack,cardputer-keyboard.yamlDrivers/m5stack-module/devicetree.yamlDrivers/m5stack-module/include/bindings/cardputer_adv_keyboard.hDrivers/m5stack-module/include/bindings/cardputer_keyboard.hDrivers/m5stack-module/include/drivers/cardputer_adv_keyboard.hDrivers/m5stack-module/include/drivers/cardputer_keyboard.hDrivers/m5stack-module/include/m5stack_module.hDrivers/m5stack-module/source/cardputer_adv_keyboard.cppDrivers/m5stack-module/source/cardputer_keyboard.cppDrivers/m5stack-module/source/module.cppDrivers/py32ioexpander-module/LICENSE-Apache-2.0.mdDrivers/st7789-module/LICENSE-Apache-2.0.mdDrivers/st7789-module/source/st7789.cppFirmware/KconfigFirmware/Source/Main.cppModules/lvgl-module/source/lvgl_devices.cModules/lvgl-module/source/lvgl_display.cPlatforms/platform-esp32/source/drivers/esp32_spi.cppdevice.py
💤 Files with no reviewable changes (32)
- Devices/elecrow-crowpanel-advance-35/Source/Configuration.cpp
- Devices/m5stack-cardputer-adv/Source/devices/Display.cpp
- Devices/m5stack-cardputer/Source/devices/Display.h
- Devices/m5stack-cardputer/Source/Configuration.cpp
- Devices/elecrow-crowpanel-advance-35/Source/devices/Display.cpp
- Devices/m5stack-cardputer/Source/devices/CardputerEncoder.h
- Devices/m5stack-cardputer/Source/devices/CardputerKeyboard.h
- Devices/m5stack-cardputer/Source/keyboard/README.md
- Devices/m5stack-cardputer-adv/Source/devices/Display.h
- Devices/m5stack-cardputer/Source/devices/Display.cpp
- Devices/m5stack-stickc-plus2/Source/module.cpp
- Devices/cyd-2432s024c/Source/Configuration.cpp
- Devices/m5stack-cardputer-adv/Source/Configuration.cpp
- Devices/m5stack-cardputer-adv/Source/devices/CardputerPower.h
- Devices/m5stack-stickc-plus2/Source/Configuration.cpp
- Devices/m5stack-cardputer-adv/Source/devices/CardputerKeyboard.h
- Devices/m5stack-stickc-plus2/Source/devices/Display.cpp
- Devices/m5stack-cardputer/Source/devices/CardputerEncoder.cpp
- Drivers/ButtonControl/Source/ButtonControl.h
- Devices/cyd-2432s024c/Source/devices/Display.cpp
- Devices/m5stack-cardputer/Source/devices/CardputerPower.cpp
- Devices/cyd-2432s024c/Source/module.cpp
- Devices/m5stack-cardputer/Source/devices/CardputerKeyboard.cpp
- Devices/m5stack-cardputer/Source/keyboard/keyboard.cpp
- Devices/m5stack-cardputer/Source/keyboard/keymap.h
- Devices/m5stack-stickc-plus2/Source/devices/Display.h
- Devices/cyd-2432s024c/Source/devices/Display.h
- Devices/m5stack-cardputer-adv/Source/devices/CardputerPower.cpp
- Devices/m5stack-cardputer-adv/Source/devices/CardputerKeyboard.cpp
- Devices/elecrow-crowpanel-advance-35/Source/devices/Display.h
- Devices/m5stack-cardputer/Source/keyboard/keyboard.h
- Devices/m5stack-cardputer/Source/devices/CardputerPower.h
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
TactilityKernel/include/tactility/device_listener.h (1)
20-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
DeviceEventListenerand callback parameter design leak implementation details.Two API design observations:
DeviceEventListener(lines 20–23) is defined in the public header but never appears in any public function signature —add/removetake rawDeviceListenerCallback*andvoid*. This struct is pure internal storage and should live indevice_listener_internal.hor the.cppfile.
DeviceListenerCallback*(pointer-to-function-pointer) forces callers to write&my_funcand the implementation to dereference. PassingDeviceListenerCallbackby value is simpler for callers and equivalent in cost.♻️ Proposed refactor
// device_listener.h — remove the struct, simplify signatures -struct DeviceEventListener { - DeviceListenerCallback callback; - void* callback_context; -}; - -void device_listener_add(DeviceListenerCallback* callback, void* context); -void device_listener_remove(DeviceListenerCallback* callback); +void device_listener_add(DeviceListenerCallback callback, void* context); +void device_listener_remove(DeviceListenerCallback callback);// device_listener_internal.h — move struct here +struct DeviceEventListener { + DeviceListenerCallback callback; + void* callback_context; +}; + void device_listener_notify(struct Device* dev, enum DeviceEvent event);// device_listener.cpp — update implementation void device_listener_add(DeviceListenerCallback callback, void* context) { ledger.lock(); - ledger.listeners.push_back(DeviceEventListener{ *callback, context }); + ledger.listeners.push_back(DeviceEventListener{ callback, context }); ledger.unlock(); } void device_listener_remove(DeviceListenerCallback callback) { ledger.lock(); const auto iterator = std::ranges::find_if(ledger.listeners, [callback](const DeviceEventListener& listener) { - return listener.callback == *callback; + return listener.callback == callback; });Tests/TactilityKernel/Source/DeviceGetPutTest.cpp (1)
102-104: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winBusy-wait can hang the test suite instead of failing cleanly.
If the worker's
device_get(&device)returns non-ERROR_NONE, it returns1without ever settingacquired, so this loop spins forever and the CI run hangs rather than reporting a failed assertion. Consider bounding the wait (e.g. spin with an iteration/time cap, thenCHECKthe worker actually acquired) so a regression surfaces as a test failure.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 79486dbe-fc7f-4ca3-8262-4ee9ec38abd4
📒 Files selected for processing (15)
Drivers/button-control-module/source/button_control.cppDrivers/ili9341-module/source/ili9341.cppDrivers/m5stack-module/source/cardputer_adv_keyboard.cppDrivers/m5stack-module/source/cardputer_keyboard.cppModules/lvgl-module/source/lvgl_devices.cTactilityKernel/CMakeLists.txtTactilityKernel/include/tactility/device.hTactilityKernel/include/tactility/device_listener.hTactilityKernel/include/tactility/error.hTactilityKernel/private/tactility/device_listener_internal.hTactilityKernel/source/device.cppTactilityKernel/source/device_listener.cppTactilityKernel/source/error.cppTests/TactilityKernel/Source/DeviceGetPutTest.cppTests/TactilityKernel/Source/DeviceTest.cpp
🚧 Files skipped from review as they are similar to previous changes (5)
- Drivers/m5stack-module/source/cardputer_keyboard.cpp
- Modules/lvgl-module/source/lvgl_devices.c
- Drivers/button-control-module/source/button_control.cpp
- Drivers/ili9341-module/source/ili9341.cpp
- Drivers/m5stack-module/source/cardputer_adv_keyboard.cpp
Uh oh!
There was an error while loading. Please reload this page.