HardwareSerial3.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. HardwareSerial3.cpp - Hardware serial library for Wiring
  3. Copyright (c) 2006 Nicholas Zambetti. All right reserved.
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. Modified 23 November 2006 by David A. Mellis
  16. Modified 28 September 2010 by Mark Sproul
  17. Modified 14 August 2012 by Alarus
  18. Modified 3 December 2013 by Matthijs Kooijman
  19. */
  20. #include "Arduino.h"
  21. #include "HardwareSerial.h"
  22. #include "HardwareSerial_private.h"
  23. // Each HardwareSerial is defined in its own file, sine the linker pulls
  24. // in the entire file when any element inside is used. --gc-sections can
  25. // additionally cause unused symbols to be dropped, but ISRs have the
  26. // "used" attribute so are never dropped and they keep the
  27. // HardwareSerial instance in as well. Putting each instance in its own
  28. // file prevents the linker from pulling in any unused instances in the
  29. // first place.
  30. #if defined(HAVE_HWSERIAL3)
  31. ISR(USART3_RX_vect)
  32. {
  33. Serial3._rx_complete_irq();
  34. }
  35. ISR(USART3_UDRE_vect)
  36. {
  37. Serial3._tx_udr_empty_irq();
  38. }
  39. HardwareSerial Serial3(&UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3);
  40. // Function that can be weakly referenced by serialEventRun to prevent
  41. // pulling in this file if it's not otherwise used.
  42. bool Serial3_available() {
  43. return Serial3.available();
  44. }
  45. #endif // HAVE_HWSERIAL3