aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino')
-rwxr-xr-xcores/arduino/HardwareSerial.cpp126
-rwxr-xr-xcores/arduino/HardwareSerial.h32
-rwxr-xr-xcores/arduino/WInterrupts.c1
-rwxr-xr-xcores/arduino/WProgram.h1
-rwxr-xr-xcores/arduino/wiring_private.h1
-rwxr-xr-xcores/arduino/wiring_serial.c85
6 files changed, 13 insertions, 233 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index 099c261..76cd9b0 100755
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -26,16 +26,13 @@
#include "HardwareSerial.h"
+void HardwareSerialWrite(uint8_t value, void *instance) {
+ ((HardwareSerial *) instance)->write(value);
+}
+
// Constructors ////////////////////////////////////////////////////////////////
-HardwareSerial::HardwareSerial(uint8_t uart)
-{
- //if(uart == 0){
- // _uart = 0;
- //}else{
- // _uart = 1;
- //}
-}
+HardwareSerial::HardwareSerial() : Print(HardwareSerialWrite) {}
// Public Methods //////////////////////////////////////////////////////////////
@@ -59,118 +56,11 @@ void HardwareSerial::flush()
serialFlush();
}
-void HardwareSerial::print(char c)
-{
- printByte(c);
-}
-
-void HardwareSerial::print(const char c[])
-{
- printString(c);
-}
-
-void HardwareSerial::print(uint8_t b)
-{
- printByte(b);
-}
-
-void HardwareSerial::print(int n)
-{
- print((long) n);
-}
-
-void HardwareSerial::print(unsigned int n)
-{
- print((unsigned long) n);
-}
-
-void HardwareSerial::print(long n)
-{
- if (n < 0) {
- print('-');
- n = -n;
- }
- printNumber(n, 10);
-}
-
-void HardwareSerial::print(unsigned long n)
-{
- printNumber(n, 10);
-}
-
-void HardwareSerial::print(long n, int base)
-{
- if (base == 0)
- print((char) n);
- else if (base == 10)
- print(n);
- else
- printNumber(n, base);
-}
-
-void HardwareSerial::println(void)
-{
- print('\r');
- print('\n');
-}
-
-void HardwareSerial::println(char c)
-{
- print(c);
- println();
-}
-
-void HardwareSerial::println(const char c[])
-{
- print(c);
- println();
-}
-
-void HardwareSerial::println(uint8_t b)
-{
- print(b);
- println();
-}
-
-void HardwareSerial::println(int n)
-{
- print(n);
- println();
-}
-
-void HardwareSerial::println(unsigned int n)
-{
- print(n);
- println();
-}
-
-void HardwareSerial::println(long n)
-{
- print(n);
- println();
-}
-
-void HardwareSerial::println(unsigned long n)
-{
- print(n);
- println();
-}
-
-void HardwareSerial::println(long n, int base)
-{
- print(n, base);
- println();
-}
-
-// Private Methods /////////////////////////////////////////////////////////////
-
-void HardwareSerial::printNumber(unsigned long n, uint8_t base)
-{
- printIntegerInBase(n, base);
+void HardwareSerial::write(uint8_t b) {
+ serialWrite(b);
}
// Preinstantiate Objects //////////////////////////////////////////////////////
-HardwareSerial Serial = HardwareSerial(0);
-//HardwareSerial Serial1 = HardwareSerial(1);
+HardwareSerial Serial = HardwareSerial();
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h
index 5de9a1f..f2c6ce8 100755
--- a/cores/arduino/HardwareSerial.h
+++ b/cores/arduino/HardwareSerial.h
@@ -22,44 +22,20 @@
#include <inttypes.h>
-#define DEC 10
-#define HEX 16
-#define OCT 8
-#define BIN 2
-#define BYTE 0
+#include "Print.h"
-class HardwareSerial
+class HardwareSerial : public Print
{
- private:
- //uint8_t _uart;
- void printNumber(unsigned long, uint8_t);
public:
- HardwareSerial(uint8_t);
+ HardwareSerial();
void begin(long);
uint8_t available(void);
int read(void);
void flush(void);
- void print(char);
- void print(const char[]);
- void print(uint8_t);
- void print(int);
- void print(unsigned int);
- void print(long);
- void print(unsigned long);
- void print(long, int);
- void println(void);
- void println(char);
- void println(const char[]);
- void println(uint8_t);
- void println(int);
- void println(unsigned int);
- void println(long);
- void println(unsigned long);
- void println(long, int);
+ void write(uint8_t);
};
extern HardwareSerial Serial;
-//extern HardwareSerial Serial1;
#endif
diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c
index 38992ee..21ebe62 100755
--- a/cores/arduino/WInterrupts.c
+++ b/cores/arduino/WInterrupts.c
@@ -26,7 +26,6 @@
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
-#include <avr/signal.h>
#include <avr/pgmspace.h>
#include <stdio.h>
diff --git a/cores/arduino/WProgram.h b/cores/arduino/WProgram.h
index 1fba738..5f78de2 100755
--- a/cores/arduino/WProgram.h
+++ b/cores/arduino/WProgram.h
@@ -3,7 +3,6 @@
#include <math.h>
#include <avr/interrupt.h>
-#include <avr/signal.h>
#include "wiring.h"
diff --git a/cores/arduino/wiring_private.h b/cores/arduino/wiring_private.h
index affccd8..b30c1f0 100755
--- a/cores/arduino/wiring_private.h
+++ b/cores/arduino/wiring_private.h
@@ -27,7 +27,6 @@
#include <avr/io.h>
#include <avr/interrupt.h>
-#include <avr/signal.h>
#include <avr/delay.h>
#include <stdio.h>
#include <stdarg.h>
diff --git a/cores/arduino/wiring_serial.c b/cores/arduino/wiring_serial.c
index 9392a09..4cac891 100755
--- a/cores/arduino/wiring_serial.c
+++ b/cores/arduino/wiring_serial.c
@@ -126,87 +126,4 @@ SIGNAL(SIG_UART_RECV)
rx_buffer[rx_buffer_head] = c;
rx_buffer_head = i;
}
-}
-
-void printMode(int mode)
-{
- // do nothing, we only support serial printing, not lcd.
-}
-
-void printByte(unsigned char c)
-{
- serialWrite(c);
-}
-
-void printNewline()
-{
- printByte('\n');
-}
-
-void printString(const char *s)
-{
- while (*s)
- printByte(*s++);
-}
-
-void printIntegerInBase(unsigned long n, unsigned long base)
-{
- unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
- unsigned long i = 0;
-
- if (n == 0) {
- printByte('0');
- return;
- }
-
- while (n > 0) {
- buf[i++] = n % base;
- n /= base;
- }
-
- for (; i > 0; i--)
- printByte(buf[i - 1] < 10 ?
- '0' + buf[i - 1] :
- 'A' + buf[i - 1] - 10);
-}
-
-void printInteger(long n)
-{
- if (n < 0) {
- printByte('-');
- n = -n;
- }
-
- printIntegerInBase(n, 10);
-}
-
-void printHex(unsigned long n)
-{
- printIntegerInBase(n, 16);
-}
-
-void printOctal(unsigned long n)
-{
- printIntegerInBase(n, 8);
-}
-
-void printBinary(unsigned long n)
-{
- printIntegerInBase(n, 2);
-}
-
-/* Including print() adds approximately 1500 bytes to the binary size,
- * so we replace it with the smaller and less-confusing printString(),
- * printInteger(), etc.
-void print(const char *format, ...)
-{
- char buf[256];
- va_list ap;
-
- va_start(ap, format);
- vsnprintf(buf, 256, format, ap);
- va_end(ap);
-
- printString(buf);
-}
-*/
+} \ No newline at end of file