Debian Codegraph @

cores/arduino/HardwareSerial1.cpp

raw
1 /*
2 HardwareSerial1.cpp - Hardware serial library for Wiring
3 Copyright (c) 2006 Nicholas Zambetti. All right reserved.
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Modified 23 November 2006 by David A. Mellis
20 Modified 28 September 2010 by Mark Sproul
21 Modified 14 August 2012 by Alarus
22 Modified 3 December 2013 by Matthijs Kooijman
23 */
24
25 #include "Arduino.h"
26 #include "HardwareSerial.h"
27 #include "HardwareSerial_private.h"
28
29 // Each HardwareSerial is defined in its own file, since the linker pulls
30 // in the entire file when any element inside is used. --gc-sections can
31 // additionally cause unused symbols to be dropped, but ISRs have the
32 // "used" attribute so are never dropped and they keep the
33 // HardwareSerial instance in as well. Putting each instance in its own
34 // file prevents the linker from pulling in any unused instances in the
35 // first place.
36
37 #if defined(HAVE_HWSERIAL1)
38
39 #if defined(UART1_RX_vect)
40 ISR(UART1_RX_vect)
41 #elif defined(USART1_RX_vect)
42 ISR(USART1_RX_vect)
43 #else
44 #error "Don't know what the Data Register Empty vector is called for Serial1"
45 #endif
46 {
47 Serial1._rx_complete_irq();
48 }
49
50 #if defined(UART1_UDRE_vect)
51 ISR(UART1_UDRE_vect)
52 #elif defined(USART1_UDRE_vect)
53 ISR(USART1_UDRE_vect)
54 #else
55 #error "Don't know what the Data Register Empty vector is called for Serial1"
56 #endif
57 {
58 Serial1._tx_udr_empty_irq();
59 }
60
61 HardwareSerial Serial1(&UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1);
62
63 // Function that can be weakly referenced by serialEventRun to prevent
64 // pulling in this file if it's not otherwise used.
65 bool Serial1_available() {
66 return Serial1.available();
67 }
68
69 #endif // HAVE_HWSERIAL1