Board implementations and fixes (#247)
- Implemented Elecrow Crowpanel Basic 5.0" - Implemented Elecrow Crowpanel Advance 5.0" - Implemented CYD 2432S032C - Fix for CYD 4848S040C rendering drift (lower transfer speed) - Fix for SD card locking mechanism for various boards
This commit is contained in:
committed by
GitHub
parent
21936f7e9e
commit
f85d0239ff
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "SdCardDevice.h"
|
||||
|
||||
#include <Tactility/hal/spi/Spi.h>
|
||||
|
||||
#include <sd_protocol_types.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -26,7 +28,8 @@ public:
|
||||
gpio_num_t spiPinWp,
|
||||
gpio_num_t spiPinInt,
|
||||
MountBehaviour mountBehaviourAtBoot,
|
||||
std::shared_ptr<Lock> lock = std::make_shared<Mutex>(),
|
||||
/** When custom lock is nullptr, use the SPI default one */
|
||||
std::shared_ptr<Lock> _Nullable customLock = nullptr,
|
||||
std::vector<gpio_num_t> csPinWorkAround = std::vector<gpio_num_t>(),
|
||||
spi_host_device_t spiHost = SPI2_HOST,
|
||||
int spiFrequencyKhz = SDMMC_FREQ_DEFAULT
|
||||
@@ -36,12 +39,10 @@ public:
|
||||
spiPinWp(spiPinWp),
|
||||
spiPinInt(spiPinInt),
|
||||
mountBehaviourAtBoot(mountBehaviourAtBoot),
|
||||
lock(std::move(lock)),
|
||||
customLock(customLock ? std::move(customLock) : nullptr),
|
||||
csPinWorkAround(std::move(csPinWorkAround)),
|
||||
spiHost(spiHost)
|
||||
{
|
||||
assert(this->lock != nullptr);
|
||||
}
|
||||
{}
|
||||
|
||||
int spiFrequencyKhz;
|
||||
gpio_num_t spiPinCs; // Clock
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
gpio_num_t spiPinWp; // Write-protect
|
||||
gpio_num_t spiPinInt; // Interrupt
|
||||
SdCardDevice::MountBehaviour mountBehaviourAtBoot;
|
||||
std::shared_ptr<Lock> _Nullable lock;
|
||||
std::shared_ptr<Lock> _Nullable customLock;
|
||||
std::vector<gpio_num_t> csPinWorkAround;
|
||||
spi_host_device_t spiHost;
|
||||
bool formatOnMountFailed = false;
|
||||
@@ -80,7 +81,13 @@ public:
|
||||
bool unmount() final;
|
||||
std::string getMountPath() const final { return mountPath; }
|
||||
|
||||
Lock& getLock() const final { return *config->lock; }
|
||||
Lock& getLock() const final {
|
||||
if (config->customLock) {
|
||||
return *config->customLock;
|
||||
} else {
|
||||
return *spi::getLock(config->spiHost);
|
||||
}
|
||||
}
|
||||
|
||||
State getState() const override;
|
||||
|
||||
|
||||
@@ -43,6 +43,6 @@ bool stop(spi_host_device_t device);
|
||||
bool isStarted(spi_host_device_t device);
|
||||
|
||||
/** @return the lock that represents the specified device. Can be used with third party SPI implementations or native API calls (e.g. ESP-IDF). */
|
||||
Lock& getLock(spi_host_device_t device);
|
||||
std::shared_ptr<Lock> getLock(spi_host_device_t device);
|
||||
|
||||
} // namespace tt::hal::spi
|
||||
|
||||
+5
-10
@@ -134,20 +134,15 @@ SdCardDevice::State SpiSdCardDevice::getState() const {
|
||||
* Writing and reading to the bus from 2 devices at the same time causes crashes.
|
||||
* This work-around ensures that this check is only happening when LVGL isn't rendering.
|
||||
*/
|
||||
if (config->lock) {
|
||||
bool locked = config->lock->lock(50); // TODO: Refactor to a more reliable locking mechanism
|
||||
if (!locked) {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
return State::Unknown;
|
||||
}
|
||||
auto lock = getLock().asScopedLock();
|
||||
bool locked = lock.lock(50); // TODO: Refactor to a more reliable locking mechanism
|
||||
if (!locked) {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
return State::Unknown;
|
||||
}
|
||||
|
||||
bool result = sdmmc_get_status(card) == ESP_OK;
|
||||
|
||||
if (config->lock) {
|
||||
config->lock->unlock();
|
||||
}
|
||||
|
||||
if (result) {
|
||||
return State::Mounted;
|
||||
} else {
|
||||
@@ -42,7 +42,7 @@ bool init(const std::vector<spi::Configuration>& configurations) {
|
||||
}
|
||||
|
||||
bool configure(spi_host_device_t device, const spi_bus_config_t& configuration) {
|
||||
auto lock = getLock(device).asScopedLock();
|
||||
auto lock = getLock(device)->asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
Data& data = dataArray[device];
|
||||
@@ -59,7 +59,7 @@ bool configure(spi_host_device_t device, const spi_bus_config_t& configuration)
|
||||
}
|
||||
|
||||
bool start(spi_host_device_t device) {
|
||||
auto lock = getLock(device).asScopedLock();
|
||||
auto lock = getLock(device)->asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
Data& data = dataArray[device];
|
||||
@@ -96,7 +96,7 @@ bool start(spi_host_device_t device) {
|
||||
}
|
||||
|
||||
bool stop(spi_host_device_t device) {
|
||||
auto lock = getLock(device).asScopedLock();
|
||||
auto lock = getLock(device)->asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
Data& data = dataArray[device];
|
||||
@@ -133,14 +133,14 @@ bool stop(spi_host_device_t device) {
|
||||
}
|
||||
|
||||
bool isStarted(spi_host_device_t device) {
|
||||
auto lock = getLock(device).asScopedLock();
|
||||
auto lock = getLock(device)->asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
return dataArray[device].isStarted;
|
||||
}
|
||||
|
||||
Lock& getLock(spi_host_device_t device) {
|
||||
return *dataArray[device].lock;
|
||||
std::shared_ptr<Lock> getLock(spi_host_device_t device) {
|
||||
return dataArray[device].lock;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user