mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-10 00:36:00 +00:00
66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
#ifndef STA_CORE_STM32_MCU_TEMPLATE_HPP
|
|
#define STA_CORE_STM32_MCU_TEMPLATE_HPP
|
|
|
|
/**
|
|
* @defgroup sta_core_stm32_mcu STM32 MCUs
|
|
* @ingroup sta_core_stm32
|
|
*/
|
|
|
|
#ifndef STM32_YOUR_MCU_xx
|
|
# error "MCU config incompatible"
|
|
#endif // STM32_YOUR_MCU_xx
|
|
|
|
#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
|
|
|
|
// Aaaaaaand we're done!
|
|
|
|
#endif // STA_CORE_STM32_MCU_TEMPLATE_HPP
|