Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/libopencm3_cpp_extensions.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Larionov <paxa.larionov@gmail.com>2017-09-06 20:16:39 +0300
committerPavel Larionov <paxa.larionov@gmail.com>2017-09-06 20:16:39 +0300
commit8d0a56d28c77a1bbc6319de2ee1fab60383a9bf7 (patch)
tree05d80d2255944833e9c565e42eea1a8ca7b486eb
parent305330f8300bc137e29fcdef58258cb8e37be8af (diff)
add func set_settings to usart
-rw-r--r--cm3cpp_usart.cpp13
-rw-r--r--cm3cpp_usart.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/cm3cpp_usart.cpp b/cm3cpp_usart.cpp
index 69ea594..16ded74 100644
--- a/cm3cpp_usart.cpp
+++ b/cm3cpp_usart.cpp
@@ -83,16 +83,21 @@ Usart::Usart(LowLevelConfig config, Settings settings)
break;
}
+ set_settings(settings);
+ usart_enable(_usart);
+
+ nvic_set_priority(_usart_nvic, config.nvic_priority);
+ nvic_enable_irq(_usart_nvic);
+}
+
+void Usart::set_settings(Settings settings)
+{
usart_set_baudrate(_usart, settings.baud_rate);
usart_set_databits(_usart, settings.word_length);
usart_set_stopbits(_usart, settings.stop_bits);
usart_set_mode(_usart, settings.mode);
usart_set_parity(_usart, settings.parity);
usart_set_flow_control(_usart, settings.flow_control);
- usart_enable(_usart);
-
- nvic_set_priority(_usart_nvic, config.nvic_priority);
- nvic_enable_irq(_usart_nvic);
}
} // namespace usart
diff --git a/cm3cpp_usart.h b/cm3cpp_usart.h
index 0385afb..3cc27c4 100644
--- a/cm3cpp_usart.h
+++ b/cm3cpp_usart.h
@@ -112,6 +112,8 @@ public:
Usart(LowLevelConfig config, Settings settings);
+ void set_settings(Settings settings);
+
bool interrupt_source_rx() {
return (((USART_CR1(_usart) & USART_CR1_RXNEIE) != 0) &&
usart_get_flag(_usart, USART_SR_RXNE));