diff --git a/Devices/lilygo-tlora-pager/Source/drivers/TloraPager.cpp b/Devices/lilygo-tlora-pager/Source/drivers/TloraPager.cpp index a333957a..741750ae 100644 --- a/Devices/lilygo-tlora-pager/Source/drivers/TloraPager.cpp +++ b/Devices/lilygo-tlora-pager/Source/drivers/TloraPager.cpp @@ -19,10 +19,10 @@ static int stop(Device* device) { Driver tlora_pager_driver = { .name = "T-Lora Pager", .compatible = (const char*[]) { "lilygo,tlora-pager", nullptr }, - .startDevice = start, - .stopDevice = stop, + .start_device = start, + .stop_device = stop, .api = nullptr, - .deviceType = nullptr, + .device_type = nullptr, .owner = &device_module, .driver_private = nullptr }; diff --git a/Devices/simulator/Source/Main.cpp b/Devices/simulator/Source/Main.cpp index 55f4565c..94481c1a 100644 --- a/Devices/simulator/Source/Main.cpp +++ b/Devices/simulator/Source/Main.cpp @@ -40,21 +40,3 @@ void freertosMain() { } } // namespace - -/** - * Assert implementation as defined in the FreeRTOSConfig.h - * It allows you to set breakpoints and debug asserts. - */ -void vAssertCalled(unsigned long line, const char* const file) { - volatile uint32_t set_to_nonzero_in_debugger_to_continue = 0; - LOGGER.error("Assert triggered at {}:{}", file, line); - taskENTER_CRITICAL(); - { - // Step out by attaching a debugger and setting set_to_nonzero_in_debugger_to_continue - while (set_to_nonzero_in_debugger_to_continue == 0) { - // NO-OP - } - } - taskEXIT_CRITICAL(); -} - diff --git a/Modules/hal-device-module/Source/drivers/hal_device.cpp b/Modules/hal-device-module/Source/drivers/hal_device.cpp index 7b37198f..d20e6256 100644 --- a/Modules/hal-device-module/Source/drivers/hal_device.cpp +++ b/Modules/hal-device-module/Source/drivers/hal_device.cpp @@ -115,10 +115,10 @@ extern struct Module hal_device_module; Driver hal_device_driver = { .name = "hal-device", .compatible = (const char*[]) {"hal-device", nullptr}, - .startDevice = start, - .stopDevice = stop, + .start_device = start, + .stop_device = stop, .api = nullptr, - .deviceType = &HAL_DEVICE_TYPE, + .device_type = &HAL_DEVICE_TYPE, .owner = &hal_device_module, .driver_private = nullptr }; diff --git a/Platforms/PlatformEsp32/Source/drivers/esp32_gpio.cpp b/Platforms/PlatformEsp32/Source/drivers/esp32_gpio.cpp index 3e3c1dd1..a71d0631 100644 --- a/Platforms/PlatformEsp32/Source/drivers/esp32_gpio.cpp +++ b/Platforms/PlatformEsp32/Source/drivers/esp32_gpio.cpp @@ -118,10 +118,10 @@ extern struct Module platform_module; Driver esp32_gpio_driver = { .name = "esp32_gpio", .compatible = (const char*[]) { "espressif,esp32-gpio", nullptr }, - .startDevice = start, - .stopDevice = stop, + .start_device = start, + .stop_device = stop, .api = (void*)&esp32_gpio_api, - .deviceType = &GPIO_CONTROLLER_TYPE, + .device_type = &GPIO_CONTROLLER_TYPE, .owner = &platform_module, .driver_private = nullptr }; diff --git a/Platforms/PlatformEsp32/Source/drivers/esp32_i2c.cpp b/Platforms/PlatformEsp32/Source/drivers/esp32_i2c.cpp index 309aec82..969b382e 100644 --- a/Platforms/PlatformEsp32/Source/drivers/esp32_i2c.cpp +++ b/Platforms/PlatformEsp32/Source/drivers/esp32_i2c.cpp @@ -211,10 +211,10 @@ extern struct Module platform_module; Driver esp32_i2c_driver = { .name = "esp32_i2c", .compatible = (const char*[]) { "espressif,esp32-i2c", nullptr }, - .startDevice = start, - .stopDevice = stop, + .start_device = start, + .stop_device = stop, .api = (void*)&esp32_i2c_api, - .deviceType = &I2C_CONTROLLER_TYPE, + .device_type = &I2C_CONTROLLER_TYPE, .owner = &platform_module, .driver_private = nullptr }; diff --git a/Platforms/PlatformPosix/Source/freertos.c b/Platforms/PlatformPosix/Source/freertos.c new file mode 100644 index 00000000..8a6775c7 --- /dev/null +++ b/Platforms/PlatformPosix/Source/freertos.c @@ -0,0 +1,13 @@ +#include +#include +#include + +#define TAG LOG_TAG(freertos) + +/** + * Assert implementation as defined in the FreeRTOSConfig.h + */ +void vAssertCalled(unsigned long line, const char* const file) { + LOG_E("Assert triggered at {}:{}", file, line); + __assert_fail("assert failed", file, line, ""); +} diff --git a/TactilityKernel/Include/tactility/device.h b/TactilityKernel/Include/tactility/device.h index e1be7d12..bec85efc 100644 --- a/TactilityKernel/Include/tactility/device.h +++ b/TactilityKernel/Include/tactility/device.h @@ -181,7 +181,7 @@ static inline void device_unlock(struct Device* device) { } static inline const struct DeviceType* device_get_type(struct Device* device) { - return device->internal.driver ? device->internal.driver->deviceType : NULL; + return device->internal.driver ? device->internal.driver->device_type : NULL; } /** * Iterate through all the known devices diff --git a/TactilityKernel/Include/tactility/driver.h b/TactilityKernel/Include/tactility/driver.h index 478252d5..0311fbfd 100644 --- a/TactilityKernel/Include/tactility/driver.h +++ b/TactilityKernel/Include/tactility/driver.h @@ -20,13 +20,13 @@ struct Driver { /** Array of const char*, terminated by NULL */ const char**compatible; /** Function to initialize the driver for a device */ - error_t (*startDevice)(struct Device* dev); + error_t (*start_device)(struct Device* dev); /** Function to deinitialize the driver for a device */ - error_t (*stopDevice)(struct Device* dev); + error_t (*stop_device)(struct Device* dev); /** Contains the driver's functions */ const void* api; /** Which type of devices this driver creates (can be NULL) */ - const struct DeviceType* deviceType; + const struct DeviceType* device_type; /** The module that owns this driver. When it is NULL, the system owns the driver and it cannot be removed from registration. */ const struct Module* owner; /** Internal data */ @@ -54,7 +54,7 @@ bool driver_is_compatible(struct Driver* driver, const char* compatible); struct Driver* driver_find_compatible(const char* compatible); static inline const struct DeviceType* driver_get_device_type(struct Driver* driver) { - return driver->deviceType; + return driver->device_type; } #ifdef __cplusplus diff --git a/TactilityKernel/Source/device.cpp b/TactilityKernel/Source/device.cpp index 8a02d4a1..2e5452dd 100644 --- a/TactilityKernel/Source/device.cpp +++ b/TactilityKernel/Source/device.cpp @@ -264,7 +264,7 @@ void for_each_device_of_type(const DeviceType* type, void* callbackContext, bool for (auto* device : ledger.devices) { auto* driver = device->internal.driver; if (driver != nullptr) { - if (driver->deviceType == type) { + if (driver->device_type == type) { if (!on_device(device, callbackContext)) { break; } diff --git a/TactilityKernel/Source/driver.cpp b/TactilityKernel/Source/driver.cpp index 0bba7299..bd93f7a7 100644 --- a/TactilityKernel/Source/driver.cpp +++ b/TactilityKernel/Source/driver.cpp @@ -159,8 +159,8 @@ error_t driver_bind(Driver* driver, Device* device) { goto error; } - if (driver->startDevice != nullptr) { - error = driver->startDevice(device); + if (driver->start_device != nullptr) { + error = driver->start_device(device); if (error != ERROR_NONE) { goto error; } @@ -187,8 +187,8 @@ error_t driver_unbind(Driver* driver, Device* device) { goto error; } - if (driver->stopDevice != nullptr) { - error = driver->stopDevice(device); + if (driver->stop_device != nullptr) { + error = driver->stop_device(device); if (error != ERROR_NONE) { goto error; } diff --git a/TactilityKernel/Source/drivers/root.cpp b/TactilityKernel/Source/drivers/root.cpp index 524a37f9..f52ffdd2 100644 --- a/TactilityKernel/Source/drivers/root.cpp +++ b/TactilityKernel/Source/drivers/root.cpp @@ -8,10 +8,10 @@ extern "C" { Driver root_driver = { .name = "root", .compatible = (const char*[]) { "root", nullptr }, - .startDevice = nullptr, - .stopDevice = nullptr, + .start_device = nullptr, + .stop_device = nullptr, .api = nullptr, - .deviceType = nullptr, + .device_type = nullptr, .owner = nullptr, .driver_private = nullptr }; diff --git a/Tests/Tactility/Main.cpp b/Tests/Tactility/Main.cpp index 9177303d..e613b156 100644 --- a/Tests/Tactility/Main.cpp +++ b/Tests/Tactility/Main.cpp @@ -67,10 +67,3 @@ int main(int argc, char** argv) { return data.result; } - -extern "C" { -// Required for FreeRTOS -void vAssertCalled(unsigned long line, const char* const file) { - __assert_fail("assert failed", file, line, ""); -} -} diff --git a/Tests/TactilityCore/Main.cpp b/Tests/TactilityCore/Main.cpp index 5866a9fe..acd1df90 100644 --- a/Tests/TactilityCore/Main.cpp +++ b/Tests/TactilityCore/Main.cpp @@ -49,10 +49,3 @@ int main(int argc, char** argv) { return data.result; } - -extern "C" { - // Required for FreeRTOS - void vAssertCalled(unsigned long line, const char* const file) { - __assert_fail("assert failed", file, line, ""); - } -} diff --git a/Tests/TactilityFreeRtos/Main.cpp b/Tests/TactilityFreeRtos/Main.cpp index 5866a9fe..acd1df90 100644 --- a/Tests/TactilityFreeRtos/Main.cpp +++ b/Tests/TactilityFreeRtos/Main.cpp @@ -49,10 +49,3 @@ int main(int argc, char** argv) { return data.result; } - -extern "C" { - // Required for FreeRTOS - void vAssertCalled(unsigned long line, const char* const file) { - __assert_fail("assert failed", file, line, ""); - } -} diff --git a/Tests/TactilityKernel/DeviceTest.cpp b/Tests/TactilityKernel/DeviceTest.cpp index e1f66195..1497ff1b 100644 --- a/Tests/TactilityKernel/DeviceTest.cpp +++ b/Tests/TactilityKernel/DeviceTest.cpp @@ -167,10 +167,10 @@ TEST_CASE("device_is_ready should return true only when it is started") { Driver driver = { .name = "test_driver", .compatible = compatible, - .startDevice = nullptr, - .stopDevice = nullptr, + .start_device = nullptr, + .stop_device = nullptr, .api = nullptr, - .deviceType = nullptr, + .device_type = nullptr, .owner = &module, .driver_private = nullptr }; diff --git a/Tests/TactilityKernel/DriverIntegrationTest.cpp b/Tests/TactilityKernel/DriverIntegrationTest.cpp index 6e7fb6fa..afb82567 100644 --- a/Tests/TactilityKernel/DriverIntegrationTest.cpp +++ b/Tests/TactilityKernel/DriverIntegrationTest.cpp @@ -33,10 +33,10 @@ static int stop(Device* device) { static Driver integration_driver = { .name = "integration_test_driver", .compatible = (const char*[]) { "integration", nullptr }, - .startDevice = start, - .stopDevice = stop, + .start_device = start, + .stop_device = stop, .api = nullptr, - .deviceType = nullptr, + .device_type = nullptr, .owner = &module, .driver_private = nullptr, }; diff --git a/Tests/TactilityKernel/DriverTest.cpp b/Tests/TactilityKernel/DriverTest.cpp index 93184afd..f7531202 100644 --- a/Tests/TactilityKernel/DriverTest.cpp +++ b/Tests/TactilityKernel/DriverTest.cpp @@ -35,10 +35,10 @@ TEST_CASE("driver_is_compatible should return true if a compatible value is foun Driver driver = { .name = "test_driver", .compatible = compatible, - .startDevice = nullptr, - .stopDevice = nullptr, + .start_device = nullptr, + .stop_device = nullptr, .api = nullptr, - .deviceType = nullptr, + .device_type = nullptr, .owner = &module, .driver_private = nullptr }; @@ -52,10 +52,10 @@ TEST_CASE("driver_find should only find a compatible driver when the driver was Driver driver = { .name = "test_driver", .compatible = compatible, - .startDevice = nullptr, - .stopDevice = nullptr, + .start_device = nullptr, + .stop_device = nullptr, .api = nullptr, - .deviceType = nullptr, + .device_type = nullptr, .owner = &module, .driver_private = nullptr }; diff --git a/Tests/TactilityKernel/Main.cpp b/Tests/TactilityKernel/Main.cpp index 3026b301..4f86b737 100644 --- a/Tests/TactilityKernel/Main.cpp +++ b/Tests/TactilityKernel/Main.cpp @@ -56,10 +56,3 @@ int main(int argc, char** argv) { return data.result; } - -extern "C" { - // Required for FreeRTOS - void vAssertCalled(unsigned long line, const char* const file) { - __assert_fail("assert failed", file, line, ""); - } -}