Skip to content

Commit 179fcdb

Browse files
committed
Moving things around - creating the hardware directory and sticking all the avr code, etc. in there.
0 parents  commit 179fcdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+7522
-0
lines changed

core/arduino/HardwareSerial.cpp

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
/*
2+
HarwareSerial.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+
*/
21+
22+
#include <stdio.h>
23+
#include <string.h>
24+
#include <inttypes.h>
25+
#include "wiring.h"
26+
27+
#include "HardwareSerial.h"
28+
29+
// Constructors ////////////////////////////////////////////////////////////////
30+
31+
HardwareSerial::HardwareSerial(uint8_t uart)
32+
{
33+
//if(uart == 0){
34+
// _uart = 0;
35+
//}else{
36+
// _uart = 1;
37+
//}
38+
}
39+
40+
// Public Methods //////////////////////////////////////////////////////////////
41+
42+
void HardwareSerial::begin(long speed)
43+
{
44+
beginSerial(speed);
45+
}
46+
47+
uint8_t HardwareSerial::available(void)
48+
{
49+
return serialAvailable();
50+
}
51+
52+
int HardwareSerial::read(void)
53+
{
54+
return serialRead();
55+
}
56+
57+
void HardwareSerial::flush()
58+
{
59+
serialFlush();
60+
}
61+
62+
void HardwareSerial::print(char c)
63+
{
64+
printByte(c);
65+
}
66+
67+
void HardwareSerial::print(const char c[])
68+
{
69+
printString(c);
70+
}
71+
72+
void HardwareSerial::print(uint8_t b)
73+
{
74+
printByte(b);
75+
}
76+
77+
void HardwareSerial::print(int n)
78+
{
79+
print((long) n);
80+
}
81+
82+
void HardwareSerial::print(unsigned int n)
83+
{
84+
print((unsigned long) n);
85+
}
86+
87+
void HardwareSerial::print(long n)
88+
{
89+
if (n < 0) {
90+
print('-');
91+
n = -n;
92+
}
93+
printNumber(n, 10);
94+
}
95+
96+
void HardwareSerial::print(unsigned long n)
97+
{
98+
printNumber(n, 10);
99+
}
100+
101+
void HardwareSerial::print(long n, int base)
102+
{
103+
if (base == 0)
104+
print((char) n);
105+
else if (base == 10)
106+
print(n);
107+
else
108+
printNumber(n, base);
109+
}
110+
111+
void HardwareSerial::println(void)
112+
{
113+
print('\r');
114+
print('\n');
115+
}
116+
117+
void HardwareSerial::println(char c)
118+
{
119+
print(c);
120+
println();
121+
}
122+
123+
void HardwareSerial::println(const char c[])
124+
{
125+
print(c);
126+
println();
127+
}
128+
129+
void HardwareSerial::println(uint8_t b)
130+
{
131+
print(b);
132+
println();
133+
}
134+
135+
void HardwareSerial::println(int n)
136+
{
137+
print(n);
138+
println();
139+
}
140+
141+
void HardwareSerial::println(long n)
142+
{
143+
print(n);
144+
println();
145+
}
146+
147+
void HardwareSerial::println(unsigned long n)
148+
{
149+
print(n);
150+
println();
151+
}
152+
153+
void HardwareSerial::println(long n, int base)
154+
{
155+
print(n, base);
156+
println();
157+
}
158+
159+
// Private Methods /////////////////////////////////////////////////////////////
160+
161+
void HardwareSerial::printNumber(unsigned long n, uint8_t base)
162+
{
163+
printIntegerInBase(n, base);
164+
}
165+
166+
// Preinstantiate Objects //////////////////////////////////////////////////////
167+
168+
HardwareSerial Serial = HardwareSerial(0);
169+
//HardwareSerial Serial1 = HardwareSerial(1);
170+

core/arduino/HardwareSerial.h

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
HardwareSerial.h - 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+
20+
#ifndef HardwareSerial_h
21+
#define HardwareSerial_h
22+
23+
#include <inttypes.h>
24+
25+
#define DEC 10
26+
#define HEX 16
27+
#define OCT 8
28+
#define BIN 2
29+
#define BYTE 0
30+
31+
class HardwareSerial
32+
{
33+
private:
34+
//uint8_t _uart;
35+
void printNumber(unsigned long, uint8_t);
36+
public:
37+
HardwareSerial(uint8_t);
38+
void begin(long);
39+
uint8_t available(void);
40+
int read(void);
41+
void flush(void);
42+
void print(char);
43+
void print(const char[]);
44+
void print(uint8_t);
45+
void print(int);
46+
void print(unsigned int);
47+
void print(long);
48+
void print(unsigned long);
49+
void print(long, int);
50+
void println(void);
51+
void println(char);
52+
void println(const char[]);
53+
void println(uint8_t);
54+
void println(int);
55+
void println(long);
56+
void println(unsigned long);
57+
void println(long, int);
58+
};
59+
60+
extern HardwareSerial Serial;
61+
//extern HardwareSerial Serial1;
62+
63+
#endif
64+

0 commit comments

Comments
 (0)