sanguino/cores/arduino/HardwareSerial.h

Fri, 17 Nov 2017 10:13:31 +0100

author
mdd
date
Fri, 17 Nov 2017 10:13:31 +0100
changeset 3
770b218a4931
parent 2
b373b0288715
permissions
-rw-r--r--

proper configuration, homing and planner optimization

2
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
1 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
2 HardwareSerial.h - Hardware serial library for Wiring
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
3 Copyright (c) 2006 Nicholas Zambetti. All right reserved.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
4
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
7 License as published by the Free Software Foundation; either
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
9
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
13 Lesser General Public License for more details.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
14
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
18
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
19 Modified 28 September 2010 by Mark Sproul
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
20 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
21
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
22 #ifndef HardwareSerial_h
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
23 #define HardwareSerial_h
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
24
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
25 #include <inttypes.h>
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
26
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
27 #include "Stream.h"
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
28
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
29 struct ring_buffer;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
30
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
31 class HardwareSerial : public Stream
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
32 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
33 private:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
34 ring_buffer *_rx_buffer;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
35 ring_buffer *_tx_buffer;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
36 volatile uint8_t *_ubrrh;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
37 volatile uint8_t *_ubrrl;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
38 volatile uint8_t *_ucsra;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
39 volatile uint8_t *_ucsrb;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
40 volatile uint8_t *_udr;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
41 uint8_t _rxen;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
42 uint8_t _txen;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
43 uint8_t _rxcie;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
44 uint8_t _udrie;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
45 uint8_t _u2x;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
46 public:
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
47 HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
48 volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
49 volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
50 volatile uint8_t *udr,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
51 uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
52 void begin(unsigned long);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
53 void end();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
54 virtual int available(void);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
55 virtual int peek(void);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
56 virtual int read(void);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
57 virtual void flush(void);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
58 virtual size_t write(uint8_t);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
59 using Print::write; // pull in write(str) and write(buf, size) from Print
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
60 operator bool();
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
61 };
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
62
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
63 #if defined(UBRRH) || defined(UBRR0H)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
64 extern HardwareSerial Serial;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
65 #elif defined(USBCON)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
66 #include "USBAPI.h"
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
67 // extern HardwareSerial Serial_;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
68 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
69 #if defined(UBRR1H)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
70 extern HardwareSerial Serial1;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
71 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
72 #if defined(UBRR2H)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
73 extern HardwareSerial Serial2;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
74 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
75 #if defined(UBRR3H)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
76 extern HardwareSerial Serial3;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
77 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
78
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
79 extern void serialEventRun(void) __attribute__((weak));
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
80
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
81 #endif

mercurial