SPI device migration (#490)
- Implement SPI devices in dts files for all devices - Removed `tt::hal::spi` HAL and its configurations - Fix for devicetree generator "boolean" support - Remove unused custom locks in all `DisplayDevice` implementations - Fixed some bugs with devices - Updated XPT2046 driver - Fix for `WifiEsp` deadlock - Export a lot of new `math.h` symbols with `tt_init.cpp` - Created `SpiDeviceLock` in `TactilityCore` as a wrapper for kernel SPI locking - Improved `TactilityKernel` SPI driver.
This commit is contained in:
committed by
GitHub
parent
74127a5f6c
commit
d27404964a
@@ -0,0 +1,36 @@
|
||||
description: ESP32 SPI Controller
|
||||
|
||||
include: ["spi-controller.yaml"]
|
||||
|
||||
compatible: "espressif,esp32-spi"
|
||||
|
||||
properties:
|
||||
host:
|
||||
type: int
|
||||
required: true
|
||||
description: |
|
||||
The SPI host (controller) to use.
|
||||
Defined by spi_host_device_t (e.g. SPI2_HOST, SPI3_HOST).
|
||||
pin-mosi:
|
||||
type: int
|
||||
required: true
|
||||
description: MOSI (Data 0) pin
|
||||
pin-miso:
|
||||
type: int
|
||||
required: true
|
||||
description: MISO (Data 1) pin
|
||||
pin-sclk:
|
||||
type: int
|
||||
required: true
|
||||
description: Clock pin
|
||||
pin-wp:
|
||||
type: int
|
||||
description: WP (Data 2) pin
|
||||
pin-hd:
|
||||
type: int
|
||||
description: HD (Data 3) pin
|
||||
max-transfer-size:
|
||||
type: int
|
||||
description: |
|
||||
Data transfer size limit in bytes.
|
||||
0 means the platform decides the limit.
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <tactility/bindings/bindings.h>
|
||||
#include <tactility/bindings/gpio.h>
|
||||
#include <tactility/drivers/esp32_gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#pragma once
|
||||
|
||||
#include <tactility/bindings/bindings.h>
|
||||
#include <tactility/drivers/esp32_spi.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DEFINE_DEVICETREE(esp32_spi, struct Esp32SpiConfig)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -10,11 +10,17 @@ extern "C" {
|
||||
|
||||
struct Esp32SpiConfig {
|
||||
spi_host_device_t host;
|
||||
/** Data 0 pin */
|
||||
int pin_mosi;
|
||||
/** Data 1 pin */
|
||||
int pin_miso;
|
||||
/** Clock pin */
|
||||
int pin_sclk;
|
||||
/** Data 2 pin */
|
||||
int pin_wp;
|
||||
/** Data 3 pin */
|
||||
int pin_hd;
|
||||
/** Data transfer size limit in bytes. 0 means the platform decides the limit. */
|
||||
int max_transfer_size;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/esp32_spi.h>
|
||||
#include <tactility/concurrent/mutex.h>
|
||||
#include <tactility/concurrent/recursive_mutex.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <esp_log.h>
|
||||
@@ -16,27 +16,27 @@
|
||||
extern "C" {
|
||||
|
||||
struct Esp32SpiInternal {
|
||||
Mutex mutex;
|
||||
RecursiveMutex mutex = {};
|
||||
bool initialized = false;
|
||||
|
||||
Esp32SpiInternal() {
|
||||
mutex_construct(&mutex);
|
||||
recursive_mutex_construct(&mutex);
|
||||
}
|
||||
|
||||
~Esp32SpiInternal() {
|
||||
mutex_destruct(&mutex);
|
||||
recursive_mutex_destruct(&mutex);
|
||||
}
|
||||
};
|
||||
|
||||
static error_t lock(Device* device) {
|
||||
auto* driver_data = GET_DATA(device);
|
||||
mutex_lock(&driver_data->mutex);
|
||||
recursive_mutex_lock(&driver_data->mutex);
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
static error_t try_lock(Device* device, TickType_t timeout) {
|
||||
auto* driver_data = GET_DATA(device);
|
||||
if (mutex_try_lock(&driver_data->mutex, timeout)) {
|
||||
if (recursive_mutex_try_lock(&driver_data->mutex, timeout)) {
|
||||
return ERROR_NONE;
|
||||
}
|
||||
return ERROR_TIMEOUT;
|
||||
@@ -44,7 +44,7 @@ static error_t try_lock(Device* device, TickType_t timeout) {
|
||||
|
||||
static error_t unlock(Device* device) {
|
||||
auto* driver_data = GET_DATA(device);
|
||||
mutex_unlock(&driver_data->mutex);
|
||||
recursive_mutex_unlock(&driver_data->mutex);
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user