File tree Expand file tree Collapse file tree 4 files changed +153
-132
lines changed Expand file tree Collapse file tree 4 files changed +153
-132
lines changed Original file line number Diff line number Diff line change @@ -33,80 +33,48 @@ void HardwareSerial::setDebugOutput(bool en)
3333 return ;
3434 }
3535 if (en) {
36- if (_uart->txEnabled ) {
37- uartSetDebug (_uart);
38- } else {
39- uartSetDebug (0 );
40- }
36+ uartSetDebug (_uart);
4137 } else {
4238 if (uartGetDebug () == _uart_nr) {
4339 uartSetDebug (0 );
4440 }
4541 }
4642}
4743
48- bool HardwareSerial::isTxEnabled (void )
49- {
50- if (_uart == 0 ) {
51- return false ;
52- }
53- return _uart->txEnabled ;
54- }
55-
56- bool HardwareSerial::isRxEnabled (void )
57- {
58- if (_uart == 0 ) {
59- return false ;
60- }
61- return _uart->rxEnabled ;
62- }
63-
6444int HardwareSerial::available (void )
6545{
66- if (_uart && _uart->rxEnabled ) {
67- return uartAvailable (_uart);
68- }
69- return 0 ;
46+ return uartAvailable (_uart);
7047}
7148
7249int HardwareSerial::peek (void )
7350{
74- if (_uart && _uart-> rxEnabled ) {
51+ if (available () ) {
7552 return uartPeek (_uart);
7653 }
7754 return -1 ;
7855}
7956
8057int HardwareSerial::read (void )
8158{
82- if (_uart && _uart-> rxEnabled ) {
59+ if (available () ) {
8360 return uartRead (_uart);
8461 }
8562 return -1 ;
8663}
8764
8865void HardwareSerial::flush ()
8966{
90- if (_uart == 0 || !_uart->txEnabled ) {
91- return ;
92- }
9367 uartFlush (_uart);
9468}
9569
9670size_t HardwareSerial::write (uint8_t c)
9771{
98- if (_uart == 0 || !_uart->txEnabled ) {
99- return 0 ;
100- }
10172 uartWrite (_uart, c);
10273 return 1 ;
10374}
10475
10576size_t HardwareSerial::write (const uint8_t *buffer, size_t size)
10677{
107- if (_uart == 0 || !_uart->txEnabled ) {
108- return 0 ;
109- }
11078 uartWriteBuf (_uart, buffer, size);
11179 return size;
11280}
Original file line number Diff line number Diff line change @@ -65,8 +65,6 @@ class HardwareSerial: public Stream
6565 operator bool () const ;
6666
6767 void setDebugOutput (bool );
68- bool isTxEnabled (void );
69- bool isRxEnabled (void );
7068
7169protected:
7270 int _uart_nr;
You can’t perform that action at this time.
0 commit comments