Skip to content

Commit 37cdca0

Browse files
committed
Merge pull request #7 from rogerclarkmelbourne/master
Resync to Roger's
2 parents 30aa4a6 + d899697 commit 37cdca0

417 files changed

Lines changed: 37822 additions & 8845 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.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ other/maple-bootloader/cscope.out
66
other/maple-bootloader/build
77
other/maple-bootloader/*~
88
*.o
9-
tools/src/stm32flash/src/parsers/parsers.a
9+
tools/src/stm32flash_serial/src/parsers/parsers.a

.gitmodules

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
[submodule "tools/src/texane-stlink"]
88
path = tools/src/texane-stlink
99
url = https://github.com/texane/stlink
10-
[submodule "tools/src/dfu-util"]
11-
path = tools/src/dfu-util
12-
url = https://gitorious.org/dfu-util/dfu-util.git
10+
[submodule "STM32duino-bootloader"]
11+
path = STM32duino-bootloader
12+
url = https://github.com/rogerclarkmelbourne/STM32duino-bootloader.git
13+
[submodule "STM32F1/libraries/TFT_ILI9163C"]
14+
path = STM32F1/libraries/TFT_ILI9163C
15+
url = https://github.com/victorpv/TFT_ILI9163C.git
16+
[submodule "STM32F1/libraries/Ethernet_STM"]
17+
path = STM32F1/libraries/Ethernet_STM
18+
url = https://github.com/Serasidis/Ethernet_STM

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: 104 additions & 79 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/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/i2c.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ int32 i2c_master_xfer(i2c_dev *dev,
235235

236236
i2c_enable_irq(dev, I2C_IRQ_EVENT);
237237
i2c_start_condition(dev);
238-
238+
239239
rc = wait_for_state_change(dev, I2C_STATE_XFER_DONE, timeout);
240240
if (rc < 0) {
241241
goto out;
@@ -347,9 +347,20 @@ void _i2c_irq_handler(i2c_dev *dev) {
347347
* register. We should get another TXE interrupt
348348
* immediately to fill DR again.
349349
*/
350-
if (msg->length != 1) {
350+
if (msg->length > 1) {
351351
i2c_write(dev, msg->data[msg->xferred++]);
352-
}
352+
} else if (msg->length == 0) { /* We're just sending an address */
353+
i2c_stop_condition(dev);
354+
/*
355+
* Turn off event interrupts to keep BTF from firing until
356+
* the end of the stop condition. Why on earth they didn't
357+
* have a start/stop condition request clear BTF is beyond
358+
* me.
359+
*/
360+
i2c_disable_irq(dev, I2C_IRQ_EVENT);
361+
I2C_CRUMB(STOP_SENT, 0, 0);
362+
dev->state = I2C_STATE_XFER_DONE;
363+
} /* else we're just sending one byte */
353364
}
354365
sr1 = sr2 = 0;
355366
}
@@ -456,7 +467,7 @@ void _i2c_irq_handler(i2c_dev *dev) {
456467
void _i2c_irq_error_handler(i2c_dev *dev) {
457468
I2C_CRUMB(ERROR_ENTRY, dev->regs->SR1, dev->regs->SR2);
458469

459-
dev->error_flags = dev->regs->SR2 & (I2C_SR1_BERR |
470+
dev->error_flags = dev->regs->SR1 & (I2C_SR1_BERR |
460471
I2C_SR1_ARLO |
461472
I2C_SR1_AF |
462473
I2C_SR1_OVR);

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);

0 commit comments

Comments
 (0)