aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-08-16 04:12:47 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-08-16 06:13:48 -0400
commit171eebc4fb5ded65637d056c24efe1bcd382a589 (patch)
treef15ca164ed201aea0ce88366a5a2cf8356b4e388 /wirish
parenta432c87cdcf3ccd7238e042da0be6a2e9cde0f0d (diff)
downloadlibrambutan-171eebc4fb5ded65637d056c24efe1bcd382a589.tar.gz
librambutan-171eebc4fb5ded65637d056c24efe1bcd382a589.zip
HardwareSerial: trivial code reordering
Diffstat (limited to 'wirish')
-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);