Skip to content

Commit bb8bbba

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into Black_F4_variant
# Conflicts: # STM32F4/cores/maple/libmaple/HardwareSerial.cpp # STM32F4/cores/maple/libmaple/adc.h # STM32F4/cores/maple/libmaple/dmaF4.c # STM32F4/cores/maple/libmaple/dmaF4.h # STM32F4/cores/maple/libmaple/fsmc.c # STM32F4/cores/maple/libmaple/gpio.c # STM32F4/cores/maple/libmaple/rcc.c # STM32F4/cores/maple/libmaple/spi_f4.c # STM32F4/cores/maple/wirish_time.h # STM32F4/cores/maple/wirish_types.h # STM32F4/libraries/SPI/src/SPI.cpp # STM32F4/libraries/SPI/src/SPI.h # STM32F4/platform.txt # STM32F4/system/libmaple/Arduino.h # STM32F4/variants/generic_f407v/generic_f407v.h # STM32F4/variants/generic_f407v/ld/common.inc # STM32F4/variants/generic_f407v/ld/jtag.ld # STM32F4/variants/generic_f407v/pin_map.c # STM32F4/variants/generic_f407v/wirish/start.S
2 parents 54a2309 + 1c1c90e commit bb8bbba

123 files changed

Lines changed: 26992 additions & 386 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ other/maple-bootloader/*~
99
tools/src/stm32flash_serial/src/parsers/parsers.a
1010
*.bak
1111
*.1
12+
STM32F4/cores/maple/libmaple/adc.h

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ This repo contains, the "Hardware" files to support STM32 based boards on Arduin
1313

1414
***PRIMARY SUPPORT FORUM: http://www.stm32duino.com/***
1515

16+
***We are also on Gitter https://gitter.im/stm32duino/Lobby/***
17+
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/stm32duino/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
18+
1619
##Background & Support:
1720
* Based on https://github.com/bobc/maple-asp, which is in turn based on LibMaple by Leaflabs
1821
* **Please read the wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki) for full details**

STM32F1/cores/maple/HardwareSerial.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ size_t HardwareSerial::write(unsigned char ch) {
193193
return 1;
194194
}
195195

196+
/* edogaldo: Waits for the transmission of outgoing serial data to complete (Arduino 1.0 api specs) */
196197
void HardwareSerial::flush(void) {
197-
usart_reset_rx(this->usart_device);
198-
usart_reset_tx(this->usart_device);
198+
while(!rb_is_empty(this->usart_device->wb)); // wait for TX buffer empty
199+
while(!((this->usart_device->regs->SR) & (1<<USART_SR_TC_BIT))); // wait for TC (Transmission Complete) flag set
199200
}

STM32F1/cores/maple/itoa.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@ extern char* ltoa( long value, char *string, int radix )
120120

121121
return string;
122122
}
123-
123+
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
124+
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
125+
extern char* utoa( unsigned value, char *string, int radix )
126+
#else
124127
extern char* utoa( unsigned long value, char *string, int radix )
128+
#endif
125129
{
126130
return ultoa( value, string, radix ) ;
127131
}

STM32F1/cores/maple/itoa.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ extern void itoa( int n, char s[] ) ;
3131

3232
extern char* itoa( int value, char *string, int radix ) ;
3333
extern char* ltoa( long value, char *string, int radix ) ;
34+
#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 9 || \
35+
(__GNUC_MINOR__ == 9 && __GNUC_PATCHLEVEL__ > 2)))
36+
extern char* utoa( unsigned value, char *string, int radix ) ;
37+
#else
3438
extern char* utoa( unsigned long value, char *string, int radix ) ;
39+
#endif
3540
extern char* ultoa( unsigned long value, char *string, int radix ) ;
3641
#endif /* 0 */
3742

STM32F1/cores/maple/libmaple/dma_f1.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ void dma_set_per_addr(dma_dev *dev, dma_channel channel, __io void *addr) {
341341
* @see dma_attach_interrupt()
342342
* @see dma_enable()
343343
*/
344-
__deprecated
345344
void dma_setup_transfer(dma_dev *dev,
346345
dma_channel channel,
347346
__io void *peripheral_address,

STM32F1/cores/maple/libmaple/gpio_f1.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ gpio_pin_mode gpio_get_mode(gpio_dev *dev, uint8 pin) {
142142
gpio_reg_map *regs = dev->regs;
143143
__io uint32 *cr = &regs->CRL + (pin >> 3);
144144
uint32 shift = (pin & 0x7) * 4;
145-
uint32 tmp = *cr;
146145

147146
uint32 crMode = (*cr>>shift) & 0x0F;
148147

STM32F1/cores/maple/libmaple/usb/stm32f1/usb_cdcacm.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,13 @@ void usb_cdcacm_enable(gpio_dev *disc_dev, uint8 disc_bit) {
384384
/* Present ourselves to the host. Writing 0 to "disc" pin must
385385
* pull USB_DP pin up while leaving USB_DM pulled down by the
386386
* transceiver. See USB 2.0 spec, section 7.1.7.3. */
387-
gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP);
388-
gpio_write_bit(disc_dev, disc_bit, 0);
389-
387+
388+
if (disc_dev!=NULL)
389+
{
390+
gpio_set_mode(disc_dev, disc_bit, GPIO_OUTPUT_PP);
391+
gpio_write_bit(disc_dev, disc_bit, 0);
392+
}
393+
390394
/* Initialize the USB peripheral. */
391395
usb_init_usblib(USBLIB, ep_int_in, ep_int_out);
392396
}
@@ -395,7 +399,10 @@ void usb_cdcacm_disable(gpio_dev *disc_dev, uint8 disc_bit) {
395399
/* Turn off the interrupt and signal disconnect (see e.g. USB 2.0
396400
* spec, section 7.1.7.3). */
397401
nvic_irq_disable(NVIC_USB_LP_CAN_RX0);
398-
gpio_write_bit(disc_dev, disc_bit, 1);
402+
if (disc_dev!=NULL)
403+
{
404+
gpio_write_bit(disc_dev, disc_bit, 1);
405+
}
399406
}
400407

401408
void usb_cdcacm_putc(char ch) {

STM32F1/cores/maple/stm32f1/wirish_digital_f1.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ void pinMode(uint8 pin, WiringPinMode mode) {
8080
gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, outputMode);
8181

8282
if (PIN_MAP[pin].timer_device != NULL) {
83-
/* Enable/disable timer channels if we're switching into or
84-
* out of PWM. */
83+
if ( pwm ) { // we're switching into PWM, enable timer channels
8584
timer_set_mode(PIN_MAP[pin].timer_device,
8685
PIN_MAP[pin].timer_channel,
87-
pwm ? TIMER_PWM : TIMER_DISABLED);
86+
TIMER_PWM );
87+
} else { // disable channel output in non pwm-Mode
88+
timer_cc_disable(PIN_MAP[pin].timer_device,
89+
PIN_MAP[pin].timer_channel);
90+
}
8891
}
8992
}

STM32F1/cores/maple/usb_serial.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ static void ifaceSetupHook(unsigned, void*);
5454
*/
5555

5656
#define USB_TIMEOUT 50
57+
#if BOARD_HAVE_SERIALUSB
58+
bool USBSerial::_hasBegun = false;
59+
#endif
5760

5861
USBSerial::USBSerial(void) {
5962
#if !BOARD_HAVE_SERIALUSB
@@ -62,7 +65,12 @@ USBSerial::USBSerial(void) {
6265
}
6366

6467
void USBSerial::begin(void) {
68+
6569
#if BOARD_HAVE_SERIALUSB
70+
if (_hasBegun)
71+
return;
72+
_hasBegun = true;
73+
6674
usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT);
6775
usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, rxHook);
6876
usb_cdcacm_set_hooks(USB_CDCACM_HOOK_IFACE_SETUP, ifaceSetupHook);
@@ -75,6 +83,7 @@ void USBSerial::begin(unsigned long ignoreBaud)
7583
volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud;
7684

7785
ignoreBaud=removeCompilerWarningsIgnoreBaud;
86+
begin();
7887
}
7988
void USBSerial::begin(unsigned long ignoreBaud, uint8_t ignore)
8089
{
@@ -83,13 +92,16 @@ volatile uint8_t removeCompilerWarningsIgnore=ignore;
8392

8493
ignoreBaud=removeCompilerWarningsIgnoreBaud;
8594
ignore=removeCompilerWarningsIgnore;
95+
begin();
8696
}
8797

8898
void USBSerial::end(void) {
8999
#if BOARD_HAVE_SERIALUSB
90100
usb_cdcacm_disable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT);
91101
usb_cdcacm_remove_hooks(USB_CDCACM_HOOK_RX | USB_CDCACM_HOOK_IFACE_SETUP);
102+
_hasBegun = false;
92103
#endif
104+
93105
}
94106

95107
size_t USBSerial::write(uint8 ch) {

0 commit comments

Comments
 (0)