diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-04-11 15:52:48 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-04-11 15:56:38 -0400 |
commit | 9ef9a63da80d79352d1029397865893a78e918fb (patch) | |
tree | 448355c7aa203373e9d93226285943c139c3eb25 /wirish | |
parent | 33f8df7aabe627f0343c5aa30c0147a8b567652c (diff) | |
download | librambutan-9ef9a63da80d79352d1029397865893a78e918fb.tar.gz librambutan-9ef9a63da80d79352d1029397865893a78e918fb.zip |
USART bugfix.
USART refactor commit f6f9a1122706ed336c52c984d76219dee0594487 only
worked for USART1.
Diffstat (limited to 'wirish')
-rw-r--r-- | wirish/comm/HardwareSerial.cpp | 19 | ||||
-rw-r--r-- | wirish/comm/HardwareSerial.h | 4 |
2 files changed, 13 insertions, 10 deletions
diff --git a/wirish/comm/HardwareSerial.cpp b/wirish/comm/HardwareSerial.cpp index aa8855b..5c9bff6 100644 --- a/wirish/comm/HardwareSerial.cpp +++ b/wirish/comm/HardwareSerial.cpp @@ -46,18 +46,21 @@ #define RX5 BOARD_UART5_RX_PIN #endif -HardwareSerial Serial1(USART1, TX1, RX1); -HardwareSerial Serial2(USART2, TX2, RX2); -HardwareSerial Serial3(USART3, TX3, RX3); +// TODO Put these magic numbers into boards.h #defines +HardwareSerial Serial1(USART1, TX1, RX1, 72000000UL); +HardwareSerial Serial2(USART2, TX2, RX2, 36000000UL); +HardwareSerial Serial3(USART3, TX3, RX3, 36000000UL); #if defined(STM32_HIGH_DENSITY) && !defined(BOARD_maple_RET6) -HardwareSerial Serial4(UART4, TX4, RX4); -HardwareSerial Serial5(UART5, TX5, RX5); +HardwareSerial Serial4(UART4, TX4, RX4, 36000000UL); +HardwareSerial Serial5(UART5, TX5, RX5, 36000000UL); #endif HardwareSerial::HardwareSerial(usart_dev *usart_device, uint8 tx_pin, - uint8 rx_pin) { + uint8 rx_pin, + uint32 clock_speed) { this->usart_device = usart_device; + this->clock_speed = clock_speed; this->tx_pin = tx_pin; this->rx_pin = rx_pin; } @@ -93,9 +96,7 @@ void HardwareSerial::begin(uint32 baud) { } usart_init(usart_device); - usart_set_baud_rate(usart_device, - CYCLES_PER_MICROSECOND * 1000000UL, - baud); + usart_set_baud_rate(usart_device, clock_speed, baud); usart_enable(usart_device); } diff --git a/wirish/comm/HardwareSerial.h b/wirish/comm/HardwareSerial.h index 5e86f79..934db23 100644 --- a/wirish/comm/HardwareSerial.h +++ b/wirish/comm/HardwareSerial.h @@ -50,7 +50,8 @@ class HardwareSerial : public Print { public: HardwareSerial(usart_dev *usart_device, uint8 tx_pin, - uint8 rx_pin); + uint8 rx_pin, + uint32 clock_speed); void begin(uint32 baud); void end(void); uint32 available(void); @@ -62,6 +63,7 @@ private: usart_dev *usart_device; uint8 tx_pin; uint8 rx_pin; + uint32 clock_speed; }; extern HardwareSerial Serial1; |