diff --git a/cores/arduino/Uart.cpp b/cores/arduino/Uart.cpp index 19c17563234d549f3439529cf536132cd67e1ef7..954a126a4ae5f683669967f571b2e94e56360379 100644 --- a/cores/arduino/Uart.cpp +++ b/cores/arduino/Uart.cpp @@ -66,15 +66,25 @@ int Uart::read() return rxBuffer.read_char(); } -size_t Uart::write(uint8_t data) +size_t Uart::write(const uint8_t data) { - if(txBuffer.isFull()) - return 0; - - txBuffer.store_char(data); + sercom->writeDataUART(data); return 1; } +size_t Uart::write(const char * data) +{ + size_t writed = 0; + + while(*data != '\0') + { + writed += write(*data); + ++data; + } + + return writed; +} + SercomNumberStopBit Uart::extractNbStopBit(uint8_t config) { switch(config & HARDSER_STOP_BIT_MASK) @@ -124,4 +134,9 @@ SercomParityMode Uart::extractParity(uint8_t config) } } -Uart Serial = Uart(SERCOM::sercom0); \ No newline at end of file +Uart Serial = Uart(SERCOM::sercom0); + +void SERCOM0_Handler() +{ + Serial.IrqHandler(); +} \ No newline at end of file diff --git a/cores/arduino/Uart.h b/cores/arduino/Uart.h index fb3a776ff832bc5c55bb75a8e10236252eb92a49..84ea558de0d0be5b8ba74ad6b12be3df99670259 100644 --- a/cores/arduino/Uart.h +++ b/cores/arduino/Uart.h @@ -19,7 +19,8 @@ class Uart : public HardwareSerial int peek(); int read(); void flush(); - size_t write(const uint8_t c); + size_t write(const uint8_t data); + size_t write(const char * data); void IrqHandler(); diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index d99dca55e1e6891b88f3c981c37fd05cba7b2c0a..b8fad9cba0ba5952358dcbc3a2682edcd99d78ce 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -347,9 +347,9 @@ void TwoWire::onService(void) }*/ -TwoWire Wire = TwoWire(SERCOM::sercom3); +TwoWire Wire(SERCOM::sercom3); -void WIRE_ISR_HANDLER(void) { +void SERCOM3_Handler(void) { Wire.onService(); } diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h index b3d2ab4cfd67e5c7666ee07f260b9b085505f878..7ae75e39c4273d26653671a2a4c2e80ddec31d01 100644 --- a/libraries/Wire/Wire.h +++ b/libraries/Wire/Wire.h @@ -99,8 +99,6 @@ class TwoWire : public Stream { //static const uint32_t XMIT_TIMEOUT = 100000; }; -#if WIRE_INTERFACES_COUNT > 0 extern TwoWire Wire; -#endif #endif