50c0a14a93
- Added kernel base drivers for: display, pointer (touch, mouse, etc.), keyboard, adc, power supply and backlight - Implement new kernel driver modules: `st7789-module` and `gt911-module` - Implement ESP32 ADC "oneshot" kernel driver - Implement ESP32 backlight kernel driver with ledc API - Implemented `battery-sense` driver that allows for voltage measurement and creates a power supply child device - Updated github actions - Updated flash scripts - Fix for esp32 legacy driver conflict with ADC - Created separate `lilygo-tdeck` and `lilygo-tdeck-plus` devices - Created `lilygo-module` with LilyGO kernel drivers - Fix for intermittent errors in build related to code generation of `devicetree.c` - `lvgl-module` can now map kernel drivers onto LVGL devices - Created `KernelDisplayApp` as a mirror of `HalDisplayApp` (formerly `DisplayApp`) - Removed `struct` and `enum` prefix in a lot of kernel driver cpp source files - `lilygo-tdeck` and `lilygo-tdeck-plus` are now fully relying on kernel drivers and don't use any of the old HAL
84 lines
2.8 KiB
C++
84 lines
2.8 KiB
C++
#include <tactility/kernel_init.h>
|
|
|
|
#include <tactility/device.h>
|
|
#include <tactility/log.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define TAG "kernel"
|
|
|
|
extern const ModuleSymbol KERNEL_SYMBOLS[];
|
|
|
|
static error_t start() {
|
|
extern Driver root_driver;
|
|
if (driver_construct_add(&root_driver) != ERROR_NONE) return ERROR_RESOURCE;
|
|
extern Driver display_placeholder_driver;
|
|
if (driver_construct_add(&display_placeholder_driver) != ERROR_NONE) return ERROR_RESOURCE;
|
|
extern Driver pointer_placeholder_driver;
|
|
if (driver_construct_add(&pointer_placeholder_driver) != ERROR_NONE) return ERROR_RESOURCE;
|
|
extern Driver spi_peripheral_driver;
|
|
if (driver_construct_add(&spi_peripheral_driver) != ERROR_NONE) return ERROR_RESOURCE;
|
|
extern Driver battery_sense_driver;
|
|
if (driver_construct_add(&battery_sense_driver) != ERROR_NONE) return ERROR_RESOURCE;
|
|
extern Driver battery_sense_power_supply_driver;
|
|
if (driver_construct_add(&battery_sense_power_supply_driver) != ERROR_NONE) return ERROR_RESOURCE;
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
static error_t stop() {
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
Module root_module = {
|
|
.name = "kernel",
|
|
.start = start,
|
|
.stop = stop,
|
|
.symbols = (const struct ModuleSymbol*)KERNEL_SYMBOLS,
|
|
.internal = nullptr
|
|
};
|
|
|
|
error_t kernel_init(Module* dts_modules[], DtsDevice dts_devices[]) {
|
|
LOG_I(TAG, "init");
|
|
|
|
if (module_construct_add_start(&root_module) != ERROR_NONE) {
|
|
LOG_E(TAG, "root module init failed");
|
|
return ERROR_RESOURCE;
|
|
}
|
|
|
|
Module** dts_module = dts_modules;
|
|
while (*dts_module != nullptr) {
|
|
if (module_construct_add_start(*dts_module) != ERROR_NONE) {
|
|
LOG_E(TAG, "dts module init failed: %s", (*dts_module)->name);
|
|
return ERROR_RESOURCE;
|
|
}
|
|
dts_module++;
|
|
}
|
|
|
|
DtsDevice* dts_device = dts_devices;
|
|
while (dts_device->device != nullptr) {
|
|
if (dts_device->status == DTS_DEVICE_STATUS_OKAY) {
|
|
if (device_construct_add_start(dts_device->device, dts_device->compatible) != ERROR_NONE) {
|
|
LOG_E(TAG, "kernel_init failed to construct+add+start device: %s (%s)", dts_device->device->name, dts_device->compatible);
|
|
return ERROR_RESOURCE;
|
|
}
|
|
} else if (dts_device->status == DTS_DEVICE_STATUS_DISABLED) {
|
|
if (device_construct_add(dts_device->device, dts_device->compatible) != ERROR_NONE) {
|
|
LOG_E(TAG, "kernel_init failed to construct+add device: %s (%s)", dts_device->device->name, dts_device->compatible);
|
|
return ERROR_RESOURCE;
|
|
}
|
|
} else {
|
|
check(false, "DTS status not implemented");
|
|
}
|
|
dts_device++;
|
|
}
|
|
|
|
LOG_I(TAG, "init done");
|
|
return ERROR_NONE;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|