Skip to content

Commit 197844d

Browse files
committed
Merge remote-tracking branch 'refs/remotes/rogerclarkmelbourne/development'
2 parents 055db5a + d0ed194 commit 197844d

7 files changed

Lines changed: 46 additions & 17 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/cores/maple/usb_serial.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,17 @@ size_t n = 0;
126126
}
127127

128128

129-
if (sent == USB_CDCACM_TX_EPSIZE) {
130-
while (usb_cdcacm_is_transmitting() != 0) {
131-
}
132-
/* flush out to avoid having the pc wait for more data */
133-
usb_cdcacm_tx(NULL, 0);
134-
}
129+
#if 0
130+
// this code leads to a serious performance drop and appears to be
131+
// unnecessary - everything seems to work fine without, -jcw, 2015-11-05
132+
// see http://stm32duino.com/posting.php?mode=quote&f=3&p=7746
133+
if (sent == USB_CDCACM_TX_EPSIZE) {
134+
while (usb_cdcacm_is_transmitting() != 0) {
135+
}
136+
/* flush out to avoid having the pc wait for more data */
137+
usb_cdcacm_tx(NULL, 0);
138+
}
139+
#endif
135140
return n;
136141
}
137142

STM32F1/cores/maple/wirish_time.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@
3434
#include <libmaple/delay.h>
3535

3636
void delay(unsigned long ms) {
37-
uint32 i;
38-
for (i = 0; i < ms; i++) {
39-
delayMicroseconds(1000);
40-
}
37+
uint32 start = millis();
38+
while (millis() - start < ms)
39+
;
4140
}
4241

4342
void delayMicroseconds(uint32 us) {

STM32F1/libraries/SPI/src/SPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
#endif
8989

9090
// PC13 or PA4
91-
//#define BOARD_SPI_DEFAULT_SS PA4
92-
#define BOARD_SPI_DEFAULT_SS PC13
91+
#define BOARD_SPI_DEFAULT_SS PA4
92+
//#define BOARD_SPI_DEFAULT_SS PC13
9393

9494
#define SPI_MODE0 SPI_MODE_0
9595
#define SPI_MODE1 SPI_MODE_1

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

tools/src/stm32flash_serial/src/serial_posix.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,18 @@ static port_err_t serial_setup(serial_t *h, const serial_baud_t baud,
182182
if (tcsetattr(h->fd, TCSANOW, &h->newtio) != 0)
183183
return PORT_ERR_UNKNOWN;
184184

185+
/* this check fails on CDC-ACM devices, bits 16 and 17 of cflag differ!
186+
* it has been disabled below for now -jcw, 2015-11-09
187+
if (settings.c_cflag != h->newtio.c_cflag)
188+
fprintf(stderr, "c_cflag mismatch %lx\n",
189+
settings.c_cflag ^ h->newtio.c_cflag);
190+
*/
191+
185192
/* confirm they were set */
186193
tcgetattr(h->fd, &settings);
187194
if (settings.c_iflag != h->newtio.c_iflag ||
188195
settings.c_oflag != h->newtio.c_oflag ||
189-
settings.c_cflag != h->newtio.c_cflag ||
196+
//settings.c_cflag != h->newtio.c_cflag ||
190197
settings.c_lflag != h->newtio.c_lflag)
191198
return PORT_ERR_UNKNOWN;
192199

0 commit comments

Comments
 (0)