Skip to content

Commit 8a35b47

Browse files
committed
stm32duino#61 Rebased. MM & BP blinky tested with STLink and Serial2
1 parent 0338724 commit 8a35b47

File tree

7 files changed

+138
-216
lines changed

7 files changed

+138
-216
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ For advanced user, you can use the repository: see the [Using git repository](ht
5757

5858
### Next release
5959
* STM32F1
60-
* BluePill F103C8 (on going)
61-
* MapleMini F103CB (on going)
60+
* BluePill F103C8 (on going, Blinky tested with STLink and UART2)
61+
* MapleMini F103CB (on going, Blinky tested with STLink and UART2)
6262

6363
## Troubleshooting
6464

Diff for: boards.txt

+76-45
Original file line numberDiff line numberDiff line change
@@ -390,53 +390,54 @@ Other.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.enable_
390390

391391
# BLUEPILL_F103C8 board
392392
# Support: USB HID, Serial2 (USART2 on PA3, PA2) and Serial3 (USART3 on PB11, PB10)
393-
Other.menu.board_part_num.BLUEPILL_F103C8=BluePill F103C8
394-
Other.menu.board_part_num.BLUEPILL_F103C8.node=NODE_F103C8
395-
Other.menu.board_part_num.BLUEPILL_F103C8.upload.maximum_size=65536
396-
Other.menu.board_part_num.BLUEPILL_F103C8.upload.maximum_data_size=20480
397-
Other.menu.board_part_num.BLUEPILL_F103C8.build.mcu=cortex-m3
398-
Other.menu.board_part_num.BLUEPILL_F103C8.build.f_cpu=72000000L
399-
Other.menu.board_part_num.BLUEPILL_F103C8.build.board=BLUEPILL_F103C8
400-
Other.menu.board_part_num.BLUEPILL_F103C8.build.series=STM32F1xx
401-
Other.menu.board_part_num.BLUEPILL_F103C8.build.product_line=STM32F103xB
402-
Other.menu.board_part_num.BLUEPILL_F103C8.build.variant=BLUEPILL_F103C8
403-
Other.menu.board_part_num.BLUEPILL_F103C8.build.cmsis_lib_gcc=arm_cortexM3l_math
393+
Other.menu.pnum.BLUEPILL_F103C8=BluePill F103C8
394+
Other.menu.pnum.BLUEPILL_F103C8.node=NODE_F103C8
395+
Other.menu.pnum.BLUEPILL_F103C8.upload.maximum_size=65536
396+
Other.menu.pnum.BLUEPILL_F103C8.upload.maximum_data_size=20480
397+
Other.menu.pnum.BLUEPILL_F103C8.build.mcu=cortex-m3
398+
Other.menu.pnum.BLUEPILL_F103C8.build.f_cpu=72000000L
399+
Other.menu.pnum.BLUEPILL_F103C8.build.board=BLUEPILL_F103C8
400+
Other.menu.pnum.BLUEPILL_F103C8.build.series=STM32F1xx
401+
Other.menu.pnum.BLUEPILL_F103C8.build.product_line=STM32F103xB
402+
Other.menu.pnum.BLUEPILL_F103C8.build.variant=BLUEPILL_F103C8
403+
Other.menu.pnum.BLUEPILL_F103C8.build.cmsis_lib_gcc=arm_cortexM3l_math
404404

405405
# MAPLEMINI_F103CB board
406406
# Support: USB HID, Serial2 (USART2 on PA3, PA2) and Serial3 (USART3 on PB11, PB10)
407-
Other.menu.board_part_num.MAPLEMINI_F103CB=MapleMini F103CB
408-
Other.menu.board_part_num.MAPLEMINI_F103CB.node=NODE_F103CB
409-
Other.menu.board_part_num.MAPLEMINI_F103CB.upload.maximum_size=131072
410-
Other.menu.board_part_num.MAPLEMINI_F103CB.upload.maximum_data_size=20480
411-
Other.menu.board_part_num.MAPLEMINI_F103CB.build.mcu=cortex-m3
412-
Other.menu.board_part_num.MAPLEMINI_F103CB.build.f_cpu=72000000L
413-
Other.menu.board_part_num.MAPLEMINI_F103CB.build.board=MAPLEMINI_F103CB
414-
Other.menu.board_part_num.MAPLEMINI_F103CB.build.series=STM32F1xx
415-
Other.menu.board_part_num.MAPLEMINI_F103CB.build.product_line=STM32F103xB
416-
Other.menu.board_part_num.MAPLEMINI_F103CB.build.variant=MAPLEMINI_F103CB
417-
Other.menu.board_part_num.MAPLEMINI_F103CB.build.cmsis_lib_gcc=arm_cortexM3l_math
407+
Other.menu.pnum.MAPLEMINI_F103CB=MapleMini F103CB
408+
Other.menu.pnum.MAPLEMINI_F103CB.node=NODE_F103CB
409+
Other.menu.pnum.MAPLEMINI_F103CB.upload.maximum_size=131072
410+
Other.menu.pnum.MAPLEMINI_F103CB.upload.maximum_data_size=20480
411+
Other.menu.pnum.MAPLEMINI_F103CB.build.mcu=cortex-m3
412+
Other.menu.pnum.MAPLEMINI_F103CB.build.f_cpu=72000000L
413+
Other.menu.pnum.MAPLEMINI_F103CB.build.board=MAPLEMINI_F103CB
414+
Other.menu.pnum.MAPLEMINI_F103CB.build.series=STM32F1xx
415+
Other.menu.pnum.MAPLEMINI_F103CB.build.product_line=STM32F103xB
416+
Other.menu.pnum.MAPLEMINI_F103CB.build.variant=MAPLEMINI_F103CB
417+
Other.menu.pnum.MAPLEMINI_F103CB.build.cmsis_lib_gcc=arm_cortexM3l_math
418418

419419
# Upload menu
420-
Other.menu.upload_method.DFUUploadMethod1=Maple bootloader (original version for Maple boards)
421-
Other.menu.upload_method.DFUUploadMethod1.upload.protocol=maple_dfu
422-
Other.menu.upload_method.DFUUploadMethod1.upload.tool=maple_upload
423-
Other.menu.upload_method.DFUUploadMethod1.build.upload_flags=-DSERIAL_USB -DVECT_TAB_OFFSET=0x5000
424-
Other.menu.upload_method.DFUUploadMethod1.build.ldscript=bootloader_original.ld
425-
Other.menu.upload_method.DFUUploadMethod1.upload.usbID=1EAF:0003
426-
Other.menu.upload_method.DFUUploadMethod1.upload.altID=1
427-
428-
Other.menu.upload_method.DFUUploadMethod=STM32duino bootloader
429-
Other.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
430-
Other.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
431-
Other.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DVECT_TAB_OFFSET=0x2000
432-
Other.menu.upload_method.DFUUploadMethod.build.ldscript=bootloader.ld
433-
Other.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
434-
Other.menu.upload_method.DFUUploadMethod.upload.altID=2
420+
#Other.menu.upload_method.DFUUploadMethod1=Maple bootloader (original version for Maple boards)
421+
#Other.menu.upload_method.DFUUploadMethod1.upload.protocol=maple_dfu
422+
#Other.menu.upload_method.DFUUploadMethod1.upload.tool=maple_upload
423+
#Other.menu.upload_method.DFUUploadMethod1.build.upload_flags=-DSERIAL_USB -DVECT_TAB_OFFSET=0x5000
424+
#Other.menu.upload_method.DFUUploadMethod1.build.ldscript=bootloader_original.ld
425+
#Other.menu.upload_method.DFUUploadMethod1.upload.usbID=1EAF:0003
426+
#Other.menu.upload_method.DFUUploadMethod1.upload.altID=1
427+
428+
#Other.menu.upload_method.DFUUploadMethod=STM32duino bootloader
429+
#Other.menu.upload_method.DFUUploadMethod.upload.protocol=maple_dfu
430+
#Other.menu.upload_method.DFUUploadMethod.upload.tool=maple_upload
431+
#Other.menu.upload_method.DFUUploadMethod.build.upload_flags=-DSERIAL_USB -DVECT_TAB_OFFSET=0x2000
432+
#Other.menu.upload_method.DFUUploadMethod.build.ldscript=bootloader.ld
433+
#Other.menu.upload_method.DFUUploadMethod.upload.usbID=1EAF:0003
434+
#Other.menu.upload_method.DFUUploadMethod.upload.altID=2
435435

436436
Other.menu.upload_method.STLinkMethod=STLink
437437
Other.menu.upload_method.STLinkMethod.upload.protocol=STLink
438438
Other.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
439-
Other.menu.upload_method.STLinkMethod.build.upload_flags=-DSERIAL_USB
439+
#Other.menu.upload_method.STLinkMethod.build.upload_flags=-DSERIAL_USB
440+
Other.menu.upload_method.STLinkMethod.build.upload_flags=
440441

441442
Other.menu.upload_method.serialMethod=Serial
442443
Other.menu.upload_method.serialMethod.upload.protocol=maple_serial
@@ -483,13 +484,14 @@ Disco.menu.xserial.all.build.xSerial=-DALL_HWSERIAL
483484
Disco.menu.xserial.third=Enable first third (USART1 to 3 if available)
484485
Disco.menu.xserial.third.build.xSerial=-DFIRST_THIRD_HWSERIAL
485486

486-
Other.menu.Other_serial.enable_Serial=None
487-
Other.menu.Other_serial.enable_SerialAll=All
488-
Other.menu.Other_serial.enable_SerialAll.build.enable_Serialx=-DENABLE_SERIAL2 -DENABLE_SERIAL3
489-
Other.menu.Other_serial.enable_Serial2=Serial2 (if available)
490-
Other.menu.Other_serial.enable_Serial2.build.enable_Serialx=-DENABLE_SERIAL2
491-
Other.menu.Other_serial.enable_Serial3=Serial3 (if available)
492-
Other.menu.Other_serial.enable_Serial3.build.enable_Serialx=-DENABLE_SERIAL3
487+
Other.menu.xserial.enable_Serial2=Serial2 (if available)
488+
Other.menu.xserial.enable_Serial2.build.enable_Serialx=-DSERIAL_UART_INSTANCE=2
489+
Other.menu.xserial.enable_Serial3=Serial3 (if available)
490+
Other.menu.xserial.enable_Serial3.build.enable_Serialx=-DSERIAL_UART_INSTANCE=3
491+
Other.menu.xserial.enable_SerialAll=All
492+
Other.menu.xserial.enable_SerialAll.build.enable_Serialx=-DSERIAL_UART_INSTANCE=2 -DENABLE_SERIAL3
493+
Other.menu.xserial.enable_SerialNone=None
494+
Other.menu.xserial.enable_SerialNone.build.enable_Serialx=
493495

494496
# USB connectivity
495497
Nucleo_144.menu.usb.none=None
@@ -628,6 +630,35 @@ Disco.menu.opt.o3lto.build.flags.ldspecs=-flto
628630
Disco.menu.opt.ogstd=Debug (-g)
629631
Disco.menu.opt.ogstd.build.flags.optimize=-g -Og
630632
Disco.menu.opt.ogstd.build.flags.ldspecs=
633+
634+
Other.menu.opt.osstd=Smallest (-Os default)
635+
Other.menu.opt.osstd.build.flags.optimize=-Os
636+
Other.menu.opt.osstd.build.flags.ldspecs=
637+
Other.menu.opt.oslto=Smallest (-Os) with LTO
638+
Other.menu.opt.oslto.build.flags.optimize=-Os -flto
639+
Other.menu.opt.oslto.build.flags.ldspecs=-flto
640+
Other.menu.opt.o1std=Fast (-O1)
641+
Other.menu.opt.o1std.build.flags.optimize=-O1
642+
Other.menu.opt.o1std.build.flags.ldspecs=
643+
Other.menu.opt.o1lto=Fast (-O1) with LTO
644+
Other.menu.opt.o1lto.build.flags.optimize=-O1 -flto
645+
Other.menu.opt.o1lto.build.flags.ldspecs=-flto
646+
Other.menu.opt.o2std=Faster (-O2)
647+
Other.menu.opt.o2std.build.flags.optimize=-O2
648+
Other.menu.opt.o2std.build.flags.ldspecs=
649+
Other.menu.opt.o2lto=Faster (-O2) with LTO
650+
Other.menu.opt.o2lto.build.flags.optimize=-O2 -flto
651+
Other.menu.opt.o2lto.build.flags.ldspecs=-flto
652+
Other.menu.opt.o3std=Fastest (-O3)
653+
Other.menu.opt.o3std.build.flags.optimize=-O3
654+
Other.menu.opt.o3std.build.flags.ldspecs=
655+
Other.menu.opt.o3lto=Fastest (-O3) with LTO
656+
Other.menu.opt.o3lto.build.flags.optimize=-O3 -flto
657+
Other.menu.opt.o3lto.build.flags.ldspecs=-flto
658+
Other.menu.opt.ogstd=Debug (-g)
659+
Other.menu.opt.ogstd.build.flags.optimize=-g -Og
660+
Other.menu.opt.ogstd.build.flags.ldspecs=
661+
631662
Nucleo_144.menu.USB_interface.enable_USB=None
632663
Nucleo_144.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
633664
Nucleo_144.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE

Diff for: cores/arduino/USBSerial.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
2424
*
2525
****************************************************************************/
26-
26+
#if defined(SERIAL_USB)
2727
#include <chip.h>
28+
#endif
2829

2930
#if defined(SERIAL_USB) && defined(USBCON)
3031
#include <USBSerial.h>

Diff for: variants/BLUEPILL_F103C8/variant.cpp

-47
Original file line numberDiff line numberDiff line change
@@ -76,53 +76,6 @@ const PinName digitalPin[] = {
7676
}
7777
#endif
7878

79-
/*
80-
* UART objects
81-
*/
82-
83-
HardwareSerial Serial1(PA_10, PA_9);
84-
#ifdef ENABLE_SERIAL2
85-
HardwareSerial Serial2(PA_3, PA_2);
86-
#endif
87-
#ifdef ENABLE_SERIAL3
88-
HardwareSerial Serial3(PB_11, PB_10);
89-
#endif
90-
91-
#if defined(SERIAL_USB) && defined(USBCON)
92-
USBSerial Serial; //available on PA11/PA12
93-
#endif
94-
95-
void serialEvent1() __attribute__((weak));
96-
void serialEvent1() { }
97-
#ifdef ENABLE_SERIAL2
98-
void serialEvent2() __attribute__((weak));
99-
void serialEvent2() { }
100-
#endif
101-
#ifdef ENABLE_SERIAL3
102-
void serialEvent3() __attribute__((weak));
103-
void serialEvent3() { }
104-
#endif
105-
106-
#if defined(SERIAL_USB) && defined(USBCON)
107-
void serialEvent() __attribute__((weak));
108-
void serialEvent() { }
109-
#endif
110-
111-
void serialEventRun(void)
112-
{
113-
if (Serial1.available()) serialEvent1();
114-
#ifdef ENABLE_SERIAL2
115-
if (Serial2.available()) serialEvent2();
116-
#endif
117-
#ifdef ENABLE_SERIAL3
118-
if (Serial3.available()) serialEvent3();
119-
#endif
120-
121-
#if defined(SERIAL_USB) && defined(USBCON)
122-
if (Serial.available()) serialEvent();
123-
#endif
124-
}
125-
12679
// ----------------------------------------------------------------------------
12780

12881
#ifdef __cplusplus

Diff for: variants/BLUEPILL_F103C8/variant.h

+29-37
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
/*----------------------------------------------------------------------------
2323
* Headers
2424
*----------------------------------------------------------------------------*/
25-
26-
#include "Arduino.h"
25+
#include "PeripheralPins.h"
2726

2827
#ifdef __cplusplus
2928
extern "C"{
@@ -32,8 +31,6 @@ extern "C"{
3231
/*----------------------------------------------------------------------------
3332
* Pins
3433
*----------------------------------------------------------------------------*/
35-
#include "PeripheralPins.h"
36-
3734
extern const PinName digitalPin[];
3835

3936
enum {
@@ -86,24 +83,24 @@ enum {
8683
PEND
8784
};
8885

89-
enum {
90-
A_START_AFTER = D34,
91-
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
92-
AEND
93-
};
86+
// This must be a literal with the same value as PEND
87+
#define NUM_DIGITAL_PINS 45
88+
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
89+
#define NUM_ANALOG_INPUTS 10
90+
#define NUM_ANALOG_FIRST 35
9491

9592
//ADC resolution is 12bits
96-
#define ADC_RESOLUTION 12
97-
#define DACC_RESOLUTION 12
93+
#define ADC_RESOLUTION 12
94+
#define DACC_RESOLUTION 12
9895

9996
//PWR resolution
100-
#define PWM_RESOLUTION 8
101-
#define PWM_FREQUENCY 1000
102-
#define PWM_MAX_DUTY_CYCLE 255
97+
#define PWM_RESOLUTION 8
98+
#define PWM_FREQUENCY 1000
99+
#define PWM_MAX_DUTY_CYCLE 255
103100

104101
//On-board LED pin number
105-
#define LED_BUILTIN 32
106-
#define LED_GREEN LED_BUILTIN
102+
#define LED_BUILTIN PC13
103+
#define LED_GREEN LED_BUILTIN
107104

108105
//SPI definitions
109106
//define 16 channels. As many channel as digital IOs
@@ -115,17 +112,17 @@ enum {
115112
//In case SPI CS channel is not used we define a default one
116113
#define BOARD_SPI_OWN_SS SPI_CHANNELS_NUM
117114

118-
#define SS BOARD_SPI_DEFAULT_SS
119-
#define SS1 8
120-
#define SS2 9
121-
#define SS3 10
122-
#define MOSI 7
123-
#define MISO 6
124-
#define SCK 5
115+
#define PIN_SPI_SS PA4
116+
#define PIN_SPI_SS1 PA8
117+
#define PIN_SPI_SS2 PA9
118+
#define PIN_SPI_SS3 PA10
119+
#define PIN_SPI_MOSI PA7
120+
#define PIN_SPI_MISO PA6
121+
#define PIN_SPI_SCK PA5
125122

126123
//I2C Definitions
127-
#define SDA 23
128-
#define SCL 22
124+
#define PIN_WIRE_SDA PB7
125+
#define PIN_WIRE_SCL PB6
129126

130127
//Timer Definitions
131128
//Do not use timer used by PWM pins when possible. See PinMap_PWM.
@@ -138,15 +135,15 @@ enum {
138135
#define DEBUG_UART ((USART_TypeDef *) USART1)
139136

140137
// Serial Pin Firmata
141-
#define PIN_SERIAL_RX 10
142-
#define PIN_SERIAL_TX 9
143-
#define PIN_SERIAL1_RX 3
144-
#define PIN_SERIAL1_TX 2
145-
#define PIN_SERIAL2_RX 27
146-
#define PIN_SERIAL2_TX 26
138+
#define PIN_SERIAL_RX PA10
139+
#define PIN_SERIAL_TX PA9
140+
#define PIN_SERIAL1_RX PA3
141+
#define PIN_SERIAL1_TX PA2
142+
#define PIN_SERIAL2_RX PB11
143+
#define PIN_SERIAL2_TX PB10
147144

148145
#if defined(SERIAL_USB) && defined(USBCON)
149-
#define USB_DISC_PIN 12 //PA12 = USB Plus (+) pin number. That pin is normally pulled up to 3.3v by a 1.5k resistor
146+
#define USB_DISC_PIN PA12 //PA12 = USB Plus (+) pin number. That pin is normally pulled up to 3.3v by a 1.5k resistor
150147
#endif
151148

152149
#ifdef __cplusplus
@@ -157,14 +154,9 @@ enum {
157154
*----------------------------------------------------------------------------*/
158155

159156
#ifdef __cplusplus
160-
extern HardwareSerial Serial1;
161-
extern HardwareSerial Serial2;
162-
extern HardwareSerial Serial3;
163157

164158
#if defined(SERIAL_USB) && defined(USBCON)
165159
extern USBSerial Serial;
166-
#else
167-
#define Serial Serial1
168160
#endif
169161

170162
// These serial port names are intended to allow libraries and architecture-neutral

0 commit comments

Comments
 (0)