mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-20 07:25:06 +00:00
Fixes
This commit is contained in:
parent
f50fbfe331
commit
99bbe105eb
@ -178,7 +178,7 @@ def generate_devicetree_c(filename: str, items: list[object], bindings: list[Bin
|
|||||||
file.write("\n")
|
file.write("\n")
|
||||||
|
|
||||||
file.write(dedent('''\
|
file.write(dedent('''\
|
||||||
#define TAG "devicetree"
|
#define TAG LOG_TAG(devicetree)
|
||||||
|
|
||||||
static int init_builtin_device(struct Device* device, const char* compatible, struct Device* parent_device) {
|
static int init_builtin_device(struct Device* device, const char* compatible, struct Device* parent_device) {
|
||||||
struct Driver* driver = driver_find(compatible);
|
struct Driver* driver = driver_find(compatible);
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
#include <driver/gpio.h>
|
#include <driver/gpio.h>
|
||||||
#include <esp_log.h>
|
|
||||||
|
|
||||||
#include <Tactility/Driver.h>
|
#include <Tactility/Driver.h>
|
||||||
#include <Tactility/drivers/Esp32Gpio.h>
|
#include <Tactility/drivers/Esp32Gpio.h>
|
||||||
#include <Tactility/drivers/GpioController.h>
|
#include <Tactility/drivers/GpioController.h>
|
||||||
#include <Tactility/drivers/Gpio.h>
|
#include <Tactility/drivers/Gpio.h>
|
||||||
|
#include <Tactility/Log.h>
|
||||||
|
|
||||||
#define TAG "esp32_gpio"
|
#define TAG LOG_TAG(esp32_gpio)
|
||||||
|
|
||||||
#define GET_CONFIG(device) ((struct Esp32GpioConfig*)device->internal.driver_data)
|
#define GET_CONFIG(device) ((struct Esp32GpioConfig*)device->internal.driver_data)
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
#include <esp_log.h>
|
|
||||||
#include <driver/i2c.h>
|
#include <driver/i2c.h>
|
||||||
|
|
||||||
#include <Tactility/Driver.h>
|
#include <Tactility/Driver.h>
|
||||||
#include <Tactility/drivers/Esp32I2c.h>
|
#include <Tactility/drivers/Esp32I2c.h>
|
||||||
#include <Tactility/drivers/I2cController.h>
|
#include <Tactility/drivers/I2cController.h>
|
||||||
|
#include <Tactility/Log.h>
|
||||||
|
|
||||||
#define TAG "esp32_i2c"
|
#define TAG LOG_TAG(esp32_i2c)
|
||||||
|
|
||||||
struct InternalData {
|
struct InternalData {
|
||||||
Mutex mutex {};
|
Mutex mutex {};
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sys/errno.h>
|
|
||||||
|
|
||||||
#include <Tactility/concurrent/Mutex.h>
|
#include <Tactility/concurrent/Mutex.h>
|
||||||
#include <Tactility/Bus.h>
|
#include <Tactility/Bus.h>
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
#include <Tactility/Error.h>
|
#include <Tactility/Error.h>
|
||||||
#include <Tactility/Log.h>
|
#include <Tactility/Log.h>
|
||||||
|
|
||||||
|
#define TAG LOG_TAG(driver)
|
||||||
|
|
||||||
struct DriverInternalData {
|
struct DriverInternalData {
|
||||||
Mutex mutex {};
|
Mutex mutex {};
|
||||||
int use_count = 0;
|
int use_count = 0;
|
||||||
@ -34,8 +36,6 @@ struct DriverLedger {
|
|||||||
|
|
||||||
static DriverLedger ledger;
|
static DriverLedger ledger;
|
||||||
|
|
||||||
#define TAG "driver"
|
|
||||||
|
|
||||||
#define ledger_lock() mutex_lock(&ledger.mutex);
|
#define ledger_lock() mutex_lock(&ledger.mutex);
|
||||||
#define ledger_unlock() mutex_unlock(&ledger.mutex);
|
#define ledger_unlock() mutex_unlock(&ledger.mutex);
|
||||||
|
|
||||||
@ -43,7 +43,6 @@ static DriverLedger ledger;
|
|||||||
#define driver_lock(driver) mutex_lock(&driver_internal_data(driver)->mutex);
|
#define driver_lock(driver) mutex_lock(&driver_internal_data(driver)->mutex);
|
||||||
#define driver_unlock(driver) mutex_unlock(&driver_internal_data(driver)->mutex);
|
#define driver_unlock(driver) mutex_unlock(&driver_internal_data(driver)->mutex);
|
||||||
|
|
||||||
|
|
||||||
static void driver_add(Driver* dev) {
|
static void driver_add(Driver* dev) {
|
||||||
LOG_I(TAG, "add %s", dev->name);
|
LOG_I(TAG, "add %s", dev->name);
|
||||||
ledger_lock();
|
ledger_lock();
|
||||||
@ -85,18 +84,18 @@ int driver_destruct(Driver* driver) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Driver* driver_find(const char* name) {
|
Driver* driver_find(const char* compatible) {
|
||||||
ledger_lock();
|
ledger_lock();
|
||||||
const auto it = std::ranges::find_if(ledger.drivers, [name](Driver* driver) {
|
const auto it = std::ranges::find_if(ledger.drivers, [compatible](Driver* driver) {
|
||||||
const char** current_compatible = driver->compatible;
|
const char** current_compatible = driver->compatible;
|
||||||
assert(current_compatible != nullptr);
|
assert(current_compatible != nullptr);
|
||||||
while (*current_compatible != nullptr) {
|
while (*current_compatible != nullptr) {
|
||||||
if (strcmp(name, *current_compatible) == 0) {
|
if (strcmp(compatible, *current_compatible) == 0) {
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
current_compatible++;
|
current_compatible++;
|
||||||
}
|
}
|
||||||
return -1;
|
return false;
|
||||||
});
|
});
|
||||||
auto* driver = (it != ledger.drivers.end()) ? *it : nullptr;
|
auto* driver = (it != ledger.drivers.end()) ? *it : nullptr;
|
||||||
ledger_unlock();
|
ledger_unlock();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user