Merged with develop, new directory structure
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/5b589e6c Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5b589e6c Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5b589e6c Branch: refs/heads/develop Commit: 5b589e6c9133a95fc822039afb092296209b86af Parents: 0ef64aa Author: julian <[email protected]> Authored: Thu Oct 20 16:43:58 2016 +0100 Committer: julian <[email protected]> Committed: Mon Nov 21 11:07:25 2016 +0000 ---------------------------------------------------------------------- hw/bsp/ci40/src/os_bsp.c | 24 ++-- hw/bsp/ci40/syscfg.yml | 14 ++ .../uart/uart_hal/src/uart_hal_BACKUP_19438.c | 143 ------------------- .../uart/uart_hal/src/uart_hal_BASE_19438.c | 143 ------------------- .../uart/uart_hal/src/uart_hal_LOCAL_19438.c | 143 ------------------- .../uart/uart_hal/src/uart_hal_REMOTE_19438.c | 143 ------------------- kernel/os/src/arch/mips/os_arch_mips.c | 8 +- 7 files changed, 32 insertions(+), 586 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b589e6c/hw/bsp/ci40/src/os_bsp.c ---------------------------------------------------------------------- diff --git a/hw/bsp/ci40/src/os_bsp.c b/hw/bsp/ci40/src/os_bsp.c index 35e4b5a..4736898 100644 --- a/hw/bsp/ci40/src/os_bsp.c +++ b/hw/bsp/ci40/src/os_bsp.c @@ -37,13 +37,19 @@ void _close(int fd); void bsp_init(void) { - #if MYNEWT_VAL(UART_0) - assert(os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0", - OS_DEV_INIT_PRIMARY, 0, uart_hal_init, 0) == 0); - #endif - - #if MYNEWT_VAL(UART_1) - assert(os_dev_create((struct os_dev *) &os_bsp_uart1, "uart1", - OS_DEV_INIT_PRIMARY, 0, uart_hal_init, 0) == 0); - #endif + int rc; + +#if MYNEWT_VAL(UART_0) + rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0", + OS_DEV_INIT_PRIMARY, 0, uart_hal_init, 0); + assert(rc == 0); +#endif + +#if MYNEWT_VAL(UART_1) + rc = os_dev_create((struct os_dev *) &os_bsp_uart1, "uart1", + OS_DEV_INIT_PRIMARY, 0, uart_hal_init, 0); + assert(rc == 0); +#endif + + (void)rc; } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b589e6c/hw/bsp/ci40/syscfg.yml ---------------------------------------------------------------------- diff --git a/hw/bsp/ci40/syscfg.yml b/hw/bsp/ci40/syscfg.yml new file mode 100644 index 0000000..d889f55 --- /dev/null +++ b/hw/bsp/ci40/syscfg.yml @@ -0,0 +1,14 @@ +# Package: hw/bsp/ci40 + +syscfg.defs: + CLOCK_FREQ: + description: 'TBD' + value: 546000000ul + + UART_0: + description: 'TBD' + value: 1 + + UART_1: + description: 'TBD' + value: 1 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b589e6c/hw/drivers/uart/uart_hal/src/uart_hal_BACKUP_19438.c ---------------------------------------------------------------------- diff --git a/hw/drivers/uart/uart_hal/src/uart_hal_BACKUP_19438.c b/hw/drivers/uart/uart_hal/src/uart_hal_BACKUP_19438.c deleted file mode 100644 index 940990a..0000000 --- a/hw/drivers/uart/uart_hal/src/uart_hal_BACKUP_19438.c +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include <ctype.h> -#include <assert.h> -#include <string.h> - -#include <os/os.h> -#include <os/os_dev.h> -#include <hal/hal_uart.h> - -#include <uart/uart.h> - -#include "uart_hal/uart_hal.h" - -struct uart_hal_priv { - int unit; -}; - -static void -uart_hal_start_tx(struct uart_dev *dev) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - assert(priv); - - hal_uart_start_tx(priv->unit); -} - -static void -uart_hal_start_rx(struct uart_dev *dev) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - - hal_uart_start_rx(priv->unit); -} - -static void -uart_hal_blocking_tx(struct uart_dev *dev, uint8_t byte) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - - hal_uart_blocking_tx(priv->unit, byte); -} - -static int -uart_hal_open(struct os_dev *odev, uint32_t wait, void *arg) -{ - struct uart_hal_priv *priv; - struct uart_conf *uc; - int rc; - - priv = ((struct uart_dev *)odev)->ud_priv; - - uc = (struct uart_conf *)arg; - if (!uc) { - return OS_EINVAL; - } - if (odev->od_flags & OS_DEV_F_STATUS_OPEN) { - return OS_EBUSY; - } - hal_uart_init_cbs(priv->unit, uc->uc_tx_char, uc->uc_tx_done, - uc->uc_rx_char, uc->uc_cb_arg); - - rc = hal_uart_config(priv->unit, uc->uc_speed, uc->uc_databits, - uc->uc_stopbits, uc->uc_parity, uc->uc_flow_ctl); - if (rc) { - return OS_EINVAL; - } - return OS_OK; -} - -static int -uart_hal_close(struct os_dev *odev) -{ - struct uart_hal_priv *priv; - int rc; - - priv = ((struct uart_dev *)odev)->ud_priv; - - rc = hal_uart_close(priv->unit); - if (rc) { - return OS_EINVAL; - } - return OS_OK; -} - -/* - * Arg points to BSP specific UART configuration. - */ -int -uart_hal_init(struct os_dev *odev, void *arg) -{ - struct uart_dev *dev; - struct uart_hal_priv *priv; - char ch; - - priv = os_malloc(sizeof(struct uart_hal_priv)); - if (!priv) { - return OS_ENOMEM; - } - priv->unit = -1; - - ch = odev->od_name[strlen(odev->od_name) - 1]; - if (!isdigit((int)ch)) { - return OS_EINVAL; - } - priv->unit = ch - '0'; - - dev = (struct uart_dev *)odev; - - OS_DEV_SETHANDLERS(odev, uart_hal_open, uart_hal_close); - - dev->ud_funcs.uf_start_tx = uart_hal_start_tx; - dev->ud_funcs.uf_start_rx = uart_hal_start_rx; - dev->ud_funcs.uf_blocking_tx = uart_hal_blocking_tx; - dev->ud_priv = priv; - - hal_uart_init(priv->unit, arg); - - return OS_OK; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b589e6c/hw/drivers/uart/uart_hal/src/uart_hal_BASE_19438.c ---------------------------------------------------------------------- diff --git a/hw/drivers/uart/uart_hal/src/uart_hal_BASE_19438.c b/hw/drivers/uart/uart_hal/src/uart_hal_BASE_19438.c deleted file mode 100644 index 5617f6b..0000000 --- a/hw/drivers/uart/uart_hal/src/uart_hal_BASE_19438.c +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include <ctype.h> -#include <assert.h> -#include <string.h> - -#include <os/os.h> -#include <os/os_dev.h> -#include <hal/hal_uart.h> - -#include <uart/uart.h> - -#include "uart_hal/uart_hal.h" - -struct uart_hal_priv { - int unit; -}; - -static void -uart_hal_start_tx(struct uart_dev *dev) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - assert(priv); - - hal_uart_start_tx(priv->unit); -} - -static void -uart_hal_start_rx(struct uart_dev *dev) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - - hal_uart_start_rx(priv->unit); -} - -static void -uart_hal_blocking_tx(struct uart_dev *dev, uint8_t byte) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - - hal_uart_blocking_tx(priv->unit, byte); -} - -static int -uart_hal_open(struct os_dev *odev, uint32_t wait, void *arg) -{ - struct uart_hal_priv *priv; - struct uart_conf *uc; - int rc; - - priv = ((struct uart_dev *)odev)->ud_priv; - - uc = (struct uart_conf *)arg; - if (!uc) { - return OS_EINVAL; - } - if (odev->od_flags & OS_DEV_F_STATUS_OPEN) { - return OS_EBUSY; - } - hal_uart_init_cbs(priv->unit, uc->uc_tx_char, uc->uc_tx_done, - uc->uc_rx_char, uc->uc_cb_arg); - - rc = hal_uart_config(priv->unit, uc->uc_speed, uc->uc_databits, - uc->uc_stopbits, uc->uc_parity, uc->uc_flow_ctl); - if (rc) { - return OS_EINVAL; - } - return OS_OK; -} - -static int -uart_hal_close(struct os_dev *odev) -{ - struct uart_hal_priv *priv; - int rc; - - priv = ((struct uart_dev *)odev)->ud_priv; - - rc = hal_uart_close(priv->unit); - if (rc) { - return OS_EINVAL; - } - return OS_OK; -} - -/* - * Arg points to BSP specific UART configuration. - */ -int -uart_hal_init(struct os_dev *odev, void *arg) -{ - struct uart_dev *dev; - struct uart_hal_priv *priv; - char ch; - - priv = os_malloc(sizeof(struct uart_hal_priv)); - if (!priv) { - return OS_ENOMEM; - } - priv->unit = -1; - - ch = odev->od_name[strlen(odev->od_name) - 1]; - if (!isdigit(ch)) { - return OS_EINVAL; - } - priv->unit = ch - '0'; - - dev = (struct uart_dev *)odev; - - OS_DEV_SETHANDLERS(odev, uart_hal_open, uart_hal_close); - - dev->ud_funcs.uf_start_tx = uart_hal_start_tx; - dev->ud_funcs.uf_start_rx = uart_hal_start_rx; - dev->ud_funcs.uf_blocking_tx = uart_hal_blocking_tx; - dev->ud_priv = priv; - - hal_uart_init(priv->unit, arg); - - return OS_OK; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b589e6c/hw/drivers/uart/uart_hal/src/uart_hal_LOCAL_19438.c ---------------------------------------------------------------------- diff --git a/hw/drivers/uart/uart_hal/src/uart_hal_LOCAL_19438.c b/hw/drivers/uart/uart_hal/src/uart_hal_LOCAL_19438.c deleted file mode 100644 index c99e613..0000000 --- a/hw/drivers/uart/uart_hal/src/uart_hal_LOCAL_19438.c +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include <ctype.h> -#include <assert.h> -#include <string.h> - -#include <os/os.h> -#include <os/os_dev.h> -#include <hal/hal_uart.h> - -#include <uart/uart.h> - -#include "uart_hal/uart_hal.h" - -struct uart_hal_priv { - int unit; -}; - -static void -uart_hal_start_tx(struct uart_dev *dev) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - assert(priv); - - hal_uart_start_tx(priv->unit); -} - -static void -uart_hal_start_rx(struct uart_dev *dev) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - - hal_uart_start_rx(priv->unit); -} - -static void -uart_hal_blocking_tx(struct uart_dev *dev, uint8_t byte) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - - hal_uart_blocking_tx(priv->unit, byte); -} - -static int -uart_hal_open(struct os_dev *odev, uint32_t wait, void *arg) -{ - struct uart_hal_priv *priv; - struct uart_conf *uc; - int rc; - - priv = ((struct uart_dev *)odev)->ud_priv; - - uc = (struct uart_conf *)arg; - if (!uc) { - return OS_EINVAL; - } - if (odev->od_flags & OS_DEV_F_STATUS_OPEN) { - return OS_EBUSY; - } - hal_uart_init_cbs(priv->unit, uc->uc_tx_char, uc->uc_tx_done, - uc->uc_rx_char, uc->uc_cb_arg); - - rc = hal_uart_config(priv->unit, uc->uc_speed, uc->uc_databits, - uc->uc_stopbits, uc->uc_parity, uc->uc_flow_ctl); - if (rc) { - return OS_EINVAL; - } - return OS_OK; -} - -static int -uart_hal_close(struct os_dev *odev) -{ - struct uart_hal_priv *priv; - int rc; - - priv = ((struct uart_dev *)odev)->ud_priv; - - rc = hal_uart_close(priv->unit); - if (rc) { - return OS_EINVAL; - } - return OS_OK; -} - -/* - * Arg points to BSP specific UART configuration. - */ -int -uart_hal_init(struct os_dev *odev, void *arg) -{ - struct uart_dev *dev; - struct uart_hal_priv *priv; - char ch; - - priv = os_malloc(sizeof(struct uart_hal_priv)); - if (!priv) { - return OS_ENOMEM; - } - priv->unit = -1; - - ch = odev->od_name[strlen(odev->od_name) - 1]; - if (!isdigit((int) ch)) { - return OS_EINVAL; - } - priv->unit = ch - '0'; - - dev = (struct uart_dev *)odev; - - OS_DEV_SETHANDLERS(odev, uart_hal_open, uart_hal_close); - - dev->ud_funcs.uf_start_tx = uart_hal_start_tx; - dev->ud_funcs.uf_start_rx = uart_hal_start_rx; - dev->ud_funcs.uf_blocking_tx = uart_hal_blocking_tx; - dev->ud_priv = priv; - - hal_uart_init(priv->unit, arg); - - return OS_OK; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b589e6c/hw/drivers/uart/uart_hal/src/uart_hal_REMOTE_19438.c ---------------------------------------------------------------------- diff --git a/hw/drivers/uart/uart_hal/src/uart_hal_REMOTE_19438.c b/hw/drivers/uart/uart_hal/src/uart_hal_REMOTE_19438.c deleted file mode 100644 index 940990a..0000000 --- a/hw/drivers/uart/uart_hal/src/uart_hal_REMOTE_19438.c +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * 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, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#include <ctype.h> -#include <assert.h> -#include <string.h> - -#include <os/os.h> -#include <os/os_dev.h> -#include <hal/hal_uart.h> - -#include <uart/uart.h> - -#include "uart_hal/uart_hal.h" - -struct uart_hal_priv { - int unit; -}; - -static void -uart_hal_start_tx(struct uart_dev *dev) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - assert(priv); - - hal_uart_start_tx(priv->unit); -} - -static void -uart_hal_start_rx(struct uart_dev *dev) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - - hal_uart_start_rx(priv->unit); -} - -static void -uart_hal_blocking_tx(struct uart_dev *dev, uint8_t byte) -{ - struct uart_hal_priv *priv; - - priv = dev->ud_priv; - - hal_uart_blocking_tx(priv->unit, byte); -} - -static int -uart_hal_open(struct os_dev *odev, uint32_t wait, void *arg) -{ - struct uart_hal_priv *priv; - struct uart_conf *uc; - int rc; - - priv = ((struct uart_dev *)odev)->ud_priv; - - uc = (struct uart_conf *)arg; - if (!uc) { - return OS_EINVAL; - } - if (odev->od_flags & OS_DEV_F_STATUS_OPEN) { - return OS_EBUSY; - } - hal_uart_init_cbs(priv->unit, uc->uc_tx_char, uc->uc_tx_done, - uc->uc_rx_char, uc->uc_cb_arg); - - rc = hal_uart_config(priv->unit, uc->uc_speed, uc->uc_databits, - uc->uc_stopbits, uc->uc_parity, uc->uc_flow_ctl); - if (rc) { - return OS_EINVAL; - } - return OS_OK; -} - -static int -uart_hal_close(struct os_dev *odev) -{ - struct uart_hal_priv *priv; - int rc; - - priv = ((struct uart_dev *)odev)->ud_priv; - - rc = hal_uart_close(priv->unit); - if (rc) { - return OS_EINVAL; - } - return OS_OK; -} - -/* - * Arg points to BSP specific UART configuration. - */ -int -uart_hal_init(struct os_dev *odev, void *arg) -{ - struct uart_dev *dev; - struct uart_hal_priv *priv; - char ch; - - priv = os_malloc(sizeof(struct uart_hal_priv)); - if (!priv) { - return OS_ENOMEM; - } - priv->unit = -1; - - ch = odev->od_name[strlen(odev->od_name) - 1]; - if (!isdigit((int)ch)) { - return OS_EINVAL; - } - priv->unit = ch - '0'; - - dev = (struct uart_dev *)odev; - - OS_DEV_SETHANDLERS(odev, uart_hal_open, uart_hal_close); - - dev->ud_funcs.uf_start_tx = uart_hal_start_tx; - dev->ud_funcs.uf_start_rx = uart_hal_start_rx; - dev->ud_funcs.uf_blocking_tx = uart_hal_blocking_tx; - dev->ud_priv = priv; - - hal_uart_init(priv->unit, arg); - - return OS_OK; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b589e6c/kernel/os/src/arch/mips/os_arch_mips.c ---------------------------------------------------------------------- diff --git a/kernel/os/src/arch/mips/os_arch_mips.c b/kernel/os/src/arch/mips/os_arch_mips.c index 7ac01a9..d1d7401 100644 --- a/kernel/os/src/arch/mips/os_arch_mips.c +++ b/kernel/os/src/arch/mips/os_arch_mips.c @@ -19,6 +19,7 @@ #include "os/os.h" #include "os/os_arch.h" +#include "syscfg/syscfg.h" #include <hal/hal_bsp.h> #include <hal/hal_os_tick.h> @@ -43,7 +44,7 @@ extern struct os_task g_idle_task; void __attribute__((interrupt, keep_interrupts_masked)) _mips_isr_hw5(void) { - mips_setcompare(mips_getcompare() + 273000); + mips_setcompare(mips_getcompare() + ((MYNEWT_VAL(CLOCK_FREQ) / 2) / 1000)); timer_handler(); } @@ -134,9 +135,6 @@ os_arch_os_init(void) if (os_in_isr() == 0) { err = OS_OK; - /* Call bsp related OS initializations */ - bsp_init(); - /* should be in kernel mode here */ os_arch_init(); } @@ -155,7 +153,7 @@ os_arch_start(void) /* XXX: take this magic number (for a 1ms tick from a 546MHz clock) and put ** it in bsp or mcu somewhere */ - mips_setcompare(mips_getcount() + 273000); + mips_setcompare(mips_getcount() + ((MYNEWT_VAL(CLOCK_FREQ) / 2) / 1000)); /* global interrupt enable */ mips_bissr(1);
