diff --git a/conf/Makefile.stm32 b/conf/Makefile.stm32 index fb7fe7ea20..be9a360e33 100644 --- a/conf/Makefile.stm32 +++ b/conf/Makefile.stm32 @@ -138,7 +138,7 @@ else LDFLAGS = -D__thumb2__ -T$(LDSCRIPT) -nostartfiles -L$(GCC_LIB_DIR) -O$(OPT) --gc-sections endif LDFLAGS += -Wl,-Map=$(OBJDIR)/$(TARGET).map,--cref,--gc-sections -LDLIBS += -lc -lm -lgcc -lcmsis -lstm32 +LDLIBS += -lc -lm -lgcc -lcmsis -lstm32 -lopencm3_stm32 CPFLAGS = -j .isr_vector -j .text -j .data CPFLAGS_BIN = -Obinary diff --git a/sw/airborne/arch/stm32/mcu_arch.c b/sw/airborne/arch/stm32/mcu_arch.c index 3c8a01fd10..9a6fb255ec 100644 --- a/sw/airborne/arch/stm32/mcu_arch.c +++ b/sw/airborne/arch/stm32/mcu_arch.c @@ -24,17 +24,24 @@ #include "mcu.h" +#include BOARD_CONFIG #include #include #include #include #include +#ifdef USE_OPENCM3 +#include +#endif -#include BOARD_CONFIG void mcu_arch_init(void) { - +#ifdef USE_OPENCM3 + rcc_clock_setup_in_hse_12mhz_out_72mhz(); + NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); + return; +#endif #ifdef HSE_TYPE_EXT_CLK #warning Using external clock /* Setup the microcontroller system. diff --git a/sw/airborne/arch/stm32/mcu_periph/uart_arch.c b/sw/airborne/arch/stm32/mcu_periph/uart_arch.c index 3edce0c1d1..134023b577 100644 --- a/sw/airborne/arch/stm32/mcu_periph/uart_arch.c +++ b/sw/airborne/arch/stm32/mcu_periph/uart_arch.c @@ -29,6 +29,14 @@ #include #include "std.h" +#include BOARD_CONFIG + +#ifdef USE_OPENCM3 +#define pprz_usart_set_baudrate(x, y) usart_set_baudrate(x, y) +#else +#define pprz_usart_set_baudrate(x, y) do { } while(0); +#endif + #ifdef USE_UART1 volatile uint16_t uart1_rx_insert_idx, uart1_rx_extract_idx; @@ -74,6 +82,9 @@ void uart1_init( void ) { USART_Init(USART1, &usart); /* Enable USART1 Receive interrupts */ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); + + pprz_usart_set_baudrate(USART1, UART1_BAUD); + /* Enable the USART1 */ USART_Cmd(USART1, ENABLE); @@ -197,6 +208,9 @@ void uart2_init( void ) { USART_Init(USART2, &usart); /* Enable USART2 Receive interrupts */ USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); + + pprz_usart_set_baudrate(USART2, UART2_BAUD); + /* Enable the USART2 */ USART_Cmd(USART2, ENABLE); @@ -320,6 +334,9 @@ void uart3_init( void ) { USART_Init(USART3, &usart); /* Enable USART3 Receive interrupts */ USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); + + pprz_usart_set_baudrate(USART3, UART3_BAUD); + /* Enable the USART3 */ USART_Cmd(USART3, ENABLE); diff --git a/sw/airborne/boards/lisa_m_1.0.h b/sw/airborne/boards/lisa_m_1.0.h index a0941c8737..611896757f 100644 --- a/sw/airborne/boards/lisa_m_1.0.h +++ b/sw/airborne/boards/lisa_m_1.0.h @@ -28,6 +28,8 @@ #define BOARD_HAS_BARO +#define USE_OPENCM3 + #define HSE_TYPE_EXT_CLK #define STM32_RCC_MODE RCC_HSE_ON #define STM32_PLL_MULT RCC_PLLMul_6