@brief Result type for DMA buffer acquisition @details Returns either a valid buffer span or an error code @note Buffer uses shared_ptr for lifetime management (important for async DMA) @note Internally holds fl::vector with allocator_psram for efficient DMA operations
| 42 | /// @note Buffer uses shared_ptr for lifetime management (important for async DMA) |
| 43 | /// @note Internally holds fl::vector with allocator_psram for efficient DMA operations |
| 44 | struct DMABuffer { |
| 45 | private: |
| 46 | fl::shared_ptr<DMABufferInternalData> mInternal; ///< Shared ownership of internal data |
| 47 | SPIError error_code; |
| 48 | bool is_ok; |
| 49 | |
| 50 | public: |
| 51 | /// @brief Default constructor (uninitialized error state) |
| 52 | DMABuffer() FL_NOEXCEPT; |
| 53 | |
| 54 | /// @brief Construct successful result with buffer size |
| 55 | /// @param size Size of buffer in bytes to allocate |
| 56 | explicit DMABuffer(size_t size) FL_NOEXCEPT; |
| 57 | |
| 58 | /// @brief Construct successful result with buffer pointer and size (legacy compatibility) |
| 59 | /// @param ptr Shared pointer to buffer data |
| 60 | /// @param size Size of buffer in bytes |
| 61 | /// @deprecated Use DMABuffer(size_t) constructor instead |
| 62 | DMABuffer(fl::shared_ptr<u8> ptr, size_t size) FL_NOEXCEPT; |
| 63 | |
| 64 | /// @brief Construct error result |
| 65 | explicit DMABuffer(SPIError err) FL_NOEXCEPT; |
| 66 | |
| 67 | /// @brief Check if buffer acquisition succeeded |
| 68 | bool ok() const FL_NOEXCEPT; |
| 69 | |
| 70 | /// @brief Get the buffer span (only valid if ok() returns true) |
| 71 | fl::span<u8> data() const FL_NOEXCEPT; |
| 72 | |
| 73 | /// @brief Get the error code (only meaningful if ok() returns false) |
| 74 | SPIError error() const FL_NOEXCEPT; |
| 75 | |
| 76 | /// @brief Reset/clear the buffer (invalidates internal data) |
| 77 | void reset() FL_NOEXCEPT; |
| 78 | |
| 79 | /// @brief Get the size of the buffer in bytes |
| 80 | size_t size() const FL_NOEXCEPT; |
| 81 | }; |
| 82 | |
| 83 | /// @brief Request structure for SPI transmit operations |
| 84 | /// @details Contains the DMA buffer and transmission mode |
no outgoing calls
no test coverage detected