From 331aedd84e6ee3bb4c53a1b238bdc04712116327 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Thu, 6 Nov 2014 21:59:28 +0100 Subject: [PATCH] [ext][stm32] update libopencm3 to get updates from libopencm3 and remove our own workarounds for: - STM32F4 25Mhz clock: https://github.com/libopencm3/libopencm3/pull/311 - STM32 defines for TIM9-TIM17: https://github.com/libopencm3/libopencm3/pull/350 - STM32 set I2C address: https://github.com/libopencm3/libopencm3/pull/344 additionally get fixes: - STM32 safe gpio toggle: https://github.com/libopencm3/libopencm3/pull/337 --- sw/airborne/arch/stm32/mcu_arch.c | 19 +---------------- sw/airborne/arch/stm32/mcu_arch.h | 9 -------- sw/airborne/arch/stm32/mcu_periph/i2c_arch.c | 21 +++---------------- .../actuators/actuators_shared_arch.c | 5 +++-- sw/ext/libopencm3 | 2 +- 5 files changed, 8 insertions(+), 48 deletions(-) diff --git a/sw/airborne/arch/stm32/mcu_arch.c b/sw/airborne/arch/stm32/mcu_arch.c index 717696224f..718f61cf51 100644 --- a/sw/airborne/arch/stm32/mcu_arch.c +++ b/sw/airborne/arch/stm32/mcu_arch.c @@ -39,23 +39,6 @@ #include "std.h" -#if defined(STM32F4) -/** 25MHz external clock to PLL it to 168MHz */ -const clock_scale_t hse_25mhz_3v3_168mhz = { /* 168MHz */ - .pllm = 25, - .plln = 336, - .pllp = 2, - .pllq = 7, - .hpre = RCC_CFGR_HPRE_DIV_NONE, - .ppre1 = RCC_CFGR_PPRE_DIV_4, - .ppre2 = RCC_CFGR_PPRE_DIV_2, - .flash_config = FLASH_ACR_ICE | FLASH_ACR_DCE | - FLASH_ACR_LATENCY_5WS, - .apb1_frequency = 42000000, - .apb2_frequency = 84000000, -}; -#endif - void mcu_arch_init(void) { #if LUFTBOOT PRINT_CONFIG_MSG("We are running luftboot, the interrupt vector is being relocated.") @@ -85,7 +68,7 @@ PRINT_CONFIG_MSG("Using 16MHz external clock to PLL it to 168MHz.") #elif EXT_CLK == 25000000 #if defined(STM32F4) PRINT_CONFIG_MSG("Using 25MHz external clock to PLL it to 168MHz.") - rcc_clock_setup_hse_3v3(&hse_25mhz_3v3_168mhz); + rcc_clock_setup_hse_3v3(&hse_25mhz_3v3[CLOCK_3V3_168MHZ]); #endif #else #error EXT_CLK is either set to an unsupported frequency or not defined at all. Please check! diff --git a/sw/airborne/arch/stm32/mcu_arch.h b/sw/airborne/arch/stm32/mcu_arch.h index 04d42da3ec..37fffacc69 100644 --- a/sw/airborne/arch/stm32/mcu_arch.h +++ b/sw/airborne/arch/stm32/mcu_arch.h @@ -31,7 +31,6 @@ #define STM32_MCU_ARCH_H #include "std.h" -#include extern void mcu_arch_init(void); @@ -50,14 +49,6 @@ extern void mcu_arch_init(void); #define mcu_int_enable() {} #define mcu_int_disable() {} -/** @todo: these should go into libopencm3 */ -#ifdef TIM9_BASE -#define TIM9 TIM9_BASE -#endif -#ifdef TIM12_BASE -#define TIM12 TIM12_BASE -#endif - uint32_t timer_get_frequency(uint32_t timer_peripheral); #endif /* STM32_MCU_ARCH_H */ diff --git a/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c b/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c index 127754030b..cec1349723 100644 --- a/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c +++ b/sw/airborne/arch/stm32/mcu_periph/i2c_arch.c @@ -1003,12 +1003,7 @@ void i2c1_hw_init(void) { // enable peripheral i2c_peripheral_enable(I2C1); - /* - * XXX: there is a function to do that already in libopencm3 but I am not - * sure if it is correct, using direct register instead (esden) - */ - //i2c_set_own_7bit_slave_address(I2C1, 0); - I2C_OAR1(I2C1) = 0 | 0x4000; + i2c_set_own_7bit_slave_address(I2C1, 0); // enable error interrupts i2c_enable_interrupt(I2C1, I2C_CR2_ITERREN); @@ -1078,12 +1073,7 @@ void i2c2_hw_init(void) { // enable peripheral i2c_peripheral_enable(I2C2); - /* - * XXX: there is a function to do that already in libopencm3 but I am not - * sure if it is correct, using direct register instead (esden) - */ - //i2c_set_own_7bit_slave_address(I2C2, 0); - I2C_OAR1(I2C2) = 0 | 0x4000; + i2c_set_own_7bit_slave_address(I2C2, 0); // enable error interrupts i2c_enable_interrupt(I2C2, I2C_CR2_ITERREN); @@ -1153,12 +1143,7 @@ void i2c3_hw_init(void) { // enable peripheral i2c_peripheral_enable(I2C3); - /* - * XXX: there is a function to do that already in libopencm3 but I am not - * sure if it is correct, using direct register instead (esden) - */ - //i2c_set_own_7bit_slave_address(I2C3, 0); - I2C_OAR1(I2C3) = 0 | 0x4000; + i2c_set_own_7bit_slave_address(I2C3, 0); // enable error interrupts i2c_enable_interrupt(I2C3, I2C_CR2_ITERREN); diff --git a/sw/airborne/arch/stm32/subsystems/actuators/actuators_shared_arch.c b/sw/airborne/arch/stm32/subsystems/actuators/actuators_shared_arch.c index 42e15146e0..a7e07d1156 100644 --- a/sw/airborne/arch/stm32/subsystems/actuators/actuators_shared_arch.c +++ b/sw/airborne/arch/stm32/subsystems/actuators/actuators_shared_arch.c @@ -23,10 +23,11 @@ * STM32 PWM and dualPWM servos shared functions. */ -#include "subsystems/actuators/actuators_shared_arch.h" +#include "arch/stm32/subsystems/actuators/actuators_shared_arch.h" +#include // for timer_get_frequency -#include "mcu_arch.h" +#include "arch/stm32/mcu_arch.h" /** Set PWM channel configuration diff --git a/sw/ext/libopencm3 b/sw/ext/libopencm3 index 283d8cc7d2..1420be5577 160000 --- a/sw/ext/libopencm3 +++ b/sw/ext/libopencm3 @@ -1 +1 @@ -Subproject commit 283d8cc7d2acbfc873897e886658364b12fc5e3b +Subproject commit 1420be55777189fd25f06ffde174c8abe6882186