Skip to content

Commit 14b9f33

Browse files
committed
Merge remote-tracking branch 'refs/remotes/rogerclarkmelbourne/master' into F1-USART---buffered-interrupt-based-TX-(static-TX-buffer)
2 parents d353dd3 + 388e8ef commit 14b9f33

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

STM32F1/cores/maple/HardwareSerial.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ void HardwareSerial::end(void) {
159159
*/
160160

161161
int HardwareSerial::read(void) {
162-
// Block until a byte becomes available, to save user confusion.
163-
while (!this->available())
164-
;
165-
return usart_getc(this->usart_device);
162+
if(usart_data_available(usart_device) > 0) {
163+
return usart_getc(usart_device);
164+
} else {
165+
return -1;
166+
}
166167
}
167168

168169
int HardwareSerial::available(void) {

STM32F3/cores/maple/wirish/HardwareSerial.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ void HardwareSerial::end(void) {
118118
* I/O
119119
*/
120120

121-
uint8 HardwareSerial::read(void) {
122-
// Block until a byte becomes available, to save user confusion.
123-
while (!this->available())
124-
;
125-
return usart_getc(this->usart_device);
121+
int HardwareSerial::read(void) {
122+
if(usart_data_available(usart_device) > 0) {
123+
return usart_getc(usart_device);
124+
} else {
125+
return -1;
126+
}
126127
}
127128

128129
uint32 HardwareSerial::available(void) {

STM32F3/cores/maple/wirish/HardwareSerial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class HardwareSerial : public Print {
6262

6363
/* I/O */
6464
uint32 available(void);
65-
uint8 read(void);
65+
int read(void);
6666
void flush(void);
6767
virtual void write(unsigned char);
6868
using Print::write;

tools/linux/stlink_upload

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/bin/bash
2+
$(dirname $0)/stlink/st-flash write "$4" 0x8000000
3+
exit 0
4+
5+
## Remove the lines 2 and 3 (above) if you want this script to wait until the Serial device has been enumerated and loaded before the script exits
26

37
# Check for leaf device.
48
function leaf_status()

0 commit comments

Comments
 (0)