1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Start to break up drv/system.c to avoid #ifdef.

This commit is contained in:
Dominic Clifton 2014-06-02 18:43:47 +01:00
parent c7cd7adee9
commit d407a4d15e
4 changed files with 44 additions and 20 deletions

View file

@ -189,6 +189,7 @@ NAZE_SRC = startup_stm32f10x_md_gcc.S \
drivers/serial_softserial.c \
drivers/serial_uart.c \
drivers/serial_uart_stm32f10x.c \
drivers/system_stm32f10x.c \
drivers/timer.c \
$(COMMON_SRC)
@ -206,6 +207,7 @@ OLIMEXINO_SRC = startup_stm32f10x_md_gcc.S \
drivers/serial_softserial.c \
drivers/serial_uart.c \
drivers/serial_uart_stm32f10x.c \
drivers/system_stm32f10x.c \
drivers/timer.c \
$(COMMON_SRC)
@ -223,6 +225,7 @@ STM32F30x_COMMON_SRC = startup_stm32f30x_md_gcc.S \
drivers/serial_uart_stm32f30x.c \
drivers/serial_softserial.c \
drivers/serial_usb_vcp.c \
drivers/system_stm32f30x.c \
drivers/timer.c \
vcp/hw_config.c \
vcp/stm32_it.c \

View file

@ -288,24 +288,4 @@ void failureMode(uint8_t mode)
}
}
#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
void systemReset(bool toBootloader)
{
if (toBootloader) {
// 1FFFF000 -> 20000200 -> SP
// 1FFFF004 -> 1FFFF021 -> PC
#ifdef STM32F10X_MD
*((uint32_t *)0x20004FF0) = 0xDEADBEEF; // 20KB STM32F103
#endif
#ifdef STM32F303xC
*((uint32_t *)0x20009FFC) = 0xDEADBEEF; // 40KB SRAM STM32F30X
#endif
}
// Generate system reset
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
}

View file

@ -0,0 +1,20 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "platform.h"
#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
void systemReset(bool toBootloader)
{
if (toBootloader) {
// 1FFFF000 -> 20000200 -> SP
// 1FFFF004 -> 1FFFF021 -> PC
*((uint32_t *)0x20004FF0) = 0xDEADBEEF; // 20KB STM32F103
}
// Generate system reset
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
}

View file

@ -0,0 +1,21 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "platform.h"
#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
void systemReset(bool toBootloader)
{
if (toBootloader) {
// 1FFFF000 -> 20000200 -> SP
// 1FFFF004 -> 1FFFF021 -> PC
*((uint32_t *)0x20009FFC) = 0xDEADBEEF; // 40KB SRAM STM32F30X
}
// Generate system reset
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
}