Add SPI subdir

This commit is contained in:
Henrik Stickann 2022-05-10 15:36:34 +02:00
parent b73e03fddf
commit 8efed8802d
6 changed files with 43 additions and 35 deletions

View File

@ -1,11 +1,12 @@
/** /**
* @brief SPI interface definitions. * @file
* @brief SPI device interface.
*/ */
#ifndef STA_SPI_DEVICE_HPP #ifndef STA_SPI_DEVICE_HPP
#define STA_SPI_DEVICE_HPP #define STA_SPI_DEVICE_HPP
#include <sta/intf/gpio_pin.hpp> #include <sta/intf/gpio_pin.hpp>
#include <sta/intf/spi_interface.hpp> #include <sta/spi/interface.hpp>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
@ -15,6 +16,8 @@ namespace sta
{ {
/** /**
* @brief Interface for SPI devices. * @brief Interface for SPI devices.
*
* @ingroup staCoreSPI
*/ */
class SpiDevice class SpiDevice
{ {

View File

@ -1,11 +1,12 @@
/** /**
* @brief SPI interface definitions. * @file
* @brief SPI interface definition.
*/ */
#ifndef STA_SPI_INTERFACE_HPP #ifndef STA_SPI_INTERFACE_HPP
#define STA_SPI_INTERFACE_HPP #define STA_SPI_INTERFACE_HPP
#include <sta/intf/mutex.hpp> #include <sta/intf/mutex.hpp>
#include <sta/spi_settings.hpp> #include <sta/spi/settings.hpp>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
@ -15,6 +16,8 @@ namespace sta
{ {
/** /**
* @brief Interface for SPI hardware. * @brief Interface for SPI hardware.
*
* @ingroup staCoreSPI
*/ */
class SpiInterface class SpiInterface
{ {

View File

@ -1,21 +1,35 @@
/** /**
* @brief SPI setting types. * @file
* @brief SPI settings.
*/ */
#ifndef STA_SPI_SETTINGS_HPP #ifndef STA_SPI_SETTINGS_HPP
#define STA_SPI_SETTINGS_HPP #define STA_SPI_SETTINGS_HPP
/**
* @defgroup staCoreSPI SPI
* @ingroup staCore
* @brief SPI interface.
*/
#include <cstdint> #include <cstdint>
namespace sta namespace sta
{ {
/**
* @ingroup staCoreSPI
* @{
*/
/** /**
* @brief SPI clock polarity. * @brief SPI clock polarity.
*/ */
enum class SpiClkPolarity enum class SpiClkPolarity
{ {
LOW, LOW, /**< Low idle clock */
HIGH HIGH /**< High idle clock */
}; };
/** /**
@ -23,8 +37,8 @@ namespace sta
*/ */
enum class SpiClkPhase enum class SpiClkPhase
{ {
EDGE_1, EDGE_1, /**< Sample on first edge, shift out on second edge */
EDGE_2 EDGE_2 /**< Shift out on first edge, sample on second edge */
}; };
/** /**
@ -32,10 +46,10 @@ namespace sta
*/ */
enum class SpiMode enum class SpiMode
{ {
MODE_0, MODE_0, /**< Low idle clock, sample on rising edge, shift out on falling edge */
MODE_1, MODE_1, /**< Low idle clock, sample on falling edge, shift out on rising edge */
MODE_2, MODE_2, /**< High idle clock, sample on rising edge, shift out on falling edge */
MODE_3 MODE_3 /**< High idle clock, sample on falling edge, shift out on rising edge */
}; };
/** /**
@ -43,8 +57,8 @@ namespace sta
*/ */
enum class SpiDataSize enum class SpiDataSize
{ {
SIZE_8, SIZE_8, /**< 8-bit data size */
SIZE_16 SIZE_16 /**< 16-bit data size */
}; };
/** /**
@ -52,23 +66,8 @@ namespace sta
*/ */
enum class SpiBitOrder enum class SpiBitOrder
{ {
MSB, MSB, /**< Send most significant bit first */
LSB LSB /**< Send least significant bit first */
};
/**
* @brief Spi baud rate prescaler.
*/
enum class SpiBaudRatePrescaler
{
DIV_2,
DIV_4,
DIV_8,
DIV_16,
DIV_32,
DIV_64,
DIV_128,
DIV_256
}; };
@ -106,6 +105,9 @@ namespace sta
* @return SPI clock mode * @return SPI clock mode
*/ */
SpiMode getSpiMode(SpiClkPolarity polarity, SpiClkPhase phase); SpiMode getSpiMode(SpiClkPolarity polarity, SpiClkPhase phase);
/** @} */
} // namespace sta } // namespace sta

View File

@ -1,4 +1,4 @@
#include <sta/spi_device.hpp> #include <sta/spi/device.hpp>
#include <sta/assert.hpp> #include <sta/assert.hpp>

View File

@ -1,4 +1,4 @@
#include <sta/intf/spi_interface.hpp> #include <sta/spi/interface.hpp>
namespace sta namespace sta

View File

@ -1,4 +1,4 @@
#include <sta/spi_settings.hpp> #include <sta/spi/settings.hpp>
#include <sta/assert.hpp> #include <sta/assert.hpp>
#include <sta/lang.hpp> #include <sta/lang.hpp>