First reworks for debugging

This commit is contained in:
dvdb97
2023-07-12 13:33:34 +02:00
parent e7ddbbf365
commit 96d94edc52
15 changed files with 125 additions and 126 deletions

View File

@@ -5,6 +5,8 @@
namespace sta
{
enum class UARTMode
{
RX,

View File

@@ -9,7 +9,7 @@ namespace sta
class UART : public Interface
{
public:
UART(const UARTSettings & settings, Mutex * mutex=nullptr);
UART(Mutex * mutex=nullptr);
/**
* @brief Get %UART interface settings.
@@ -22,4 +22,4 @@ namespace sta
};
} // namespace sta
#endif // STA_CORE_UART_UART_HPP
#endif // STA_CORE_UART_UART_HPP

40
include/sta/debugging.hpp Normal file
View File

@@ -0,0 +1,40 @@
#ifndef STA_CORE_DEBUGGING_HPP
#define STA_CORE_DEBUGGING_HPP
#include <sta/config.hpp>
#ifdef STA_DEBUGGING_ENABLED
#include <sta/printable.hpp>
namespace sta
{
extern Printable * Debug;
} // namespace sta
/**
* @brief Debug print message.
*
* @param ... See @ref sta::PrintableUART::print
*
* @ingroup sta_core_debug
*/
# define STA_DEBUG_PRINT(...) sta::Debug->print(__VA_ARGS__)
/**
* @brief Debug print message followed by new-line to UART.
*
* @param ... See @ref sta::PrintableUART::println
*
* @ingroup sta_core_debug
*/
# define STA_DEBUG_PRINTLN(...) sta::Debug->println(__VA_ARGS__)
#else // !STA_DEBUGGING_ENABLED
# define STA_DEBUG_PRINT(...) ((void)0)
# define STA_DEBUG_PRINTLN(...) ((void)0)
#endif // STA_DEBUGGING_ENABLED
#endif // STA_CORE_DEBUGGING_HPP

View File

@@ -35,7 +35,8 @@ namespace sta
class STM32I2CDevice : public I2CDevice
{
STM32I2CDevice();
public:
STM32I2CDevice(STM32I2C * intf, int address, bool master=true, bool blocking=true);
};
}

View File

@@ -18,7 +18,7 @@
#if defined(STA_STM32_UART_ENABLED) || defined(DOXYGEN)
#include <sta/uart.hpp>
#include <sta/bus/uart/uart.hpp>
/**
@@ -41,10 +41,15 @@ namespace sta
/**
* @param handle STM32 HAL handle
*/
STM32UART(UART_HandleTypeDef * handle);
STM32UART(UART_HandleTypeDef * handle, Mutex * mutex);
void write(const uint8_t * buffer, size_t size) override;
void transfer(uint8_t value) override;
void transfer16(uint16_t value) override;
void transfer(const uint8_t * buffer, size_t size) override;
void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) override;
void receive(uint8_t * buffer, size_t size) override;
void fill(uint8_t value, size_t count) override;
private:
UART_HandleTypeDef * handle_; /**< STM32 HAL handle */
};

View File

@@ -25,6 +25,7 @@ namespace sta
class Printable
{
public:
/**
* @brief Print single character.
*
@@ -188,4 +189,4 @@ namespace sta
} // namespace sta
#endif // STA_CORE_PRINTABLE_HPP
#endif // STA_CORE_PRINTABLE_HPP

View File

@@ -1,61 +0,0 @@
/**
* @file
* @brief UART interface definition.
*/
#ifndef STA_CORE_UART_HPP
#define STA_CORE_UART_HPP
#include <cstddef>
#include <cstdint>
/**
* @defgroup sta_core_uart UART
* @ingroup sta_core
* @brief UART interface.
*/
namespace sta
{
/**
* @brief Interface for %UART.
*
* @ingroup sta_core_uart
*/
class UART
{
public:
/**
* @brief Write buffer to %UART.
*
* @param buffer Source buffer
* @param size Number of bytes in buffer
*/
virtual void write(const uint8_t * buffer, size_t size) = 0;
/**
* @brief Write unsigned integer to %UART.
*
* @param value Unsigned integer value
*/
void write(uint8_t value);
/**
* @brief Write unsigned integer to %UART.
*
* @param value Unsigned integer value
*/
void write(uint16_t value);
/**
* @brief Write unsigned integer to %UART.
*
* @param value Unsigned integer value
*/
void write(uint32_t value);
};
} // namespace sta
#endif // STA_CORE_UART_HPP