diff options
Diffstat (limited to 'wirish/comm')
-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; |