From db5b2075d6cf51a819c669ca48dc24cd578a625f Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Fri, 13 May 2016 12:51:31 +0200 Subject: Implement support for the two UARTs on the alpha board. --- projects/board-test/uart-test.c | 48 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 25 deletions(-) (limited to 'projects') diff --git a/projects/board-test/uart-test.c b/projects/board-test/uart-test.c index 6f022f4..eb6108a 100644 --- a/projects/board-test/uart-test.c +++ b/projects/board-test/uart-test.c @@ -16,36 +16,34 @@ int main() { - uint8_t tx = 'A'; - uint8_t rx = 0; - uint8_t upper = 0; + uint8_t crlf[] = "\r\n"; + uint8_t tx = 'A'; + uint8_t rx = 0; + uint8_t upper = 0; - stm_init(); + stm_init(); - while (1) - { - led_toggle(LED_GREEN); + while (1) { + led_toggle(LED_GREEN); - uart_send_char2(STM_UART_USER, tx + upper); - uart_send_char2(STM_UART_MGMT, tx + upper); - DELAY(); + uart_send_char2(STM_UART_USER, tx + upper); + uart_send_char2(STM_UART_MGMT, tx + upper); + DELAY(); - if (uart_recv_char2(STM_UART_USER, &rx, 0) == HAL_OK || - uart_recv_char2(STM_UART_MGMT, &rx, 0) == HAL_OK) { - led_toggle(LED_YELLOW); - if (rx == '\r') { - upper = upper == 0 ? ('a' - 'A'):0; + if (uart_recv_char2(STM_UART_USER, &rx, 0) == HAL_OK || + uart_recv_char2(STM_UART_MGMT, &rx, 0) == HAL_OK) { + led_toggle(LED_YELLOW); + if (rx == '\r') { + upper = upper == 0 ? ('a' - 'A'):0; + } } - } - if (tx++ == 'Z') { - /* linefeed after each alphabet */ - uart_send_char2(STM_UART_USER, '\r'); - uart_send_char2(STM_UART_USER, '\n'); - uart_send_char2(STM_UART_MGMT, '\r'); - uart_send_char2(STM_UART_MGMT, '\n'); - tx = 'A'; - led_toggle(LED_BLUE); + if (tx++ == 'Z') { + /* linefeed after each alphabet */ + uart_send_string2(STM_UART_USER, crlf); + uart_send_string2(STM_UART_MGMT, crlf); + tx = 'A'; + led_toggle(LED_BLUE); + } } - } } -- cgit v1.2.3