aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-05 20:28:32 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-06-05 20:28:32 +0200
commit97a104555de59091124a854cad3a5a4ff6bd285b (patch)
treef3f0bcb9cdcaa908bc3384da1759bef6998acf40 /src/common
parentff3d9f84a14ca5c2d4c44bf946b0f0def8abe6b6 (diff)
downloadglutte-o-matic-97a104555de59091124a854cad3a5a4ff6bd285b.tar.gz
glutte-o-matic-97a104555de59091124a854cad3a5a4ff6bd285b.tar.bz2
glutte-o-matic-97a104555de59091124a854cad3a5a4ff6bd285b.zip
Fix USART concurrency, create common usart object
Diffstat (limited to 'src/common')
-rw-r--r--src/common/includes/GPIO/usart.h10
-rw-r--r--src/common/sourcelist.txt1
-rw-r--r--src/common/src/GPIO/usart.c5
3 files changed, 14 insertions, 2 deletions
diff --git a/src/common/includes/GPIO/usart.h b/src/common/includes/GPIO/usart.h
index 21936d7..0ad1034 100644
--- a/src/common/includes/GPIO/usart.h
+++ b/src/common/includes/GPIO/usart.h
@@ -31,6 +31,14 @@
#ifndef __USART_H_
#define __USART_H_
+#ifdef STM32F4XX
+# include <stm32f4xx_usart.h>
+#else
+# define USART_TypeDef int
+# define USART2 ((USART_TypeDef*)2)
+# define USART3 ((USART_TypeDef*)3)
+#endif
+
#define MAX_NMEA_SENTENCE_LEN 256
// Initialise USART2 for PC debugging
@@ -48,7 +56,7 @@ void usart_debug(const char *format, ...);
// Send a string to the PC
void usart_debug_puts(const char* str);
-void usart_debug_puts_no_header(const char* str);
+void usart_debug_puts_header(const char* hdr, const char* str);
// Get a MAX_NMEA_SENTENCE_LEN sized NMEA sentence
// Return 1 on success
diff --git a/src/common/sourcelist.txt b/src/common/sourcelist.txt
new file mode 100644
index 0000000..a8602d6
--- /dev/null
+++ b/src/common/sourcelist.txt
@@ -0,0 +1 @@
+src/GPIO/usart.c
diff --git a/src/common/src/GPIO/usart.c b/src/common/src/GPIO/usart.c
index cf7e517..b96fa27 100644
--- a/src/common/src/GPIO/usart.c
+++ b/src/common/src/GPIO/usart.c
@@ -104,9 +104,12 @@ void usart_debug_puts(const char* str) {
xTaskResumeAll();
}
-void usart_debug_puts_no_header(const char* str) {
+void usart_debug_puts_header(const char* hdr, const char* str) {
vTaskSuspendAll();
+ usart_debug_timestamp();
+ usart_puts(USART2, hdr);
usart_puts(USART2, str);
+ usart_puts(USART2, "\r\n");
xTaskResumeAll();
}