File tree Expand file tree Collapse file tree
STM32F3/cores/maple/wirish Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,10 +159,11 @@ void HardwareSerial::end(void) {
159159 */
160160
161161int 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
168169int HardwareSerial::available (void ) {
Original file line number Diff line number Diff 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
128129uint32 HardwareSerial::available (void ) {
Original file line number Diff line number Diff 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;
Original file line number Diff line number Diff line change 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.
48function leaf_status()
You can’t perform that action at this time.
0 commit comments