From 533898d765397abb07be72d7c394a8908157ad8c Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Wed, 16 Mar 2016 10:18:50 -0400 Subject: Added uart_recv_char() to support RPC. Moved hal_io_fmc.c to libhal repo. --- stm-uart.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'stm-uart.c') diff --git a/stm-uart.c b/stm-uart.c index 602a59c..9934870 100644 --- a/stm-uart.c +++ b/stm-uart.c @@ -41,21 +41,27 @@ UART_HandleTypeDef huart2; /* send a single character */ -void uart_send_char(uint8_t ch) +HAL_StatusTypeDef uart_send_char(uint8_t ch) { - HAL_UART_Transmit(&huart2, &ch, 1, 0x1); + return HAL_UART_Transmit(&huart2, &ch, 1, 0x1); +} + +/* receive a single character */ +HAL_StatusTypeDef uart_recv_char(uint8_t *cp) +{ + return HAL_UART_Receive(&huart2, cp, 1, 0x0); } /* send a string */ -void uart_send_string(char *s) +HAL_StatusTypeDef uart_send_string(char *s) { - HAL_UART_Transmit(&huart2, (uint8_t *) s, strlen(s), 0x1); + return HAL_UART_Transmit(&huart2, (uint8_t *) s, strlen(s), 0x1); } /* Generalized routine to send binary, decimal, and hex integers. * This code is adapted from Chris Giese's printf.c */ -void uart_send_number(uint32_t num, uint8_t digits, uint8_t radix) +HAL_StatusTypeDef uart_send_number(uint32_t num, uint8_t digits, uint8_t radix) { #define BUFSIZE 32 char buf[BUFSIZE]; @@ -83,5 +89,5 @@ void uart_send_number(uint32_t num, uint8_t digits, uint8_t radix) /* number is larger than the specified number of digits */ digits = buf + BUFSIZE - where; - HAL_UART_Transmit(&huart2, (uint8_t *) where, digits, 0x1); + return HAL_UART_Transmit(&huart2, (uint8_t *) where, digits, 0x1); } -- cgit v1.2.3