Skip to content

Commit 7dcbbc8

Browse files
Fix bug USB divider for 48Mhz operation. Also added support for 48Mhz to Maple mini and Generic F103C (Note. There is a bug in tone() at 48Mhz)
1 parent 7c9b1cc commit 7dcbbc8

File tree

14 files changed

+83
-24
lines changed

14 files changed

+83
-24
lines changed

STM32F1/boards.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ mapleMini.menu.bootloader_version.bootloader20.upload.flash.maximum_size=122880
3838
mapleMini.menu.bootloader_version.bootloader20.upload.maximum_size=122880
3939
mapleMini.menu.bootloader_version.bootloader20.upload.altID=2
4040

41+
#-- CPU Clock frequency
42+
mapleMini.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
43+
mapleMini.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
44+
45+
mapleMini.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
46+
mapleMini.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
47+
48+
4149
##############################################################
4250
maple.name=Maple (Rev 3)
4351

@@ -217,6 +225,13 @@ genericSTM32F103C.menu.upload_method.jlinkMethod.upload.protocol=jlink
217225
genericSTM32F103C.menu.upload_method.jlinkMethod.upload.tool=jlink_upload
218226
genericSTM32F103C.menu.upload_method.jlinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER
219227

228+
#-- CPU Clock frequency
229+
genericSTM32F103C.menu.cpu_speed.speed_72mhz=72Mhz (Normal)
230+
genericSTM32F103C.menu.cpu_speed.speed_72mhz.build.f_cpu=72000000L
231+
232+
genericSTM32F103C.menu.cpu_speed.speed_48mhz=48Mhz (Slow - with USB)
233+
genericSTM32F103C.menu.cpu_speed.speed_48mhz.build.f_cpu=48000000L
234+
220235
########################### Generic STM32F103R ###########################
221236

222237
genericSTM32F103R.name=Generic STM32F103R series

STM32F1/variants/STM32VLD/wirish/boards_setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace wirish {
7171
#if F_CPU == 72000000
7272
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7373
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
74+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7575
#endif
7676
}
7777

STM32F1/variants/generic_gd32f103c/wirish/boards_setup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace wirish {
8080
#elif F_CPU == 72000000
8181
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
8282
#elif F_CPU == 48000000
83-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
83+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
8484
#endif
8585
}
8686

STM32F1/variants/generic_stm32f103c/wirish/boards_setup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848
// works for F103 performance line MCUs, which is all that LeafLabs
4949
// currently officially supports).
5050
#ifndef BOARD_RCC_PLLMUL
51-
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
51+
#if F_CPU==72000000
52+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
53+
#elif F_CPU==48000000
54+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_6
55+
#endif
5256
#endif
5357

5458
namespace wirish {
@@ -71,7 +75,7 @@ namespace wirish {
7175
#if F_CPU == 72000000
7276
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7377
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
78+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7579
#endif
7680
}
7781

STM32F1/variants/generic_stm32f103r/wirish/boards_setup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848
// works for F103 performance line MCUs, which is all that LeafLabs
4949
// currently officially supports).
5050
#ifndef BOARD_RCC_PLLMUL
51-
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
51+
#if F_CPU==72000000
52+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
53+
#elif F_CPU==48000000
54+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_6
55+
#endif
5256
#endif
5357

5458
namespace wirish {
@@ -71,7 +75,7 @@ namespace wirish {
7175
#if F_CPU == 72000000
7276
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7377
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
78+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7579
#endif
7680
}
7781

STM32F1/variants/generic_stm32f103r8/wirish/boards_setup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848
// works for F103 performance line MCUs, which is all that LeafLabs
4949
// currently officially supports).
5050
#ifndef BOARD_RCC_PLLMUL
51-
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
51+
#if F_CPU==72000000
52+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
53+
#elif F_CPU==48000000
54+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_6
55+
#endif
5256
#endif
5357

5458
namespace wirish {
@@ -71,7 +75,7 @@ namespace wirish {
7175
#if F_CPU == 72000000
7276
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7377
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
78+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7579
#endif
7680
}
7781

STM32F1/variants/generic_stm32f103t/wirish/boards_setup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848
// works for F103 performance line MCUs, which is all that LeafLabs
4949
// currently officially supports).
5050
#ifndef BOARD_RCC_PLLMUL
51-
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
51+
#if F_CPU==72000000
52+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
53+
#elif F_CPU==48000000
54+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_6
55+
#endif
5256
#endif
5357

5458
namespace wirish {
@@ -71,7 +75,7 @@ namespace wirish {
7175
#if F_CPU == 72000000
7276
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7377
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
78+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7579
#endif
7680
}
7781

STM32F1/variants/generic_stm32f103v/wirish/boards_setup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848
// works for F103 performance line MCUs, which is all that LeafLabs
4949
// currently officially supports).
5050
#ifndef BOARD_RCC_PLLMUL
51-
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
51+
#if F_CPU==72000000
52+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
53+
#elif F_CPU==48000000
54+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_6
55+
#endif
5256
#endif
5357

5458
namespace wirish {
@@ -71,7 +75,7 @@ namespace wirish {
7175
#if F_CPU == 72000000
7276
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7377
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
78+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7579
#endif
7680
}
7781

STM32F1/variants/generic_stm32f103z/wirish/boards_setup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848
// works for F103 performance line MCUs, which is all that LeafLabs
4949
// currently officially supports).
5050
#ifndef BOARD_RCC_PLLMUL
51-
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
51+
#if F_CPU==72000000
52+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
53+
#elif F_CPU==48000000
54+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_6
55+
#endif
5256
#endif
5357

5458
namespace wirish {
@@ -71,7 +75,7 @@ namespace wirish {
7175
#if F_CPU == 72000000
7276
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7377
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
78+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7579
#endif
7680
}
7781

STM32F1/variants/hytiny_stm32f103t/wirish/boards_setup.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848
// works for F103 performance line MCUs, which is all that LeafLabs
4949
// currently officially supports).
5050
#ifndef BOARD_RCC_PLLMUL
51-
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
51+
#if F_CPU==72000000
52+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_9
53+
#elif F_CPU==48000000
54+
#define BOARD_RCC_PLLMUL RCC_PLLMUL_6
55+
#endif
5256
#endif
5357

5458
namespace wirish {
@@ -71,7 +75,7 @@ namespace wirish {
7175
#if F_CPU == 72000000
7276
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
7377
#elif F_CPU == 48000000
74-
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
78+
rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
7579
#endif
7680
}
7781

0 commit comments

Comments
 (0)