summaryrefslogtreecommitdiff
path: root/libraries/usart.h
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2020-10-25 12:49:35 +0100
committerxengineering <mail2xengineering@protonmail.com>2020-10-25 12:49:35 +0100
commit9435a85605d7efc75642491c85b0942bd558fcec (patch)
tree56e0c8f5530cac4e5e09aa174edaa170a0120726 /libraries/usart.h
parentdb0a19edd8c4cd62c6784d8bb1d91c61a6447a2a (diff)
downloadstm32f103c8-examples-9435a85605d7efc75642491c85b0942bd558fcec.tar
stm32f103c8-examples-9435a85605d7efc75642491c85b0942bd558fcec.tar.zst
stm32f103c8-examples-9435a85605d7efc75642491c85b0942bd558fcec.zip
Add usart_irq Code
Diffstat (limited to 'libraries/usart.h')
-rw-r--r--libraries/usart.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/libraries/usart.h b/libraries/usart.h
new file mode 100644
index 0000000..cac971b
--- /dev/null
+++ b/libraries/usart.h
@@ -0,0 +1,47 @@
+
+
+#ifndef USART_H
+#define USART_H
+
+
+#include <string.h>
+
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/gpio.h>
+#include <libopencm3/stm32/usart.h>
+#include <libopencm3/cm3/nvic.h>
+
+#include "fifo.h"
+
+#define USART_BUFFER_SIZE 30
+
+
+typedef struct USART{
+
+ FIFO rx_fifo;
+ FIFO tx_fifo;
+
+} USART;
+
+
+// init functions
+
+void usart_init(USART *usart);
+void usart_deinit(USART *usart);
+
+
+// write functions
+
+uint16_t usart_write_bytes(USART *usart, uint8_t *data_source, uint16_t data_length);
+uint16_t usart_write(USART *usart, char *str);
+//uint16_t usart_writeln(USART *usart, char *str);
+
+
+// read functions
+
+uint16_t usart_read_bytes(USART *usart, uint8_t *data_sink, uint16_t data_length);
+//uint16_t usart_read(USART *usart, char *data_sink, uint16_t data_length);
+//uint16_t usart_readln(USART *usart, char *data_sink);
+
+
+#endif /* USART_H */