| 15 | #include "platforms/shared/spi_hw_base.h" |
| 16 | |
| 17 | FL_TEST_FILE(FL_FILEPATH) { |
| 18 | |
| 19 | using namespace fl; |
| 20 | |
| 21 | namespace { |
| 22 | |
| 23 | /// @brief Simple mock SPI hardware controller for testing |
| 24 | /// Simulates SpiHwBase without actual hardware transmission |
| 25 | class MockSpiHw : public SpiHwBase { |
| 26 | public: |
| 27 | explicit MockSpiHw(uint8_t laneCount = 1, const char* name = "MOCK_SPI", int priority = 5) |
| 28 | : mLaneCount(laneCount), mName(name) { |
| 29 | (void)priority; // Unused, just for API compatibility |
| 30 | } |
| 31 | |
| 32 | // SpiHwBase interface |
| 33 | bool begin(const void* config) override { |
| 34 | mBeginCalled = true; |
| 35 | mInitialized = true; |
| 36 | return mBeginReturnValue; |
| 37 | } |
| 38 | |
| 39 | void end() override { |
| 40 | mEndCalled = true; |
| 41 | mInitialized = false; |
| 42 | } |
| 43 | |
| 44 | DMABuffer acquireDMABuffer(size_t size) override { |
| 45 | mAcquireBufferCalled = true; |
| 46 | if (size > mDmaBuffer.size()) { |
| 47 | mDmaBuffer.resize(size); |
| 48 | } |
| 49 | // Return a DMABuffer constructed with size |
| 50 | return DMABuffer(size); |
| 51 | } |
| 52 | |
| 53 | bool transmit(TransmitMode mode = TransmitMode::ASYNC) override { |
| 54 | mTransmitCalled = true; |
| 55 | mTransmitCount++; |
| 56 | mTransmitMode = mode; |
| 57 | if (mode == TransmitMode::ASYNC) { |
| 58 | mBusy = true; |
| 59 | } |
| 60 | return mTransmitReturnValue; |
| 61 | } |
| 62 | |
| 63 | bool waitComplete(uint32_t timeout_ms = fl::numeric_limits<uint32_t>::max()) override { |
| 64 | (void)timeout_ms; |
| 65 | mWaitCompleteCalled = true; |
| 66 | mBusy = false; |
| 67 | return mWaitCompleteReturnValue; |
| 68 | } |
| 69 | |
| 70 | bool isBusy() const override { |
| 71 | return mBusy; |
| 72 | } |
| 73 | |
| 74 | bool isInitialized() const override { |
nothing calls this directly
no test coverage detected