From 93e1859ba63fc3ced83252e8d82585093b1e6818 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Wed, 31 Aug 2022 15:25:33 +0100 Subject: [PATCH] AP_HAL_ChibiOS: support is_busy() on WSPI device --- libraries/AP_HAL_ChibiOS/WSPIDevice.cpp | 9 +++++++++ libraries/AP_HAL_ChibiOS/WSPIDevice.h | 1 + 2 files changed, 10 insertions(+) diff --git a/libraries/AP_HAL_ChibiOS/WSPIDevice.cpp b/libraries/AP_HAL_ChibiOS/WSPIDevice.cpp index 7c5cbf8f21..bdf70ed60c 100644 --- a/libraries/AP_HAL_ChibiOS/WSPIDevice.cpp +++ b/libraries/AP_HAL_ChibiOS/WSPIDevice.cpp @@ -85,6 +85,15 @@ WSPIDesc WSPIDeviceManager::device_table[] = { HAL_WSPI_DEVICE_LIST }; #endif #endif +bool WSPIDevice::is_busy() +{ +#if HAL_USE_OCTOSPI + return (wspi_devices[device_desc.bus].driver->ospi->SR & OCTOSPI_SR_BUSY) != 0U; +#else + return (wspi_devices[device_desc.bus].driver->qspi->SR & QUADSPI_SR_BUSY) != 0U; +#endif +} + bool WSPIDevice::transfer(const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len) { diff --git a/libraries/AP_HAL_ChibiOS/WSPIDevice.h b/libraries/AP_HAL_ChibiOS/WSPIDevice.h index 0735fdec32..47af925e47 100644 --- a/libraries/AP_HAL_ChibiOS/WSPIDevice.h +++ b/libraries/AP_HAL_ChibiOS/WSPIDevice.h @@ -111,6 +111,7 @@ public: #endif } + bool is_busy() override; bool acquire_bus(bool acquire); // Enters Memory mapped or eXecution In Place or 0-4-4 mode