Add kernel drivers for SPI and UART and make locking APIs more consistent (#489)
- Add kernel support for SPI driver - Add kernel support for UART driver - Implemented ESP32 UART kernel driver - Update existing UART-related code in Tactility to use new kernel driver - Remove UART from tt::hal::Configuration - Remove tt_hal_uart functionality but keep functions for now - Update devicetrees for UART changes - Kernel mutex and recursive mutex: improved locking API design - Other kernel improvements - Added device_exists_of_type() and device_find_by_name()
This commit is contained in:
committed by
GitHub
parent
7e24105d0c
commit
74127a5f6c
@@ -12,20 +12,20 @@
|
||||
#define TAG "esp32_i2c"
|
||||
#define ACK_CHECK_EN 1
|
||||
|
||||
struct InternalData {
|
||||
struct Esp32SpiInternal {
|
||||
Mutex mutex { 0 };
|
||||
|
||||
InternalData() {
|
||||
Esp32SpiInternal() {
|
||||
mutex_construct(&mutex);
|
||||
}
|
||||
|
||||
~InternalData() {
|
||||
~Esp32SpiInternal() {
|
||||
mutex_destruct(&mutex);
|
||||
}
|
||||
};
|
||||
|
||||
#define GET_CONFIG(device) ((Esp32I2cConfig*)device->config)
|
||||
#define GET_DATA(device) ((InternalData*)device_get_driver_data(device))
|
||||
#define GET_DATA(device) ((Esp32SpiInternal*)device_get_driver_data(device))
|
||||
|
||||
#define lock(data) mutex_lock(&data->mutex);
|
||||
#define unlock(data) mutex_unlock(&data->mutex);
|
||||
@@ -144,11 +144,6 @@ on_error:
|
||||
return esp_err_to_error(error);
|
||||
}
|
||||
|
||||
error_t esp32_i2c_get_port(struct Device* device, i2c_port_t* port) {
|
||||
auto* config = GET_CONFIG(device);
|
||||
*port = config->port;
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
static error_t start(Device* device) {
|
||||
ESP_LOGI(TAG, "start %s", device->name);
|
||||
@@ -177,14 +172,14 @@ static error_t start(Device* device) {
|
||||
LOG_E(TAG, "Failed to install driver at port %d: %s", static_cast<int>(dts_config->port), esp_err_to_name(error));
|
||||
return ERROR_RESOURCE;
|
||||
}
|
||||
auto* data = new InternalData();
|
||||
auto* data = new Esp32SpiInternal();
|
||||
device_set_driver_data(device, data);
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
static error_t stop(Device* device) {
|
||||
ESP_LOGI(TAG, "stop %s", device->name);
|
||||
auto* driver_data = static_cast<InternalData*>(device_get_driver_data(device));
|
||||
auto* driver_data = static_cast<Esp32SpiInternal*>(device_get_driver_data(device));
|
||||
|
||||
i2c_port_t port = GET_CONFIG(device)->port;
|
||||
esp_err_t result = i2c_driver_delete(port);
|
||||
|
||||
Reference in New Issue
Block a user