Skip to content

Commit a25bb2b

Browse files
committed
2 parents a7244e0 + c0a4c1d commit a25bb2b

364 files changed

Lines changed: 60393 additions & 9603 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "tools/src/dfu-util"]
1111
path = tools/src/dfu-util
1212
url = https://gitorious.org/dfu-util/dfu-util.git
13+
[submodule "STM32duino-bootloader"]
14+
path = STM32duino-bootloader
15+
url = https://github.com/rogerclarkmelbourne/STM32duino-bootloader.git

LICENSE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This project is built of many different components.
2+
3+
Substantial portions were derived from leaflabs libmaple - see https://github.com/leaflabs/libmaple/blob/master/LICENSE
4+
5+
Other sub projects e.g. Texane STlink have their own licenses

README.md

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
1-
Arduino STM32
2-
=============
1+
Arduino STM32
2+
=============
33

4-
This repo contains, the "Hardware" files to support STM32 based boards on Arduino version 1.5.x to the latest version (currently 1.6.3) including LeafLabs Maple, and Maple mini, and other generic STM32F103 boards
4+
##Notice
55

6-
Please read the wiki https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki for full details
6+
This software is experimental and a work in progress.
7+
Under no circumstances should these files be used in relation to any critical system(s).
8+
Use of these files is at your own risk.
79

8-
Based on https://github.com/bobc/maple-asp, which is in turn based on LibMaple by Leaflabs
910

10-
See also my blog
11+
##Summary:
12+
This repo contains, the "Hardware" files to support STM32 based boards on Arduino version 1.5.x to the latest version (currently 1.6.3) including [LeafLabs Maple, and Maple mini](http://www.leaflabs.com/about-maple/), and other generic STM32F103 boards
13+
14+
***PRIMARY SUPPORT FORUM: http://www.stm32duino.com/***
15+
16+
##Background & Support:
17+
* Based on https://github.com/bobc/maple-asp, which is in turn based on LibMaple by Leaflabs
18+
* **Please read the wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki) for full details**
19+
* See also my blog: http://www.rogerclark.net/stm32f103-and-maple-maple-mini-with-arduino-1-5-x-ide/
20+
* **NEW: Main support site for using STM32 boards with the Arduino IDE: http://www.stm32duino.com/**
21+
* LeafLabs "Maple Language Reference:" http://leaflabs.com/docs/language.html
22+
* LeafLabs "Maple-Arduino Compatibility:" http://leaflabs.com/docs/arduino-compatibility.html
23+
24+
**YouTube Videos:**
25+
* 20141116: [Arduino 1.5.8 IDE with STM32 board](https://www.youtube.com/watch?v=-zwGnytGT8M)
26+
* 20150413: [STM32 for Arduino 1.6.2 or newer (update)](https://www.youtube.com/watch?v=TePglhSkghg)
27+
* 20150419: [Uploading via USB to Serial to STM32F103 boards](https://www.youtube.com/watch?v=G_RF0a0hrak)
28+
29+
##Additional Links & Info:
30+
* https://www.hackster.io/rayburne/4-dollar-90-mips-32-bit-72-mhz-arm-arduino
31+
32+
##Purchase info:
33+
###Entry level boards
34+
35+
* [Ebay search for "arduino maple"](http://www.ebay.com/sch/i.html?_from=R40&_sacat=0&LH_BIN=1&_nkw=arduino+maple&_sop=15) (currently costs <$5 with shipping)
36+
* [AliExpress search for "leaflabs maple"] (http://www.aliexpress.com/wholesale?catId=0&initiative_id=SB_20150607085526&SearchText=leaflabs+maple)
37+
38+
### Bigger boards (You need to load the stm32duino bootloader)
39+
40+
Some supplier have this board e.g.
41+
42+
*[ STM32F103VET ](http://www.ebay.com.au/itm/1PCS-STM32F103VET6-ARM-STM32-Minimum-System-Development-Board-Arduino-M77-/301433302819)
43+
44+
*[There is also a STM32F103ZET board which also works, however they are not always available. They have been listed as "STM32F103ZET6 Minimum System Development Board ARM STM32 Cortex-m3 M75"]
45+
(http://www.ebay.com.au/itm/1pcs-STM32F103ZET6-Minimum-System-Development-Board-ARM-STM32-Cortex-m3-M75-/291305557264)
1146

12-
More information is available at http://www.rogerclark.net/stm32f103-and-maple-maple-mini-with-arduino-1-5-x-ide/

STM32F1/boards.txt

Lines changed: 161 additions & 127 deletions
Large diffs are not rendered by default.

STM32F1/cores/maple/HardwareSerial.cpp

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,54 +37,58 @@
3737
#include <libmaple/timer.h>
3838
#include <libmaple/usart.h>
3939

40-
#define DEFINE_HWSERIAL(name, n) \
41-
HardwareSerial name(USART##n, \
42-
BOARD_USART##n##_TX_PIN, \
43-
BOARD_USART##n##_RX_PIN)
44-
45-
#define DEFINE_HWSERIAL_UART(name, n) \
46-
HardwareSerial name(UART##n, \
47-
BOARD_USART##n##_TX_PIN, \
48-
BOARD_USART##n##_RX_PIN)
49-
50-
#ifdef SERIAL_USB
51-
#if BOARD_HAVE_USART1
52-
DEFINE_HWSERIAL(Serial1, 1);
53-
#endif
54-
#if BOARD_HAVE_USART2
55-
DEFINE_HWSERIAL(Serial2, 2);
56-
#endif
57-
#if BOARD_HAVE_USART3
58-
DEFINE_HWSERIAL(Serial3, 3);
59-
#endif
60-
#if BOARD_HAVE_UART4
61-
DEFINE_HWSERIAL_UART(Serial4, 4);
62-
#endif
63-
#if BOARD_HAVE_UART5
64-
DEFINE_HWSERIAL_UART(Serial5, 5);
65-
#endif
66-
#if BOARD_HAVE_USART6
67-
DEFINE_HWSERIAL_UART(Serial6, 6);
68-
#endif
69-
#else
70-
#if BOARD_HAVE_USART1
71-
DEFINE_HWSERIAL(Serial, 1);
72-
#endif
73-
#if BOARD_HAVE_USART2
74-
DEFINE_HWSERIAL(Serial1, 2);
75-
#endif
76-
#if BOARD_HAVE_USART3
77-
DEFINE_HWSERIAL(Serial2, 3);
78-
#endif
79-
#if BOARD_HAVE_UART4
80-
DEFINE_HWSERIAL_UART(Serial3, 4);
81-
#endif
82-
#if BOARD_HAVE_UART5
83-
DEFINE_HWSERIAL_UART(Serial4, 5);
84-
#endif
85-
#if BOARD_HAVE_USART6
86-
DEFINE_HWSERIAL_UART(Serial5, 6);
40+
#if 0
41+
42+
#define DEFINE_HWSERIAL(name, n) \
43+
HardwareSerial name(USART##n, \
44+
BOARD_USART##n##_TX_PIN, \
45+
BOARD_USART##n##_RX_PIN)
46+
47+
#define DEFINE_HWSERIAL_UART(name, n) \
48+
HardwareSerial name(UART##n, \
49+
BOARD_USART##n##_TX_PIN, \
50+
BOARD_USART##n##_RX_PIN)
51+
52+
#ifdef SERIAL_USB
53+
#if BOARD_HAVE_USART1
54+
DEFINE_HWSERIAL(Serial1, 1);
55+
#endif
56+
#if BOARD_HAVE_USART2
57+
DEFINE_HWSERIAL(Serial2, 2);
58+
#endif
59+
#if BOARD_HAVE_USART3
60+
DEFINE_HWSERIAL(Serial3, 3);
61+
#endif
62+
#if BOARD_HAVE_UART4
63+
DEFINE_HWSERIAL_UART(Serial4, 4);
64+
#endif
65+
#if BOARD_HAVE_UART5
66+
DEFINE_HWSERIAL_UART(Serial5, 5);
67+
#endif
68+
#if BOARD_HAVE_USART6
69+
DEFINE_HWSERIAL_UART(Serial6, 6);
70+
#endif
71+
#else
72+
#if BOARD_HAVE_USART1
73+
DEFINE_HWSERIAL(Serial, 1);
74+
#endif
75+
#if BOARD_HAVE_USART2
76+
DEFINE_HWSERIAL(Serial1, 2);
77+
#endif
78+
#if BOARD_HAVE_USART3
79+
DEFINE_HWSERIAL(Serial2, 3);
80+
#endif
81+
#if BOARD_HAVE_UART4
82+
DEFINE_HWSERIAL_UART(Serial3, 4);
83+
#endif
84+
#if BOARD_HAVE_UART5
85+
DEFINE_HWSERIAL_UART(Serial4, 5);
86+
#endif
87+
#if BOARD_HAVE_USART6
88+
DEFINE_HWSERIAL_UART(Serial5, 6);
89+
#endif
8790
#endif
91+
8892
#endif
8993
HardwareSerial::HardwareSerial(usart_dev *usart_device,
9094
uint8 tx_pin,

STM32F1/cores/maple/HardwareSerial.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,20 @@ struct usart_dev;
100100
#define SERIAL_9O2 0B00101011
101101

102102

103+
/* Roger Clark
104+
* Moved macros from hardwareSerial.cpp
105+
*/
106+
107+
#define DEFINE_HWSERIAL(name, n) \
108+
HardwareSerial name(USART##n, \
109+
BOARD_USART##n##_TX_PIN, \
110+
BOARD_USART##n##_RX_PIN)
111+
112+
#define DEFINE_HWSERIAL_UART(name, n) \
113+
HardwareSerial name(UART##n, \
114+
BOARD_USART##n##_TX_PIN, \
115+
BOARD_USART##n##_RX_PIN)
116+
103117

104118
/* Roger clark. Changed class inheritance from Print to Stream.
105119
* Also added new functions for peek() and availableForWrite()

STM32F1/cores/maple/Print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ size_t Print::write(const void *buffer, uint32 size) {
6565
}
6666

6767
size_t Print::print(uint8 b, int base) {
68-
print((uint64)b, base);
68+
return print((uint64)b, base);
6969
}
7070

7171
size_t Print::print(const String &s)

STM32F1/cores/maple/libmaple/gpio_f1.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,23 @@ void gpio_set_mode(gpio_dev *dev, uint8 pin, gpio_pin_mode mode) {
138138
}
139139
}
140140

141+
gpio_pin_mode gpio_get_mode(gpio_dev *dev, uint8 pin) {
142+
gpio_reg_map *regs = dev->regs;
143+
__io uint32 *cr = &regs->CRL + (pin >> 3);
144+
uint32 shift = (pin & 0x7) * 4;
145+
uint32 tmp = *cr;
146+
147+
uint32 crMode = (*cr>>shift) & 0x0F;
148+
149+
// could be pull up or pull down. Nee to check the ODR
150+
if (crMode==GPIO_INPUT_PD && ((regs->ODR >> pin) & 0x01) !=0 )
151+
{
152+
crMode = GPIO_INPUT_PU;
153+
}
154+
155+
return(crMode);
156+
}
157+
141158
/*
142159
* AFIO
143160
*/

STM32F1/cores/maple/libmaple/spi_f1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void spi_config_gpios(spi_dev *ignored,
6363
uint8 miso_bit,
6464
uint8 mosi_bit) {
6565
if (as_master) {
66-
gpio_set_mode(nss_dev, nss_bit, GPIO_AF_OUTPUT_PP);
66+
// gpio_set_mode(nss_dev, nss_bit, GPIO_AF_OUTPUT_PP);// Roger Clark. Commented out, so that NSS can be driven as a normal GPIO pin during SPI use
6767
gpio_set_mode(comm_dev, sck_bit, GPIO_AF_OUTPUT_PP);
6868
gpio_set_mode(comm_dev, miso_bit, GPIO_INPUT_FLOATING);
6969
gpio_set_mode(comm_dev, mosi_bit, GPIO_AF_OUTPUT_PP);

STM32F1/cores/maple/libmaple/stm32f1/performance/isrs.S

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,14 @@ __default_handler:
163163
.weak __irq_tim1_cc
164164
.globl __irq_tim1_cc
165165
.set __irq_tim1_cc, __default_handler
166-
.weak __irq_tim2
167-
.globl __irq_tim2
168-
.set __irq_tim2, __default_handler
169-
.weak __irq_tim3
170-
.globl __irq_tim3
171-
.set __irq_tim3, __default_handler
172-
.weak __irq_tim4
173-
.globl __irq_tim4
174-
.set __irq_tim4, __default_handler
166+
167+
.weakref __irq_tim2, __default_handler
168+
.globl __irq_tim2
169+
.weakref __irq_tim3, __default_handler
170+
.globl __irq_tim3
171+
.weakref __irq_tim4, __default_handler
172+
.globl __irq_tim4
173+
175174
.weak __irq_i2c1_ev
176175
.globl __irq_i2c1_ev
177176
.set __irq_i2c1_ev, __default_handler
@@ -260,4 +259,4 @@ __default_handler:
260259
.weak __irq_dma2_channel4_5
261260
.globl __irq_dma2_channel4_5
262261
.set __irq_dma2_channel4_5, __default_handler
263-
#endif /* STM32_HIGH_DENSITY */
262+
#endif /* STM32_HIGH_DENSITY */

0 commit comments

Comments
 (0)