aboutsummaryrefslogtreecommitdiff
path: root/stm-uart.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2016-03-16 10:18:50 -0400
committerPaul Selkirk <paul@psgd.org>2016-03-16 10:18:50 -0400
commit533898d765397abb07be72d7c394a8908157ad8c (patch)
treef5e88b52f52f0f1896c887c4445e152767269aec /stm-uart.c
parentc77986dcefbf2123caea6c2fb0573eb81226348c (diff)
Added uart_recv_char() to support RPC.
Moved hal_io_fmc.c to libhal repo.
Diffstat (limited to 'stm-uart.c')
-rw-r--r--stm-uart.c18
1 files changed, 12 insertions, 6 deletions
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);
}