Removed libstm32 legacy code from mcu_arch.c and it's dependencies.

This commit is contained in:
Piotr Esden-Tempski
2012-02-11 23:29:54 -08:00
parent 02d2c8c7cd
commit 5016b9710b
4 changed files with 15 additions and 70 deletions
+9 -59
View File
@@ -27,69 +27,19 @@
#include BOARD_CONFIG
#include <inttypes.h>
#include <stm32/gpio.h>
#include <stm32/rcc.h>
#include <stm32/flash.h>
#include <stm32/misc.h>
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/flash.h>
void mcu_arch_init(void) {
#if USE_OPENCM3
#if EXT_CLK == 8000000
#pragma message "Using 8MHz external clock to PLL it to 72MHz."
rcc_clock_setup_in_hse_8mhz_out_72mhz();
#elif EXT_CLK == 12000000
#pragma message "Using 12MHz external clock to PLL it to 72MHz."
rcc_clock_setup_in_hse_12mhz_out_72mhz();
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
return;
#else // !USE_OPENCM3
#ifdef HSE_TYPE_EXT_CLK
#pragma message "Using external clock."
/* Setup the microcontroller system.
* Initialize the Embedded Flash Interface,
* initialize the PLL and update the SystemFrequency variable.
*/
/* RCC system reset(for debug purpose) */
RCC_DeInit();
/* Enable HSE with external clock ( HSE_Bypass ) */
RCC_HSEConfig( STM32_RCC_MODE );
/* Wait till HSE is ready */
ErrorStatus HSEStartUpStatus = RCC_WaitForHSEStartUp();
if (HSEStartUpStatus != SUCCESS) {
/* block if something went wrong */
while(1) {}
}
else {
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
/* PLLCLK = 8MHz * 9 = 72 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, STM32_PLL_MULT);
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {}
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while(RCC_GetSYSCLKSource() != 0x08) {}
}
#else /* HSE_TYPE_EXT_CLK */
#pragma message "Using normal system clock setup."
SystemInit();
#endif /* HSE_TYPE_EXT_CLK */
/* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#ifdef STM32_FORCE_ALL_CLOCK_ON
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD |
RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE);
#else
#error EXT_CLK is either set to an unsupported frequency or not defined at all. Please check!
#endif
#endif // USE_OPENCM3
}
+2 -5
View File
@@ -3,13 +3,10 @@
#define BOARD_LISA_L
/* Lisa/L has an 8MHZ external clock and 72MHz internal. */
#define EXT_CLK 8000000
#define AHB_CLK 72000000
/* Lisa uses an external clock instead of a crystal */
#define HSE_TYPE_EXT_CLK
#define STM32_RCC_MODE RCC_HSE_Bypass
#define STM32_PLL_MULT RCC_PLLMul_9
/* Onboard LEDs */
#define LED_1_BANK
#define LED_STP08
+2
View File
@@ -3,6 +3,8 @@
#define BOARD_LISA_M
/* Lisa/M has a 12MHz external clock and 72MHz internal. */
#define EXT_CLK 12000000
#define AHB_CLK 72000000
/* Onboard LEDs */
+2 -6
View File
@@ -1,18 +1,14 @@
#ifndef CONFIG_OLIMEX_STM32_H103_H
#define CONFIG_OLIMEX_STM32_H103_H
/* Olimex STM32-H103 board has an 8MHz external clock and 72MHz internal. */
#define EXT_CLK 8000000
#define AHB_CLK 72000000
/* this board uses a crystal for HSE */
//#define HSE_TYPE RCC_HSE_ON
/* Onboard LEDs */
#define LED_1_BANK
#define LED_1_GPIO GPIOC
#define LED_1_GPIO_CLK RCC_APB2Periph_GPIOC
#define LED_1_GPIO_PIN GPIO_Pin_12
#endif /* CONFIG_OLIMEX_STM32_H103_H */