summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-06-03 21:02:24 +1000
committerjacqueline <me@jacqueline.id.au>2024-06-03 21:02:24 +1000
commit39460931d8e3d044f00f7a4f58b44b1035338f09 (patch)
treea12b989d1f132ae3c5f830959b35315d6f69c51a /src/drivers
parent9457f9021a633ab97b8259f162124857cc0acf8e (diff)
downloadtangara-fw-39460931d8e3d044f00f7a4f58b44b1035338f09.tar.gz
Remove spi locking hack + increase max sd frequency
These two changes (mostly the former) dramatically increase responsiveness when doing database updates; previously we were suffering from some nasty priority inversion. afaict the underlying need to acquire_spi seems to be fixed? i.e. spi bus acquisition is working properly. fingers heavily heavily crossed.
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/display.cpp4
-rw-r--r--src/drivers/include/drivers/spi.hpp2
-rw-r--r--src/drivers/spi.cpp6
-rw-r--r--src/drivers/storage.cpp1
4 files changed, 10 insertions, 3 deletions
diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp
index b0a97b30..e28b6b47 100644
--- a/src/drivers/display.cpp
+++ b/src/drivers/display.cpp
@@ -296,6 +296,8 @@ void Display::SendTransaction(TransactionType type,
void Display::OnLvglFlush(lv_disp_drv_t* disp_drv,
const lv_area_t* area,
lv_color_t* color_map) {
+ spi_device_acquire_bus(handle_, portMAX_DELAY);
+
// First we need to specify the rectangle of the display we're writing into.
uint16_t data[2] = {0, 0};
@@ -314,6 +316,8 @@ void Display::OnLvglFlush(lv_disp_drv_t* disp_drv,
SendCommandWithData(displays::ST77XX_RAMWR,
reinterpret_cast<uint8_t*>(color_map), size * 2);
+ spi_device_release_bus(handle_);
+
if (!first_flush_finished_ && lv_disp_flush_is_last(disp_drv)) {
first_flush_finished_ = true;
SetDisplayOn(display_on_);
diff --git a/src/drivers/include/drivers/spi.hpp b/src/drivers/include/drivers/spi.hpp
index 60638f71..95b002b4 100644
--- a/src/drivers/include/drivers/spi.hpp
+++ b/src/drivers/include/drivers/spi.hpp
@@ -13,6 +13,6 @@ namespace drivers {
esp_err_t init_spi(void);
esp_err_t deinit_spi(void);
-std::lock_guard<std::mutex> acquire_spi(void);
+int acquire_spi(void);
} // namespace drivers
diff --git a/src/drivers/spi.cpp b/src/drivers/spi.cpp
index f4d3ea6e..50799c6e 100644
--- a/src/drivers/spi.cpp
+++ b/src/drivers/spi.cpp
@@ -56,8 +56,10 @@ esp_err_t deinit_spi(void) {
return spi_bus_free(kSpiHost);
}
-std::lock_guard<std::mutex> acquire_spi(void) {
- return std::lock_guard<std::mutex>{sSpiMutex};
+int acquire_spi(void) {
+ // Cross fingers emoji: I *think* this is now resolved???
+ // return std::lock_guard<std::mutex>{sSpiMutex};
+ return 1;
}
} // namespace drivers
diff --git a/src/drivers/storage.cpp b/src/drivers/storage.cpp
index b2b7174e..f4be5864 100644
--- a/src/drivers/storage.cpp
+++ b/src/drivers/storage.cpp
@@ -57,6 +57,7 @@ auto SdStorage::Create(IGpios& gpio) -> cpp::result<SdStorage*, Error> {
}
auto host = std::make_unique<sdmmc_host_t>(sdmmc_host_t SDSPI_HOST_DEFAULT());
+ host->max_freq_khz = SDMMC_FREQ_HIGHSPEED;
auto card = std::make_unique<sdmmc_card_t>();
host->slot = handle;