mongoose/examples/stm32/stm32f1/device.h

30 lines
943 B
C
Raw Normal View History

2021-05-11 16:12:06 +08:00
// Copyright (c) 2018-2021 Cesanta Software Limited
// All rights reserved
2021-05-12 01:05:03 +08:00
#include "mcu.h"
2021-05-11 16:12:06 +08:00
2021-05-12 01:05:03 +08:00
// These are NUCLEO-F103RB settings - adjust for your specific board
#define RAM_SIZE 20480 // RAM size on this device, needed by link.ld
#define ROM_SIZE 131072 // Flash size for this device, needed by link.ld
#define LED1 PIN('A', 5) // On-board LED pin
2021-05-11 16:12:06 +08:00
static inline void led_toggle(void) {
2021-05-12 01:05:03 +08:00
gpio_toggle(LED1);
2021-05-11 16:12:06 +08:00
}
static inline void init_hardware(void) {
2021-05-12 03:44:14 +08:00
RCC->CR |= (RCC_CR_HSEON);
while (!(RCC->CR & RCC_CR_HSERDY)) (void) 0;
RCC->CFGR &= ~(RCC_CFGR_SW);
RCC->CFGR |= (RCC_CFGR_SW_HSE);
RCC->CFGR &= ~(RCC_CFGR_PLLMULL);
RCC->CFGR |= (RCC_CFGR_PLLMULL9);
RCC->CR |= (RCC_CR_PLLON);
while (!(RCC->CR & RCC_CR_PLLRDY)) (void) 0;
RCC->CFGR &= ~(RCC_CFGR_SW);
RCC->CFGR |= (RCC_CFGR_SW_PLL);
2021-05-12 01:05:03 +08:00
RCC->APB2ENR |= BIT(2) | BIT(3) | BIT(4); // Init GPIO banks A,B,C
gpio_init(LED1, OUTPUT); // Set LED
2021-05-11 16:12:06 +08:00
}