mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-05 18:21:54 +00:00
First reworks for debugging
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
namespace sta
|
||||
{
|
||||
|
||||
|
||||
enum class UARTMode
|
||||
{
|
||||
RX,
|
||||
|
@@ -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
40
include/sta/debugging.hpp
Normal 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
|
@@ -35,7 +35,8 @@ namespace sta
|
||||
|
||||
class STM32I2CDevice : public I2CDevice
|
||||
{
|
||||
STM32I2CDevice();
|
||||
public:
|
||||
STM32I2CDevice(STM32I2C * intf, int address, bool master=true, bool blocking=true);
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -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 */
|
||||
};
|
@@ -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
|
||||
|
@@ -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
|
Reference in New Issue
Block a user