aboutsummaryrefslogtreecommitdiff
path: root/projects/ekermit-test
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2016-06-21 16:05:48 -0400
committerPaul Selkirk <paul@psgd.org>2016-06-21 16:05:48 -0400
commit035ad220df784f71e2424c86d5ffe015c764ae69 (patch)
tree1574537db3463686bd74dfca7c848bf5c9c95b5a /projects/ekermit-test
parent5a0fb1ce24abe38ada705327868a5601b59e8ec4 (diff)
Sudden realization that initializing the uart from the ekermit library is Just Wrong.
Diffstat (limited to 'projects/ekermit-test')
-rw-r--r--projects/ekermit-test/ekermit-test.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/projects/ekermit-test/ekermit-test.c b/projects/ekermit-test/ekermit-test.c
index 3b71a69..ba9a2f8 100644
--- a/projects/ekermit-test/ekermit-test.c
+++ b/projects/ekermit-test/ekermit-test.c
@@ -44,6 +44,8 @@
#include "stm-sdram.h"
#include "sdram-malloc.h"
#include "stm-kermit.h"
+#include "stm-uart.h"
+#include "ringbuf.h"
/* alignment for file allocations */
#define ALIGN 16
@@ -62,6 +64,29 @@ typedef struct {
filetab_t filetab[NFILE], *curfile;
int nfile;
+static ringbuf_t uart_ringbuf;
+
+/* current character received from UART */
+static uint8_t uart_rx;
+
+/* Callback for HAL_UART_Receive_IT(). Must be public. */
+void HAL_UART1_RxCpltCallback(UART_HandleTypeDef *huart)
+{
+ ringbuf_write_char(&uart_ringbuf, uart_rx);
+ HAL_UART_Receive_IT(huart, &uart_rx, 1);
+}
+
+void uart1_init(void)
+{
+ ringbuf_init(&uart_ringbuf);
+ HAL_UART_Receive_IT(&huart_mgmt, &uart_rx, 1);
+}
+
+int uart1_read_char(uint8_t *c)
+{
+ return ringbuf_read_char(&uart_ringbuf, c);
+}
+
#ifdef DUMP
static void hexdump(uint8_t *buf, int len)
{
@@ -149,6 +174,7 @@ int main(void)
{
stm_init();
sdram_init();
+ uart1_init();
while (1) {
memset((void *)filetab, 0, sizeof(filetab));