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
@@ -4,7 +4,6 @@
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Axp2101Power.h>
|
||||
|
||||
using namespace tt::hal;
|
||||
@@ -21,30 +20,5 @@ static DeviceVector createDevices() {
|
||||
|
||||
extern const Configuration hardwareConfiguration = {
|
||||
.initBoot = initBoot,
|
||||
.createDevices = createDevices,
|
||||
.spi {
|
||||
spi::Configuration {
|
||||
.device = SPI3_HOST,
|
||||
.dma = SPI_DMA_CH_AUTO,
|
||||
.config = {
|
||||
.mosi_io_num = GPIO_NUM_37,
|
||||
.miso_io_num = GPIO_NUM_35,
|
||||
.sclk_io_num = GPIO_NUM_36,
|
||||
.data2_io_num = GPIO_NUM_NC,
|
||||
.data3_io_num = GPIO_NUM_NC,
|
||||
.data4_io_num = GPIO_NUM_NC,
|
||||
.data5_io_num = GPIO_NUM_NC,
|
||||
.data6_io_num = GPIO_NUM_NC,
|
||||
.data7_io_num = GPIO_NUM_NC,
|
||||
.data_io_default_level = false,
|
||||
.max_transfer_sz = LCD_SPI_TRANSFER_SIZE_LIMIT,
|
||||
.flags = 0,
|
||||
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
|
||||
.intr_flags = 0
|
||||
},
|
||||
.initMode = spi::InitMode::ByTactility,
|
||||
.isMutable = false,
|
||||
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
|
||||
}
|
||||
}
|
||||
.createDevices = createDevices
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <driver/spi_common.h>
|
||||
|
||||
// Display
|
||||
constexpr auto LCD_SPI_HOST = SPI3_HOST;
|
||||
constexpr auto LCD_SPI_HOST = SPI2_HOST;
|
||||
constexpr auto LCD_PIN_CS = GPIO_NUM_3;
|
||||
constexpr auto LCD_PIN_DC = GPIO_NUM_35;
|
||||
constexpr auto LCD_HORIZONTAL_RESOLUTION = 320;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
|
||||
|
||||
@@ -16,13 +17,14 @@ std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
GPIO_NUM_NC,
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
tt::lvgl::getSyncLock(),
|
||||
std::vector {
|
||||
CORES3_LCD_PIN_CS
|
||||
},
|
||||
SPI3_HOST
|
||||
std::vector { CORES3_LCD_PIN_CS }
|
||||
);
|
||||
|
||||
auto* spi_controller = device_find_by_name("spi0");
|
||||
check(spi_controller, "spi0 not found");
|
||||
|
||||
return std::make_shared<SpiSdCardDevice>(
|
||||
std::move(configuration)
|
||||
std::move(configuration),
|
||||
spi_controller
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_i2s.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
// Reference: https://docs.m5stack.com/en/core/CoreS3
|
||||
@@ -22,8 +23,6 @@
|
||||
clock-frequency = <400000>;
|
||||
pin-sda = <12>;
|
||||
pin-scl = <11>;
|
||||
pin-sda-pullup;
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
i2c_port_a {
|
||||
@@ -32,18 +31,14 @@
|
||||
clock-frequency = <400000>;
|
||||
pin-sda = <2>;
|
||||
pin-scl = <1>;
|
||||
pin-sda-pullup;
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
/*
|
||||
i2c_port_b {
|
||||
compatible = "espressif,esp32-i2c";
|
||||
port = <I2C_NUM_1>;
|
||||
clock-frequency = <400000>;
|
||||
pin-sda = <9>;
|
||||
pin-scl = <8>;
|
||||
pin-sda-pullup;
|
||||
pin-scl-pullup;
|
||||
};
|
||||
|
||||
i2c_port_c {
|
||||
@@ -52,8 +47,17 @@
|
||||
clock-frequency = <400000>;
|
||||
pin-sda = <18>;
|
||||
pin-scl = <17>;
|
||||
sda-pullup;
|
||||
scl-pullup;
|
||||
};
|
||||
*/
|
||||
spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
pin-mosi = <37>;
|
||||
pin-miso = <35>;
|
||||
pin-sclk = <36>;
|
||||
pin-wp = <GPIO_PIN_NONE>;
|
||||
pin-hd = <GPIO_PIN_NONE>;
|
||||
max-transfer-size = <0>;
|
||||
};
|
||||
|
||||
// TODO: Enable speaker via ES7210 I2C: https://github.com/m5stack/M5Unified/blob/a6256725481f1bc366655fa48cf03b6095e30ad1/src/M5Unified.cpp#L417
|
||||
|
||||
Reference in New Issue
Block a user