Update description and debug serial usage

This commit is contained in:
Henrik Stickann 2022-04-12 16:08:00 +02:00
parent b50cf07ce9
commit 9f2c73c9ab
2 changed files with 13 additions and 15 deletions

View File

@ -1,10 +1,10 @@
/** /**
* @brief Implementation for UART using HAL. * @brief Implementation of UART using HAL.
* *
* Define STA_HAL_UART_ENABLE in <sta/config.hpp> to enable. * Define **STA_HAL_UART_ENABLE** in `<sta/config.hpp>` to enable module.
* *
* To enable the global DebugSerial instance (example using UART1) define: * To use a HAL UART instance (e.g. UART1) for `<sta/debug_serial.hpp>` define:
* #define STA_HAL_UART_DEBUG huart1 * #define STA_HAL_UART_DEBUG_SERIAL huart1
*/ */
#ifndef STA_HAL_UART_HPP #ifndef STA_HAL_UART_HPP
#define STA_HAL_UART_HPP #define STA_HAL_UART_HPP
@ -37,14 +37,6 @@ namespace sta
private: private:
UART_HandleTypeDef * handle_; /**< UART handle */ UART_HandleTypeDef * handle_; /**< UART handle */
}; };
#ifdef STA_HAL_UART_DEBUG
/**
* @brief Global UART instance for debug output.
*/
extern HalUART DebugSerial;
#endif // STA_HAL_UART_DEBUG
} // namespace sta } // namespace sta

View File

@ -17,16 +17,22 @@ namespace sta
} // namespace sta } // namespace sta
#ifdef STA_HAL_UART_DEBUG #ifdef STA_HAL_UART_DEBUG_SERIAL
// Get extern declaration for DebugSerial because const namespace level variables have internal linkage by default
#include <sta/debug_serial.hpp>
#include <usart.h> #include <usart.h>
namespace sta namespace sta
{ {
HalUART DebugSerial(&STA_HAL_UART_DEBUG); HalUART gHalDebugSerial(&STA_HAL_UART_DEBUG_SERIAL);
// Used by <sta/debug.hpp>
UART * const DebugSerial = &gHalDebugSerial;
} // namespace sta } // namespace sta
#endif // STA_HAL_UART_DEBUG #endif // STA_HAL_UART_DEBUG_SERIAL
#endif // STA_HAL_UART_ENABLE #endif // STA_HAL_UART_ENABLE