diff options
Diffstat (limited to 'projects/cli-test/mgmt-cli.c')
-rw-r--r-- | projects/cli-test/mgmt-cli.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/projects/cli-test/mgmt-cli.c b/projects/cli-test/mgmt-cli.c index eacb944..d7f7383 100644 --- a/projects/cli-test/mgmt-cli.c +++ b/projects/cli-test/mgmt-cli.c @@ -58,8 +58,8 @@ #endif typedef struct { - int ridx; - volatile int widx; + unsigned ridx; + unsigned widx; mgmt_cli_dma_state_t rx_state; uint8_t buf[CLI_UART_RECVBUF_SIZE]; } ringbuf_t; @@ -97,19 +97,20 @@ static uint8_t uart_rx; */ void HAL_UART1_RxCpltCallback(UART_HandleTypeDef *huart) { + huart = huart; + ringbuf_write_char(&uart_ringbuf, uart_rx); } static void uart_cli_print(struct cli_def *cli __attribute__ ((unused)), const char *buf) { - char crlf[] = "\r\n"; - uart_send_string2(STM_UART_MGMT, buf); - uart_send_string2(STM_UART_MGMT, crlf); + uart_send_string(buf); + uart_send_string("\r\n"); } static ssize_t uart_cli_read(struct cli_def *cli __attribute__ ((unused)), void *buf, size_t count) { - for (int i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) { while (ringbuf_read_char(&uart_ringbuf, (uint8_t *)(buf + i)) == 0) { } } @@ -118,7 +119,7 @@ static ssize_t uart_cli_read(struct cli_def *cli __attribute__ ((unused)), void static ssize_t uart_cli_write(struct cli_def *cli __attribute__ ((unused)), const void *buf, size_t count) { - uart_send_bytes(STM_UART_MGMT, (uint8_t *) buf, count); + uart_send_bytes((uint8_t *) buf, count); return (ssize_t)count; } |