Skip to content

Commit 239802f

Browse files
Merge branch 'jcw-two-nucleo-variants' into development
2 parents ca3db7c + 081b6d5 commit 239802f

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

STM32F1/boards.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,8 @@ nucleo_f103rb.upload.altID=1
125125
nucleo_f103rb.upload.auto_reset=true
126126

127127
nucleo_f103rb.build.mcu=cortex-m3
128-
nucleo_f103rb.build.f_cpu=72000000L
129-
nucleo_f103rb.build.board=STM_NUCLEU_F103RB
128+
nucleo_f103rb.build.board=STM_NUCLEO_F103RB
130129
nucleo_f103rb.build.core=maple
131-
nucleo_f103rb.build.extra_flags=-DMCU_STM32F103RB -mthumb -march=armv7-m -D__STM32F1__
132130
nucleo_f103rb.build.ldscript=ld/jtag.ld
133131
nucleo_f103rb.build.variant=nucleo_f103rb
134132
nucleo_f103rb.build.variant_system_lib=libmaple.a
@@ -139,6 +137,16 @@ nucleo_f103rb.build.error_led_pin=1
139137
nucleo_f103rb.build.gcc_ver=gcc-arm-none-eabi-4.8.3-2014q1
140138
nucleo_f103rb.build.vect=VECT_TAB_ADDR=0x8000000
141139

140+
## internal oscillator (HSI), running at 64 MHz
141+
nucleo_f103rb.menu.device_variant.NucleoF103_HSI=Nucleo F103 @ 64 MHz
142+
nucleo_f103rb.menu.device_variant.NucleoF103_HSI.build.f_cpu=64000000L
143+
nucleo_f103rb.menu.device_variant.NucleoF103_HSI.build.extra_flags=-DMCU_STM32F103RB -mthumb -march=armv7-m -D__STM32F1__
144+
145+
## external crystal (HSE), running at 72 MHz
146+
nucleo_f103rb.menu.device_variant.NucleoF103_HSE=Nucleo F103 @ 72 MHz w/ crystal
147+
nucleo_f103rb.menu.device_variant.NucleoF103_HSE.build.f_cpu=72000000L
148+
nucleo_f103rb.menu.device_variant.NucleoF103_HSE.build.extra_flags=-DNUCLEO_HSE_CRYSTAL -DMCU_STM32F103RB -mthumb -march=armv7-m -D__STM32F1__
149+
142150
###################### Generic STM32F103C ########################################
143151

144152
genericSTM32F103C.name=Generic STM32F103C series

STM32F1/variants/nucleo_f103rb/wirish/boards.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,12 @@ static void setup_clocks(void) {
121121
// readiness interrupts.
122122
RCC_BASE->CIR = 0x00000000;
123123

124+
#if NUCLEO_HSE_CRYSTAL
124125
// Enable HSE, and wait until it's ready.
125126
rcc_turn_on_clk(RCC_CLK_HSE);
126127
while (!rcc_is_clk_ready(RCC_CLK_HSE))
127128
;
129+
#endif
128130

129131
// Configure AHBx, APBx, etc. prescalers and the main PLL.
130132
wirish::priv::board_setup_clock_prescalers();

STM32F1/variants/nucleo_f103rb/wirish/boards_setup.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,22 @@
4848
// works for F103 performance line MCUs, which is all that LeafLabs
4949
// currently officially supports).
5050
#ifndef BOARD_RCC_PLLMUL
51+
#if NUCLEO_HSE_CRYSTAL
5152
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
53+
#else
54+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_16
55+
#endif
5256
#endif
5357

5458
namespace wirish {
5559
namespace priv {
5660

5761
static stm32f1_rcc_pll_data pll_data = {BOARD_RCC_PLLMUL};
62+
#if NUCLEO_HSE_CRYSTAL
5863
__weak rcc_pll_cfg w_board_pll_cfg = {RCC_PLLSRC_HSE, &pll_data};
64+
#else
65+
__weak rcc_pll_cfg w_board_pll_cfg = {RCC_PLLSRC_HSI_DIV_2, &pll_data};
66+
#endif
5967
__weak adc_prescaler w_adc_pre = ADC_PRE_PCLK2_DIV_6;
6068
__weak adc_smp_rate w_adc_smp = ADC_SMPR_55_5;
6169

@@ -71,7 +79,7 @@ namespace wirish {
7179
#if F_CPU == 72000000
7280
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7381
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
82+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7583
#endif
7684
}
7785

0 commit comments

Comments
 (0)