mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
Make struct fields consistent, move PC code into platform project
This commit is contained in:
parent
827f5034d5
commit
56bb9fcc82
@ -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
|
||||
};
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
13
Platforms/PlatformPosix/Source/freertos.c
Normal file
13
Platforms/PlatformPosix/Source/freertos.c
Normal file
@ -0,0 +1,13 @@
|
||||
#include <assert.h>
|
||||
#include <tactility/freertos/task.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#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, "");
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -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, "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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, "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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, "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -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,
|
||||
};
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -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, "");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user