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
@@ -14,31 +14,31 @@
|
||||
|
||||
#define TAG "esp32_i2s"
|
||||
|
||||
struct InternalData {
|
||||
Mutex mutex { 0 };
|
||||
struct Esp32I2sInternal {
|
||||
Mutex mutex {};
|
||||
i2s_chan_handle_t tx_handle = nullptr;
|
||||
i2s_chan_handle_t rx_handle = nullptr;
|
||||
I2sConfig config {};
|
||||
bool config_set = false;
|
||||
|
||||
InternalData() {
|
||||
Esp32I2sInternal() {
|
||||
mutex_construct(&mutex);
|
||||
}
|
||||
|
||||
~InternalData() {
|
||||
~Esp32I2sInternal() {
|
||||
mutex_destruct(&mutex);
|
||||
}
|
||||
};
|
||||
|
||||
#define GET_CONFIG(device) ((Esp32I2sConfig*)device->config)
|
||||
#define GET_DATA(device) ((InternalData*)device_get_driver_data(device))
|
||||
#define GET_DATA(device) ((Esp32I2sInternal*)device_get_driver_data(device))
|
||||
|
||||
#define lock(data) mutex_lock(&data->mutex);
|
||||
#define unlock(data) mutex_unlock(&data->mutex);
|
||||
|
||||
extern "C" {
|
||||
|
||||
static error_t cleanup_channel_handles(InternalData* driver_data) {
|
||||
static error_t cleanup_channel_handles(Esp32I2sInternal* driver_data) {
|
||||
// TODO: error handling of i2ss functions
|
||||
if (driver_data->tx_handle) {
|
||||
i2s_channel_disable(driver_data->tx_handle);
|
||||
@@ -188,7 +188,7 @@ static error_t get_config(Device* device, struct I2sConfig* config) {
|
||||
|
||||
static error_t start(Device* device) {
|
||||
ESP_LOGI(TAG, "start %s", device->name);
|
||||
auto* data = new(std::nothrow) InternalData();
|
||||
auto* data = new(std::nothrow) Esp32I2sInternal();
|
||||
if (!data) return ERROR_OUT_OF_MEMORY;
|
||||
|
||||
device_set_driver_data(device, data);
|
||||
|
||||
Reference in New Issue
Block a user