Use new SPI settings

This commit is contained in:
Henrik Stickann
2022-04-15 14:57:01 +02:00
parent 3c8fce14f6
commit 4504ee9c3b
6 changed files with 98 additions and 7 deletions

View File

@@ -45,6 +45,7 @@ namespace sta
void receive(uint8_t * buffer, size_t size) override;
private:
SPI_HandleTypeDef * handle_; /**< SPI handle */
};

View File

@@ -87,6 +87,15 @@ namespace sta
*/
void receive(uint8_t * buffer, size_t size);
/**
* @brief Get SPI interface settings.
*
* @return SPI settings
*/
const SpiSettings & settings() const;
/**
* @brief Activate device via CS pin.
*/

View File

@@ -5,6 +5,7 @@
#define STA_SPI_INTERFACE_HPP
#include <sta/mutex.hpp>
#include <sta/spi_settings.hpp>
#include <stdint.h>
#include <stddef.h>
@@ -19,9 +20,10 @@ namespace sta
{
public:
/**
* @param settings SPI interface settings
* @param mutex Mutex object for managing shared access. Pass nullptr for no access control
*/
SpiInterface(Mutex * mutex = nullptr);
SpiInterface(const SpiSettings & settings, Mutex * mutex = nullptr);
/**
@@ -76,6 +78,15 @@ namespace sta
*/
virtual void receive(uint8_t * buffer, size_t size) = 0;
/**
* @brief Get SPI interface settings.
*
* @return SPI settings
*/
const SpiSettings & settings() const;
/**
* @brief Acquire usage rights to use the interface.
*
@@ -90,7 +101,8 @@ namespace sta
virtual void release();
private:
Mutex * mutex_; /**< Mutex object */
SpiSettings settings_; /** SPI settings */
Mutex * mutex_; /**< Mutex object */
};
} // namespace sta