From 0c78fdf5350b3e3d6e8335fc83fb942763c447ad Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Wed, 26 Jan 2022 19:31:49 -0500 Subject: watch library: implement UART --- watch-library/simulator/watch/watch_uart.c | 49 +++++++++++++----------------- 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'watch-library/simulator') diff --git a/watch-library/simulator/watch/watch_uart.c b/watch-library/simulator/watch/watch_uart.c index e37fabff..7043383c 100644 --- a/watch-library/simulator/watch/watch_uart.c +++ b/watch-library/simulator/watch/watch_uart.c @@ -22,37 +22,30 @@ * SOFTWARE. */ - /* - * UART methods are Copyright (c) 2014-2017, Alex Taradov - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - #include "watch_uart.h" #include "peripheral_clk_config.h" +static bool tx_enable = false; +static bool rx_enable = false; + +void watch_enable_uart(const uint8_t tx_pin, const uint8_t rx_pin, uint32_t baud) { + tx_enable = !!tx_pin; + rx_enable = !!rx_pin; +} + +void watch_uart_puts(char *s) { + if (tx_enable) { + // TODO: hook up to UI + } +} + +char watch_uart_getc(void) { + if (rx_enable) { + // TODO: hook up to UI + } + return 0; +} + void watch_enable_debug_uart(uint32_t baud) {} void watch_debug_putc(char c) {} -- cgit v1.2.3