From 912098d5b84a0c73d7743c815c6c469a134af99b Mon Sep 17 00:00:00 2001 From: rogerclarkmelbourne Date: Sun, 31 May 2015 18:06:19 +1000 Subject: [PATCH] Updated with commits that had been applied to Leaflabs:libmaple since the original copy of the repo was taken (by BobC) in Nov 2014 --- STM32F1/cores/maple/usb_serial.cpp | 8 ++++++++ STM32F1/system/libmaple/dma_private.h | 3 ++- STM32F1/system/libmaple/usart_private.h | 17 ++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/STM32F1/cores/maple/usb_serial.cpp b/STM32F1/cores/maple/usb_serial.cpp index c11fd15..fcc39b1 100644 --- a/STM32F1/cores/maple/usb_serial.cpp +++ b/STM32F1/cores/maple/usb_serial.cpp @@ -72,9 +72,17 @@ void USBSerial::begin(void) { //Roger Clark. Two new begin functions has been added so that normal Arduino Sketches that use Serial.begin(xxx) will compile. void USBSerial::begin(unsigned long ignoreBaud) { +volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud; + + ignoreBaud=removeCompilerWarningsIgnoreBaud; } void USBSerial::begin(unsigned long ignoreBaud, uint8_t ignore) { +volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud; +volatile uint8_t removeCompilerWarningsIgnore=ignore; + + ignoreBaud=removeCompilerWarningsIgnoreBaud; + ignore=removeCompilerWarningsIgnore; } void USBSerial::end(void) { diff --git a/STM32F1/system/libmaple/dma_private.h b/STM32F1/system/libmaple/dma_private.h index 82f5fc1..c0ee11f 100644 --- a/STM32F1/system/libmaple/dma_private.h +++ b/STM32F1/system/libmaple/dma_private.h @@ -38,10 +38,11 @@ * in the series support files, which need dma_irq_handler().) */ #ifdef DMA_GET_HANDLER static __always_inline void dma_irq_handler(dma_dev *dev, dma_tube tube) { - dma_clear_isr_bits(dev, tube); /* in case handler doesn't */ + void (*handler)(void) = DMA_GET_HANDLER(dev, tube); if (handler) { handler(); + dma_clear_isr_bits(dev, tube); /* in case handler doesn't */ } } #endif diff --git a/STM32F1/system/libmaple/usart_private.h b/STM32F1/system/libmaple/usart_private.h index 8e8e11b..9bc0527 100644 --- a/STM32F1/system/libmaple/usart_private.h +++ b/STM32F1/system/libmaple/usart_private.h @@ -38,14 +38,21 @@ #include static __always_inline void usart_irq(ring_buffer *rb, usart_reg_map *regs) { + /* We can get RXNE and ORE interrupts here. Only RXNE signifies + * availability of a byte in DR. + * + * See table 198 (sec 27.4, p809) in STM document RM0008 rev 15. + * We enable RXNEIE. */ + if (regs->SR & USART_SR_RXNE) { #ifdef USART_SAFE_INSERT - /* If the buffer is full and the user defines USART_SAFE_INSERT, - * ignore new bytes. */ - rb_safe_insert(rb, (uint8)regs->DR); + /* If the buffer is full and the user defines USART_SAFE_INSERT, + * ignore new bytes. */ + rb_safe_insert(rb, (uint8)regs->DR); #else - /* By default, push bytes around in the ring buffer. */ - rb_push_insert(rb, (uint8)regs->DR); + /* By default, push bytes around in the ring buffer. */ + rb_push_insert(rb, (uint8)regs->DR); #endif + } } uint32 _usart_clock_freq(usart_dev *dev);