44 lines
875 B
C++
44 lines
875 B
C++
/*
|
|
* peripherals_spi.hpp
|
|
*
|
|
* Created on: Mar 5, 2021
|
|
* Author: erki
|
|
*/
|
|
|
|
#ifndef INC_PERIPHERALS_SPI_HPP_
|
|
#define INC_PERIPHERALS_SPI_HPP_
|
|
|
|
#include "spi.h"
|
|
|
|
#include "peripherals_config.hpp"
|
|
#include "peripherals_io.hpp"
|
|
|
|
namespace Peripherals
|
|
{
|
|
|
|
struct Spi
|
|
{
|
|
SPI_HandleTypeDef* hspi;
|
|
IO cs;
|
|
|
|
std::uint32_t timeout = 10;
|
|
|
|
#ifdef PERIPHERALS_USE_DELAY_US
|
|
std::uint32_t cs_set_delay = 0;
|
|
#endif
|
|
|
|
Spi() = delete;
|
|
Spi(SPI_HandleTypeDef* hspi, const IO& cs);
|
|
|
|
void WriteRegister(std::uint8_t reg, uint8_t data);
|
|
void WriteRegisterMultibyte(std::uint8_t reg, std::uint8_t* data, const std::uint32_t len);
|
|
|
|
std::uint8_t ReadRegister(std::uint8_t reg, const std::uint32_t read_delay = 0);
|
|
void ReadRegisterMultibyte(std::uint8_t reg, std::uint8_t* data, const std::uint32_t len, const std::uint32_t read_delay = 0);
|
|
};
|
|
|
|
}
|
|
|
|
|
|
#endif /* INC_PERIPHERALS_SPI_HPP_ */
|