aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm/hsm.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-12-19 15:33:52 -0500
committerRob Austein <sra@hactrn.net>2016-12-19 15:33:52 -0500
commiteb8c7d7cd26608a0f2825b89a1eca5008d7e3f66 (patch)
tree62706c821f0329e908330f54b4cb637299ef5d46 /projects/hsm/hsm.c
parentc28f77d75105a31555c0eb45f45c76675248032f (diff)
parentd172acba926b72c57c47697bd640c51c0fcb038d (diff)
Merge branch 'master' into ksng.
Drag in UART-related changes from master.
Diffstat (limited to 'projects/hsm/hsm.c')
-rw-r--r--projects/hsm/hsm.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/projects/hsm/hsm.c b/projects/hsm/hsm.c
index ac0f23a..971d460 100644
--- a/projects/hsm/hsm.c
+++ b/projects/hsm/hsm.c
@@ -103,7 +103,7 @@ osMutexId uart_mutex;
osMutexDef(uart_mutex);
#endif
-static volatile uint8_t uart_rx; /* current character received from UART */
+static uint8_t uart_rx[2]; /* current character received from UART */
/* Callback for HAL_UART_Receive_DMA().
* With multiple worker threads, we can't do a blocking receive, because
@@ -113,7 +113,7 @@ static volatile uint8_t uart_rx; /* current character received from UART */
* Even with only one worker thread, context-switching to the CLI thread
* causes HAL_UART_Receive to miss input.
*/
-void HAL_UART2_RxCpltCallback(UART_HandleTypeDef *huart)
+static void RxCallback(uint8_t c)
{
/* current RPC input buffer */
static rpc_buffer_t *ibuf = NULL;
@@ -125,7 +125,7 @@ void HAL_UART2_RxCpltCallback(UART_HandleTypeDef *huart)
ibuf->len = 0;
}
- if (hal_slip_recv_char(ibuf->buf, &ibuf->len, sizeof(ibuf->buf), &complete) != LIBHAL_OK)
+ if (hal_slip_process_char(c, ibuf->buf, &ibuf->len, sizeof(ibuf->buf), &complete) != LIBHAL_OK)
Error_Handler();
if (complete) {
@@ -135,17 +135,20 @@ void HAL_UART2_RxCpltCallback(UART_HandleTypeDef *huart)
}
}
-void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
+void HAL_UART2_RxHalfCpltCallback(UART_HandleTypeDef *huart)
{
- /* I dunno, just trap it for now */
- Error_Handler();
+ RxCallback(uart_rx[0]);
}
-hal_error_t hal_serial_recv_char(uint8_t *cp)
+void HAL_UART2_RxCpltCallback(UART_HandleTypeDef *huart)
{
- /* return the character from HAL_UART_Receive_DMA */
- *cp = uart_rx;
- return LIBHAL_OK;
+ RxCallback(uart_rx[1]);
+}
+
+void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
+{
+ /* I dunno, just trap it for now */
+ Error_Handler();
}
hal_error_t hal_serial_send_char(uint8_t c)
@@ -277,7 +280,7 @@ int main()
}
/* Start the UART receiver. */
- if (HAL_UART_Receive_DMA(&huart_user, (uint8_t *)&uart_rx, 1) != CMSIS_HAL_OK)
+ if (HAL_UART_Receive_DMA(&huart_user, uart_rx, 2) != CMSIS_HAL_OK)
Error_Handler();
/* Launch other threads (csprng warm-up thread?)