aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/comm
diff options
context:
space:
mode:
Diffstat (limited to 'wirish/comm')
-rw-r--r--wirish/comm/HardwareSerial.cpp30
-rw-r--r--wirish/comm/HardwareSerial.h4
2 files changed, 23 insertions, 11 deletions
diff --git a/wirish/comm/HardwareSerial.cpp b/wirish/comm/HardwareSerial.cpp
index 5ec9451..fba68fd 100644
--- a/wirish/comm/HardwareSerial.cpp
+++ b/wirish/comm/HardwareSerial.cpp
@@ -67,17 +67,9 @@ HardwareSerial::HardwareSerial(usart_dev *usart_device,
this->rx_pin = rx_pin;
}
-uint8 HardwareSerial::read(void) {
- return usart_getc(usart_device);
-}
-
-uint32 HardwareSerial::available(void) {
- return usart_data_available(usart_device);
-}
-
-void HardwareSerial::write(unsigned char ch) {
- usart_putc(usart_device, ch);
-}
+/*
+ * Set up/tear down
+ */
void HardwareSerial::begin(uint32 baud) {
ASSERT(baud <= usart_device->max_baud);
@@ -106,6 +98,22 @@ void HardwareSerial::end(void) {
usart_disable(usart_device);
}
+/*
+ * I/O
+ */
+
+uint8 HardwareSerial::read(void) {
+ return usart_getc(usart_device);
+}
+
+uint32 HardwareSerial::available(void) {
+ return usart_data_available(usart_device);
+}
+
+void HardwareSerial::write(unsigned char ch) {
+ usart_putc(usart_device, ch);
+}
+
void HardwareSerial::flush(void) {
usart_reset_rx(usart_device);
}
diff --git a/wirish/comm/HardwareSerial.h b/wirish/comm/HardwareSerial.h
index 49d535d..a347051 100644
--- a/wirish/comm/HardwareSerial.h
+++ b/wirish/comm/HardwareSerial.h
@@ -56,8 +56,12 @@ public:
uint8 tx_pin,
uint8 rx_pin,
uint32 clock_speed);
+
+ /* Set up/tear down */
void begin(uint32 baud);
void end(void);
+
+ /* I/O */
uint32 available(void);
uint8 read(void);
void flush(void);