Replace short STM32XXX defines with CONFIG_SOC_...

This commit is contained in:
Martin Jäger
2020-05-06 12:53:26 +02:00
parent c856b28082
commit 9f258b6e69
4 changed files with 23 additions and 40 deletions
+2 -2
View File
@@ -71,10 +71,10 @@ enum {
ADC_POS_TEMP_FETS, // ADC 5 (PA_5)
ADC_POS_I_LOAD, // ADC 6 (PA_6)
ADC_POS_I_DCDC, // ADC 7 (PA_7)
#if defined(STM32F0) || defined(CONFIG_SOC_SERIES_STM32F0X)
#if defined(CONFIG_SOC_SERIES_STM32F0X)
ADC_POS_TEMP_MCU, // ADC 16
ADC_POS_VREF_MCU, // ADC 17
#elif defined(STM32L0) || defined(CONFIG_SOC_SERIES_STM32L0X)
#elif defined(CONFIG_SOC_SERIES_STM32L0X)
ADC_POS_VREF_MCU, // ADC 17
ADC_POS_TEMP_MCU, // ADC 18
#endif
+9 -9
View File
@@ -18,7 +18,7 @@ static uint8_t _deadtime_clocks;
static bool _enabled;
#if defined(STM32L0)
#if defined(CONFIG_SOC_SERIES_STM32L0X)
class PWM_TIM3
{
@@ -100,7 +100,7 @@ class PWM_TIM3
}
};
#elif defined(STM32F0) || defined(STM32G4)
#elif defined(CONFIG_SOC_SERIES_STM32F0X) || defined(CONFIG_SOC_SERIES_STM32G4X)
class PWM_TIM1
{
@@ -109,9 +109,9 @@ class PWM_TIM1
static void _init_registers(uint32_t pwm_resolution)
{
// Enable peripheral clock of GPIOA and GPIOB
#ifdef STM32F0
#ifdef CONFIG_SOC_SERIES_STM32F0X
RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
#else // STM32G4
#else // CONFIG_SOC_SERIES_STM32G4X
RCC->AHB2ENR |= RCC_AHB2ENR_GPIOAEN | RCC_AHB2ENR_GPIOBEN;
#endif
@@ -122,10 +122,10 @@ class PWM_TIM1
GPIOB->MODER = (GPIOB->MODER & ~(GPIO_MODER_MODER13)) | GPIO_MODER_MODER13_1;
// Select AF2 on PA8 (TIM1_CH1) and PB13 (TIM1_CH1N)
#ifdef STM32F0
#ifdef CONFIG_SOC_SERIES_STM32F0X
GPIOA->AFR[1] |= 0x2 << GPIO_AFRH_AFSEL8_Pos;
GPIOB->AFR[1] |= 0x2 << GPIO_AFRH_AFSEL13_Pos;
#else // STM32G4
#else // CONFIG_SOC_SERIES_STM32G4X
GPIOA->AFR[1] |= 0x6 << GPIO_AFRH_AFSEL8_Pos;
GPIOB->AFR[1] |= 0x6 << GPIO_AFRH_AFSEL13_Pos;
#endif
@@ -153,7 +153,7 @@ class PWM_TIM1
// OIS1 = OIS1N = 0: Output Idle State is set to off
//TIM1->CR2 |= ;
#ifdef STM32G4
#ifdef CONFIG_SOC_SERIES_STM32G4X
// Boards with STM32G4 MCU use ADC2 for synchronized ADC sampling. We use OC2
// for triggering, but but don't configure any pin for PWM mode
TIM1->CCMR1 |= TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2PE;
@@ -253,9 +253,9 @@ uint32_t PWM_UT::m_ccr = 0;
#endif /* UNIT_TEST */
#if defined(STM32F0) || defined(STM32G4)
#if defined(CONFIG_SOC_SERIES_STM32F0X) || defined(CONFIG_SOC_SERIES_STM32G4X)
typedef PWM_TIM1 PWM_TIM_HW;
#elif defined(STM32L0)
#elif defined(CONFIG_SOC_SERIES_STM32L0X)
typedef PWM_TIM3 PWM_TIM_HW;
#else
typedef PWM_UT PWM_TIM_HW;
+3 -3
View File
@@ -13,10 +13,10 @@
#include "leds.h"
#include "setup.h"
#if defined(STM32F0)
#if defined(CONFIG_SOC_SERIES_STM32F0X)
#define SYS_MEM_START 0x1FFFC800
#define SRAM_END 0x20003FFF // 16k
#elif defined(STM32L0)
#elif defined(CONFIG_SOC_SERIES_STM32L0X)
#define SYS_MEM_START 0x1FF00000
#define SRAM_END 0X20004FFF // 20k
#define FLASH_LAST_PAGE 0x0802FF80 // start address of last page (192 kbyte cat 5 devices)
@@ -73,7 +73,7 @@ void start_stm32_bootloader()
k_sleep(100); // wait for capacitor at BOOT0 pin to charge up
reset_device();
#elif defined (STM32F0)
#elif defined (CONFIG_SOC_SERIES_STM32F0X)
// place magic code at end of RAM and initiate reset
*((uint32_t *)(MAGIC_CODE_ADDR)) = 0xDEADBEEF;
reset_device();
+9 -26
View File
@@ -7,52 +7,35 @@
#ifndef MCU_H_
#define MCU_H_
// mbed defines STM32Fxx variables automatically, so we define them also for Zephyr
#ifdef CONFIG_SOC_STM32L072XX
#define STM32L0
#define STM32L072
#endif
#ifdef CONFIG_SOC_STM32F072XB
#define STM32F0
#define STM32F072
#endif
#ifdef CONFIG_SOC_STM32G431XX
#define STM32G4
#define STM32G431
#endif
#ifdef STM32L072
#include "stm32l072xx.h"
#endif
#ifdef STM32F072
#ifdef CONFIG_SOC_SERIES_STM32F0X
#include "stm32f072xb.h"
#endif
#ifdef STM32G431
#ifdef CONFIG_SOC_SERIES_STM32L0X
#include "stm32l072xx.h"
#endif
#ifdef CONFIG_SOC_SERIES_STM32G4X
#include "stm32g431xx.h"
#endif
// factory calibration values for internal voltage reference and temperature sensor
// (see MCU datasheet, not Reference Manual)
#if defined(STM32F0)
#if defined(CONFIG_SOC_SERIES_STM32F0X)
const uint16_t VREFINT_CAL = *((uint16_t *)0x1FFFF7BA); // VREFINT @3.3V/30°C
#define VREFINT_VALUE 3300 // mV
const uint16_t TSENSE_CAL1 = *((uint16_t *)0x1FFFF7B8);
const uint16_t TSENSE_CAL2 = *((uint16_t *)0x1FFFF7C2);
#define TSENSE_CAL1_VALUE 30.0 // temperature of first calibration point
#define TSENSE_CAL2_VALUE 110.0 // temperature of second calibration point
#elif defined(STM32L0)
#elif defined(CONFIG_SOC_SERIES_STM32L0X)
const uint16_t VREFINT_CAL = *((uint16_t *)0x1FF80078); // VREFINT @3.0V/25°C
#define VREFINT_VALUE 3000 // mV
const uint16_t TSENSE_CAL1 = *((uint16_t *)0x1FF8007A);
const uint16_t TSENSE_CAL2 = *((uint16_t *)0x1FF8007E);
#define TSENSE_CAL1_VALUE 30.0 // temperature of first calibration point
#define TSENSE_CAL2_VALUE 130.0 // temperature of second calibration point
#elif defined(STM32G4)
#elif defined(CONFIG_SOC_SERIES_STM32G4X)
const uint16_t VREFINT_CAL = *((uint16_t *)0x1FFF75AA); // VREFINT @3.0V/30°C
#define VREFINT_VALUE 3000 // mV
const uint16_t TSENSE_CAL1 = *((uint16_t *)0x1FFF75A8);