Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 96e85a1eb -> bbbdf2194
fix up native uart for new uart calls to get native compiling again. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/bbbdf219 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/bbbdf219 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/bbbdf219 Branch: refs/heads/develop Commit: bbbdf2194f0561129bc5c22edefb62cae3646a96 Parents: 96e85a1 Author: Sterling Hughes <sterl...@apache.org> Authored: Thu Sep 22 23:14:12 2016 -0700 Committer: Sterling Hughes <sterl...@apache.org> Committed: Thu Sep 22 23:14:12 2016 -0700 ---------------------------------------------------------------------- hw/bsp/native/include/bsp/bsp.h | 4 ++-- hw/bsp/native/src/os_bsp.c | 16 +++++++++++++++- hw/mcu/native/src/hal_uart.c | 33 +++++++++++++++++++++++++++++++++ libs/os/include/os/os.h | 1 + 4 files changed, 51 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bbbdf219/hw/bsp/native/include/bsp/bsp.h ---------------------------------------------------------------------- diff --git a/hw/bsp/native/include/bsp/bsp.h b/hw/bsp/native/include/bsp/bsp.h index d4cedc3..e8f2b42 100644 --- a/hw/bsp/native/include/bsp/bsp.h +++ b/hw/bsp/native/include/bsp/bsp.h @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -35,7 +35,7 @@ extern "C" { #define LED_BLINK_PIN (0x1) /* UART info */ -#define CONSOLE_UART "uart1" +#define CONSOLE_UART "uart0" #define CONSOLE_UART_SPEED 9600 #define NFFS_AREA_MAX (8) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bbbdf219/hw/bsp/native/src/os_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/native/src/os_bsp.c b/hw/bsp/native/src/os_bsp.c index a04c48f..7f312d6 100644 --- a/hw/bsp/native/src/os_bsp.c +++ b/hw/bsp/native/src/os_bsp.c @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -16,7 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +#include <assert.h> + +#include <os/os.h> #include <hal/flash_map.h> +#include <uart/uart.h> +#include <uart_hal/uart_hal.h> #include <mcu/native_bsp.h> static struct flash_area bsp_flash_areas[] = { @@ -53,6 +58,8 @@ static struct flash_area bsp_flash_areas[] = { }, }; +static struct uart_dev os_bsp_uart0; + /* * Returns the flash map slot where the currently active image is located. * If executing from internal flash from fixed location, that slot would @@ -67,9 +74,16 @@ bsp_imgr_current_slot(void) return FLASH_AREA_IMAGE_0; } + void bsp_init(void) { + int rc; + flash_area_init(bsp_flash_areas, sizeof(bsp_flash_areas) / sizeof(bsp_flash_areas[0])); + + rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0", + OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *) NULL); + assert(rc == 0); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bbbdf219/hw/mcu/native/src/hal_uart.c ---------------------------------------------------------------------- diff --git a/hw/mcu/native/src/hal_uart.c b/hw/mcu/native/src/hal_uart.c index 0db339f..dbaaec6 100644 --- a/hw/mcu/native/src/hal_uart.c +++ b/hw/mcu/native/src/hal_uart.c @@ -373,3 +373,36 @@ hal_uart_config(int port, int32_t baudrate, uint8_t databits, uint8_t stopbits, uart->u_open = 1; return 0; } + +int +hal_uart_close(int port) +{ + struct uart *uart; + int rc; + + if (port >= UART_CNT) { + rc = -1; + goto err; + } + + uart = &uarts[port]; + if (!uart->u_open) { + rc = -1; + goto err; + } + + close(uart->u_fd); + + uart->u_open = 0; + return (0); +err: + return (rc); +} + +int +hal_uart_init(int port, void *arg) +{ + return (0); +} + + http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bbbdf219/libs/os/include/os/os.h ---------------------------------------------------------------------- diff --git a/libs/os/include/os/os.h b/libs/os/include/os/os.h index 19d85b4..0f1879c 100644 --- a/libs/os/include/os/os.h +++ b/libs/os/include/os/os.h @@ -96,5 +96,6 @@ void os_init_idle_task(void); #include "os/os_sem.h" #include "os/os_mempool.h" #include "os/os_mbuf.h" +#include "os/os_dev.h" #endif /* _OS_H */