Improve doxygen comments

This commit is contained in:
Henrik Stickann 2022-04-24 13:43:44 +02:00
parent e7d246a2e7
commit a24aa1c5c6
10 changed files with 77 additions and 52 deletions

View File

@ -1,7 +1,8 @@
/**
* @brief Atomic mutex implementation.
*
* Define **STA_ATOMIC_ENABLE** to enable module.
* Configuration:
* STA_ATOMIC_ENABLE: Enable module
*/
#ifndef STA_ATOMIC_MUTEX_HPP
#define STA_ATOMIC_MUTEX_HPP

View File

@ -1,7 +1,8 @@
/**
* @brief Atomic signal implementation.
*
* Define **STA_ATOMIC_ENABLE** to enable module.
* Configuration:
* STA_ATOMIC_ENABLE: Enable module
*/
#ifndef STA_ATOMIC_SIGNAL_HPP
#define STA_ATOMIC_SIGNAL_HPP

View File

@ -1,7 +1,8 @@
/**
* @brief Wrapper for HAL GPIO pins.
*
* Define **STA_HAL_GPIO_ENABLE** in `<sta/config.hpp>` to enable module.
* Configuration:
* STA_HAL_GPIO_ENABLE: Enable module
*/
#ifndef STA_HAL_GPIO_PIN_HPP
#define STA_HAL_GPIO_PIN_HPP
@ -10,8 +11,7 @@
#ifdef STA_HAL_GPIO_ENABLE
#include <sta/gpio_pin.hpp>
#include <main.h>
#include <sta/hal.hpp>
namespace sta

View File

@ -1,9 +1,10 @@
/**
* @brief Implementations for `SpiInterface` and `SpiDevice` using HAL.
*
* Define **STA_HAL_SPI_ENABLE** in `<sta/config.hpp>` to enable module.
* Configuration:
* STA_HAL_SPI_ENABLE: Enable module
*
* Requires **STA_HAL_GPIO_ENABLE**.
* Requires **HAL_GPIO** module.
*/
#ifndef STA_HAL_SPI_HPP
#define STA_HAL_SPI_HPP
@ -15,11 +16,11 @@
#error "HAL GPIO required"
#endif // !STA_HAL_GPIO_ENABLE
#include <sta/hal.hpp>
#include <sta/spi_device.hpp>
#include <sta/hal/clocks.hpp>
#include <sta/hal/gpio_pin.hpp>
#include <main.h>
namespace sta
{
@ -88,36 +89,18 @@ namespace sta
} // namespace sta
/**
* @brief Get function returning PCLK frequency.
* @brief Get SPI interface info struct for HAL handle.
*
* @param n Index of peripheral clock
*/
#define STA_HAL_GET_PCLK_FREQ_FN(n) HAL_RCC_GetPCLK ## n ## Freq
/**
* @brief Get SPI interface info struct.
* Requires STA_HAL_<handle>_PCLK_IDX to be defined for the MCU.
* MCU mappings are found in `core` -> sta/mcu/.hpp files.
*
* Check the MCUs Reference Manual RCC register documentation to see which
* peripheral clock is used.
*
* @param n Index of SPI interface (e.g. 2 for SPI2)
* @param pclk Index of peripheral clock used by SPI interface
* @param handle SPI interface handle
*/
#define STA_HAL_SPI_INFO_MANUAL(n, pclk) sta::HalSpiInterfaceInfo{&hspi ## n, STA_HAL_GET_PCLK_FREQ_FN(pclk)}
/**
* @brief Get SPI interface info struct.
*
* Requires STA_HAL_SPI_n_PCLK_IDX set to idx of PCLK used by the interface.
*
* Check the MCUs Reference Manual RCC register documentation to see which
* peripheral clock is used.
*
* @param n Index of SPI interface (e.g. 2 for SPI2)
*/
#define STA_HAL_SPI_INFO(n) STA_HAL_SPI_INFO_MANUAL(n, STA_HAL_SPI_ ## n ## _PCLK_IDX)
#define STA_HAL_SPI_INFO(handle) sta::HalSpiInterfaceInfo{&handle, STA_HAL_GET_HANDLE_PCLK_FREQ_FN(handle)}
#endif // STA_HAL_SPI_ENABLE

View File

@ -1,10 +1,9 @@
/**
* @brief Implementation of UART using HAL.
*
* Define **STA_HAL_UART_ENABLE** in `<sta/config.hpp>` to enable module.
*
* To use a HAL UART instance (e.g. UART1) for `<sta/debug_serial.hpp>` define:
* #define STA_HAL_UART_DEBUG_SERIAL huart1
* Configuration:
* STA_HAL_UART_ENABLE: Enable module
* STA_HAL_UART_DEBUG_SERIAL: Create global `sta::DebugSerial` object using this UART instance
*/
#ifndef STA_HAL_UART_HPP
#define STA_HAL_UART_HPP
@ -12,10 +11,9 @@
#include <sta/config.hpp>
#ifdef STA_HAL_UART_ENABLE
#include <sta/hal.hpp>
#include <sta/uart.hpp>
#include <main.h>
namespace sta
{

View File

@ -6,8 +6,8 @@
#include <sta/spi_interface.hpp>
#include <stdint.h>
#include <stddef.h>
#include <cstdint>
#include <cstddef>
namespace sta

View File

@ -7,8 +7,8 @@
#include <sta/mutex.hpp>
#include <sta/spi_settings.hpp>
#include <stdint.h>
#include <stddef.h>
#include <cstdint>
#include <cstddef>
namespace sta

View File

@ -1,3 +1,6 @@
/**
* @brief SPI setting types.
*/
#ifndef STA_SPI_SETTINGS_HPP
#define STA_SPI_SETTINGS_HPP
@ -6,18 +9,27 @@
namespace sta
{
/**
* @brief SPI clock polarity.
*/
enum class SpiClkPolarity
{
LOW,
HIGH
};
/**
* @brief SPI clock phase.
*/
enum class SpiClkPhase
{
EDGE_1,
EDGE_2
};
/**
* @brief SPI clock mode.
*/
enum class SpiMode
{
MODE_0,
@ -26,18 +38,27 @@ namespace sta
MODE_3
};
/**
* @brief SPI data size.
*/
enum class SpiDataSize
{
SIZE_8,
SIZE_16
};
/**
* @brief SPI bit order.
*/
enum class SpiBitOrder
{
MSB,
LSB
};
/**
* @brief Spi baud rate prescaler.
*/
enum class SpiBaudRatePrescaler
{
DIV_2,
@ -51,17 +72,39 @@ namespace sta
};
/**
* @brief SPI settings.
*/
struct SpiSettings
{
SpiMode mode;
SpiDataSize dataSize;
SpiBitOrder bitOrder;
uint32_t clkSpeed;
SpiMode mode; /**< SPI clock mode */
SpiDataSize dataSize; /**< SPI data size */
SpiBitOrder bitOrder; /**< SPI bit order */
uint32_t clkSpeed; /**< SPI clock speed */
};
/**
* @brief Get SPI clock polarity from clock mode.
*
* @param mode SPI clock mode
* @return SPI clock polarity
*/
SpiClkPolarity getSpiClkPolarity(SpiMode mode);
/**
* @brief Get SPI clock phase from clock mode.
*
* @param mode SPI clock mode
* @return SPI clock phase
*/
SpiClkPhase getSpiClkPhase(SpiMode mode);
/**
* @brief Get SPI clock mode from clock phase and polarity.
*
* @param polarity SPI clock polarity
* @param phase SPI clock phase
* @return SPI clock mode
*/
SpiMode getSpiMode(SpiClkPolarity polarity, SpiClkPhase phase);
} // namespace sta

View File

@ -4,8 +4,8 @@
#ifndef STA_UART_HPP
#define STA_UART_HPP
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
namespace sta

View File

@ -1,10 +1,9 @@
#include <sta/uart.hpp>
//#include <cstdio>
#include <sta/printf.hpp>
#include <cstring>
// Include last so macros don't mess with other headers
#include <printf.h>
namespace sta
@ -143,7 +142,7 @@ namespace sta
void UART::printDec(uintmax_t num, const char * fmt)
{
char buffer[64];
sprintf(buffer, fmt, num);
snprintf(buffer, sizeof(buffer), fmt, num);
print(buffer);
}