Update MCU-specific defines and includes

Distinguish properly between MCU series and actual MCUs. Constants in mcu.h
had to be changed to #defines to be useable from C code (not only C++).
This commit is contained in:
Martin Jäger
2020-08-25 17:46:48 +02:00
parent d274ca6980
commit f55b236a56
3 changed files with 19 additions and 18 deletions
+2 -2
View File
@@ -33,6 +33,7 @@ static struct device *dev_usb;
#include "hardware.h"
#include "leds.h"
#include "mcu.h"
// short circuit detection comparator only present in PWM 2420 LUS board so far
#ifdef CONFIG_BOARD_PWM_2420_LUS
@@ -181,11 +182,10 @@ void usb_out_set(bool status)
#if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), charge_pump))
#if defined(CONFIG_SOC_STM32G431XX)
#if defined(CONFIG_SOC_SERIES_STM32G4X)
#include <stm32g4xx_ll_tim.h>
#include <stm32g4xx_ll_rcc.h>
#include <stm32g4xx_ll_bus.h>
#include "stm32g431xx.h"
#endif
#define CP_PWM_PERIOD (DT_PHA(DT_CHILD(DT_PATH(outputs), charge_pump), pwms, period))
+14 -12
View File
@@ -7,39 +7,41 @@
#ifndef MCU_H_
#define MCU_H_
#ifdef CONFIG_SOC_SERIES_STM32F0X
#ifdef CONFIG_SOC_STM32F072XB
#include "stm32f072xb.h"
#endif
#ifdef CONFIG_SOC_SERIES_STM32L0X
#ifdef CONFIG_SOC_STM32L072XX
#include "stm32l072xx.h"
#endif
#ifdef CONFIG_SOC_SERIES_STM32G4X
#if defined(CONFIG_SOC_STM32G431XX)
#include "stm32g431xx.h"
#elif defined(CONFIG_SOC_STM32G474XX)
#include "stm32g474xx.h"
#endif
// factory calibration values for internal voltage reference and temperature sensor
// (see MCU datasheet, not Reference Manual)
#if defined(CONFIG_SOC_SERIES_STM32F0X)
const uint16_t VREFINT_CAL = *((uint16_t *)0x1FFFF7BA); // VREFINT @3.3V/30°C
#define 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 (*((uint16_t *)0x1FFFF7B8))
#define 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(CONFIG_SOC_SERIES_STM32L0X)
const uint16_t VREFINT_CAL = *((uint16_t *)0x1FF80078); // VREFINT @3.0V/25°C
#define 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 (*((uint16_t *)0x1FF8007A))
#define 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(CONFIG_SOC_SERIES_STM32G4X)
const uint16_t VREFINT_CAL = *((uint16_t *)0x1FFF75AA); // VREFINT @3.0V/30°C
#define VREFINT_CAL (*((uint16_t *)0x1FFF75AA)) // VREFINT @3.0V/30°C
#define VREFINT_VALUE 3000 // mV
const uint16_t TSENSE_CAL1 = *((uint16_t *)0x1FFF75A8);
const uint16_t TSENSE_CAL2 = *((uint16_t *)0x1FFF75CA);
#define TSENSE_CAL1 (*((uint16_t *)0x1FFF75A8))
#define TSENSE_CAL2 (*((uint16_t *)0x1FFF75CA))
#define TSENSE_CAL1_VALUE 30.0 // temperature of first calibration point
#define TSENSE_CAL2_VALUE 110.0 // temperature of second calibration point
#elif defined(UNIT_TEST)
+3 -4
View File
@@ -13,17 +13,16 @@
#include "daq.h"
#include "helper.h"
#include "mcu.h"
#if defined(CONFIG_SOC_STM32L072XX)
#if defined(CONFIG_SOC_SERIES_STM32L0X)
#include <stm32l0xx_ll_tim.h>
#include <stm32l0xx_ll_rcc.h>
#include <stm32l0xx_ll_bus.h>
#include "stm32l072xx.h"
#elif defined(CONFIG_SOC_STM32G431XX)
#elif defined(CONFIG_SOC_SERIES_STM32G4X)
#include <stm32g4xx_ll_tim.h>
#include <stm32g4xx_ll_rcc.h>
#include <stm32g4xx_ll_bus.h>
#include "stm32g431xx.h"
#endif
#if DT_NODE_EXISTS(DT_CHILD(DT_PATH(outputs), pwm_switch))