mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 16:55:58 +00:00
Major config cleanup and updated UART handle definition
This commit is contained in:
parent
1558821e72
commit
400b249fa3
@ -12,17 +12,24 @@
|
||||
# error "MCU config incompatible"
|
||||
#endif // STM32F407xx
|
||||
|
||||
// If the chip follows the ASEAG design use huart1.
|
||||
#if defined(STA_STM32_ASEAG) && !defined(STA_STM32_SWD_USART_IDX)
|
||||
# define STA_STM32_SWD_USART_IDX 1
|
||||
#endif
|
||||
|
||||
// The default UART handle for STM32 F407 Nucleos is huart2.
|
||||
#ifndef STA_STM32_SWD_USART_IDX
|
||||
# define STA_STM32_SWD_USART_IDX 2
|
||||
#endif // STA_STM32_SWD_USART_IDX
|
||||
|
||||
|
||||
// Initialize the default config for all STM32 microcontrollers.
|
||||
#include <sta/devices/stm32/mcu/common.hpp>
|
||||
|
||||
// uart/CAN setup
|
||||
|
||||
#ifdef STA_STM32_ASEAG
|
||||
# define STA_STM32_USART_HANDLE huart1
|
||||
# define STA_STM32_CAN_HANDLE hcan1
|
||||
#else
|
||||
# ifdef STA_STM32_SWD_USART_IDX
|
||||
# define STA_STM32_USART_HANDLE CONCAT(huart, STA_STM32_SWD_USART_IDX)
|
||||
# endif // STA_STM32_SWD_USART_IDX
|
||||
#endif // STA_STM32_SWD_USART_IDX
|
||||
# define STA_STM32_CAN_HANDLE hcan1
|
||||
#endif // STA_STM32_ASEAG
|
||||
|
||||
/**
|
||||
* @ingroup sta_core_stm32_mcu_stm32f407xx
|
||||
|
@ -16,18 +16,21 @@
|
||||
#endif // !STM32F411xE
|
||||
|
||||
|
||||
#include <sta/devices/stm32/mcu/common.hpp>
|
||||
// If the chip follows the ASEAG design use huart1.
|
||||
#if defined(STA_STM32_ASEAG) && !defined(STA_STM32_SWD_USART_IDX)
|
||||
# define STA_STM32_SWD_USART_IDX 1
|
||||
#endif
|
||||
|
||||
// uart setup
|
||||
#ifdef STA_STM32_ASEAG
|
||||
# define STA_STM32_USART_HANDLE huart1
|
||||
#else
|
||||
# ifdef STA_STM32_SWD_USART_IDX
|
||||
# define STA_STM32_USART_HANDLE huart2
|
||||
# endif // STA_STM32_SWD_USART_IDX
|
||||
// The default UART handle for STM32 F411 Nucleos is huart2.
|
||||
#ifndef STA_STM32_SWD_USART_IDX
|
||||
# define STA_STM32_SWD_USART_IDX 2
|
||||
#endif // STA_STM32_SWD_USART_IDX
|
||||
|
||||
|
||||
// Initialize the default config for all STM32 microcontrollers.
|
||||
#include <sta/devices/stm32/mcu/common.hpp>
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup sta_core_stm32_mcu_stm32f411xe
|
||||
* @{
|
||||
|
69
include/sta/devices/stm32/mcu/STM32U5xx.hpp
Normal file
69
include/sta/devices/stm32/mcu/STM32U5xx.hpp
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @defgroup sta_core_stm32_mcu STM32 MCUs
|
||||
* @ingroup sta_core_stm32
|
||||
*/
|
||||
|
||||
#ifndef STA_CORE_STM32_MCU_STM32U5A5_HPP
|
||||
#define STA_CORE_STM32_MCU_STM32U5A5_HPP
|
||||
|
||||
#ifndef STM32_U5xx
|
||||
# error "MCU config incompatible"
|
||||
#endif // STM32_YOUR_MCU_xx
|
||||
|
||||
// Add the default uart index for Nucleos using this chip here.
|
||||
#ifndef STA_STM32_SWD_USART_IDX
|
||||
# define STA_STM32_SWD_USART_IDX 2
|
||||
#endif // STA_STM32_SWD_USART_IDX
|
||||
|
||||
#include <sta/devices/stm32/mcu/common.hpp>
|
||||
|
||||
// Peripheral clock mappings
|
||||
//
|
||||
|
||||
// TIM to PCLK
|
||||
/**
|
||||
* Look up the datasheet for the MCU you are using. There you will find a functional
|
||||
* diagram, where all timers (e.g. "TIM1") are displayed. They are all connected to a
|
||||
* "Advanced Peripheral Bus" (APB). Since there are multiple of them (e.g. APB1 and APB2),
|
||||
* you have to map each timer to the APB it is connected to:
|
||||
*/
|
||||
#define STA_STM32_TIM_1_PCLK_IDX 1
|
||||
// ...
|
||||
|
||||
// SPI to PCLK
|
||||
// Do the same for SPI...
|
||||
#define STA_STM32_SPI_1_PCLK_IDX 2
|
||||
|
||||
// I2C to PCLK
|
||||
// Do the same for I2C...
|
||||
#define STA_STM32_I2C_1_PCLK_IDX 1
|
||||
|
||||
// USART to PCLK
|
||||
// Do the same for USART...
|
||||
#define STA_STM32_USART_1_PCLK_IDX 2
|
||||
|
||||
|
||||
// HAL handle mappings
|
||||
//
|
||||
|
||||
// TIM to PCLK#
|
||||
/**
|
||||
* This section is straightforward. We only map the handles of the different timers
|
||||
* to the corresponding indices we defined before. For example "htim1" is the handle
|
||||
* for TIM1 which means that we need the following mapping:
|
||||
*/
|
||||
#define STA_STM32_htim1_PCLK_IDX STA_STM32_TIM_1_PCLK_IDX
|
||||
|
||||
// SPI to PCLK
|
||||
// Do the same for SPI...
|
||||
#define STA_STM32_hspi1_PCLK_IDX STA_STM32_SPI_1_PCLK_IDX
|
||||
|
||||
// I2C to PCLK
|
||||
// Do the same for I2C...
|
||||
#define STA_STM32_hi2c1_PCLK_IDX STA_STM32_I2C_1_PCLK_IDX
|
||||
|
||||
// USART to PCLK
|
||||
// Do the same for USART...
|
||||
#define STA_STM32_husart1_PCLK_IDX STA_STM32_USART_1_PCLK_IDX
|
||||
|
||||
#endif // STA_CORE_STM32_MCU_STM32U5A5_HPP
|
@ -5,6 +5,8 @@
|
||||
#ifndef STA_CORE_STM32_MCU_COMMON_HPP
|
||||
#define STA_CORE_STM32_MCU_COMMON_HPP
|
||||
|
||||
#include <sta/lang.hpp>
|
||||
|
||||
|
||||
// TODO: Are all STM32 MCUs little endian?
|
||||
#define STA_MCU_LITTLE_ENDIAN
|
||||
@ -14,4 +16,10 @@
|
||||
#define STA_PLATFORM_STM32
|
||||
|
||||
|
||||
// Define the USART handle based on the provided USART idx.
|
||||
#ifdef STA_STM32_SWD_USART_IDX
|
||||
# define STA_STM32_USART_HANDLE STA_CONCAT(huart, STA_STM32_SWD_USART_IDX)
|
||||
#endif // STA_STM32_SWD_USART_IDX
|
||||
|
||||
|
||||
#endif // STA_CORE_STM32_MCU_COMMON_HPP
|
||||
|
@ -10,6 +10,11 @@
|
||||
# error "MCU config incompatible"
|
||||
#endif // STM32_YOUR_MCU_xx
|
||||
|
||||
// Add the default uart index for Nucleos using this chip here.
|
||||
#ifndef STA_STM32_SWD_USART_IDX
|
||||
# define STA_STM32_SWD_USART_IDX 2
|
||||
#endif // STA_STM32_SWD_USART_IDX
|
||||
|
||||
#include <sta/devices/stm32/mcu/common.hpp>
|
||||
|
||||
// Peripheral clock mappings
|
||||
@ -63,4 +68,4 @@
|
||||
|
||||
// Aaaaaaand we're done!
|
||||
|
||||
#endif // STA_CORE_STM32_MCU_TEMPLATE_HPP
|
||||
#endif // STA_CORE_STM32_MCU_TEMPLATE_HPP
|
||||
|
@ -122,6 +122,26 @@
|
||||
#endif // !STA_FALLTRHOUGH
|
||||
|
||||
|
||||
/**
|
||||
* @brief A macro for concatenating preprocessor tokens A and B without expanding them.
|
||||
* @param A first preprocessor token.
|
||||
* @param B second preprocessor token.
|
||||
*/
|
||||
#ifndef STA_CONCAT_NX
|
||||
# define STA_CONCAT_NX(A, B) A ## B
|
||||
#endif // !STA_CONCAT_NX
|
||||
|
||||
|
||||
/**
|
||||
* @brief Macro-expands A and B first and concatenates them afterwards.
|
||||
* @param A first preprocessor token.
|
||||
* @param B second preprocessor token.
|
||||
*/
|
||||
#ifndef STA_CONCAT
|
||||
# define STA_CONCAT(A, B) STA_CONCAT_NX(A, B)
|
||||
#endif // !STA_CONCAT
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // STA_CORE_LANG_HPP
|
||||
|
@ -3,7 +3,6 @@
|
||||
* @brief Compatibility layer for different printf implementations.
|
||||
*
|
||||
* Configuration:
|
||||
* * STA_PRINTF_USE_STDLIB: Use printf implementation from standard library
|
||||
* * STA_PRINTF_USE_MPALAND: Use printf implementation from Marco Paland
|
||||
*/
|
||||
#ifndef STA_CORE_PRINTF_HPP
|
||||
@ -11,16 +10,11 @@
|
||||
|
||||
#include <sta/config.hpp>
|
||||
|
||||
#if !defined(STA_PRINTF_USE_STDLIB) && !defined(STA_PRINTF_USE_MPALAND)
|
||||
# error "No printf implementation chosen!"
|
||||
#endif // !STA_PRINTF_USE_STDLIB && !STA_PRINTF_USE_MPALAND
|
||||
|
||||
|
||||
#ifdef STA_PRINTF_USE_STDLIB
|
||||
# include <cstdio>
|
||||
#endif // STA_PRINTF_USE_STDLIB
|
||||
#ifdef STA_PRINTF_USE_MPALAND
|
||||
# include <printf.h>
|
||||
#else
|
||||
# include <cstdio>
|
||||
#endif // STA_PRINTF_USE_MPALAND
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user