Commit 6d515555 authored by Martino Facchin's avatar Martino Facchin

Serial: add bind() API for transparent passthrough

parent c8a1dd99
...@@ -168,11 +168,14 @@ class UartClass : public HardwareSerial ...@@ -168,11 +168,14 @@ class UartClass : public HardwareSerial
using Print::write; // pull in write(str) and write(buf, size) from Print using Print::write; // pull in write(str) and write(buf, size) from Print
explicit operator bool() { return true; } explicit operator bool() { return true; }
void bind(UartClass& ser) {bound = &ser; }
// Interrupt handlers - Not intended to be called externally // Interrupt handlers - Not intended to be called externally
inline void _rx_complete_irq(void); inline void _rx_complete_irq(void);
void _tx_data_empty_irq(void); void _tx_data_empty_irq(void);
private: private:
void _poll_tx_data_empty(void); void _poll_tx_data_empty(void);
UartClass* bound = NULL;
}; };
#if defined(HWSERIAL0) #if defined(HWSERIAL0)
......
...@@ -66,6 +66,9 @@ void UartClass::_rx_complete_irq(void) ...@@ -66,6 +66,9 @@ void UartClass::_rx_complete_irq(void)
_rx_buffer[_rx_buffer_head] = c; _rx_buffer[_rx_buffer_head] = c;
_rx_buffer_head = i; _rx_buffer_head = i;
} }
if (bound != NULL) {
bound->write(c);
}
} else { } else {
// Parity error, read byte but discard it // Parity error, read byte but discard it
(*_hwserial_module).RXDATAL; (*_hwserial_module).RXDATAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment