MYNEWT_542 Controller using a non-1MHz clock for cputime

Removed the CLOCK_FREQ definition from the BSP and replaced with
OS_CPUTIME_FREQ as there is no need for multiple definitions. Made
the call to os_cputime_init() based on OS_CPUTIME_TIMER_NUM. This
defaults to zero but can be overridden in a target or BSP.


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/f5d513f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f5d513f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f5d513f8

Branch: refs/heads/sensors_branch
Commit: f5d513f89787412a9c2a138da17f513ce3601664
Parents: 607dfa5
Author: William San Filippo <wi...@runtime.io>
Authored: Tue Jan 17 13:45:36 2017 -0800
Committer: William San Filippo <wi...@runtime.io>
Committed: Wed Jan 18 11:06:05 2017 -0800

----------------------------------------------------------------------
 hw/bsp/arduino_primo_nrf52/src/hal_bsp.c | 7 ++++---
 hw/bsp/arduino_primo_nrf52/syscfg.yml    | 4 ----
 hw/bsp/bmd300eval/src/hal_bsp.c          | 5 +++--
 hw/bsp/bmd300eval/syscfg.yml             | 4 ----
 hw/bsp/nrf52840pdk/src/hal_bsp.c         | 5 +++--
 hw/bsp/nrf52840pdk/syscfg.yml            | 4 +---
 hw/bsp/nrf52dk/src/hal_bsp.c             | 9 +++------
 hw/bsp/nrf52dk/syscfg.yml                | 4 +---
 hw/bsp/rb-nano2/src/hal_bsp.c            | 6 ++++--
 hw/bsp/rb-nano2/syscfg.yml               | 5 +----
 10 files changed, 20 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c 
b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
index ea2d74f..4e77617 100644
--- a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
+++ b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
@@ -53,7 +53,7 @@ static struct uart_dev os_bsp_bitbang_uart1;
 static const struct uart_bitbang_conf os_bsp_uart1_cfg = {
     .ubc_rxpin = MYNEWT_VAL(UART_1_PIN_TX),
     .ubc_txpin = MYNEWT_VAL(UART_1_PIN_RX),
-    .ubc_cputimer_freq = MYNEWT_VAL(CLOCK_FREQ),
+    .ubc_cputimer_freq = MYNEWT_VAL(OS_CPUTIME_FREQ),
 };
 #endif
 
@@ -168,9 +168,10 @@ hal_bsp_init(void)
     assert(rc == 0);
 #endif
 
-    /* Set cputime to count at 1 usec increments */
-    rc = os_cputime_init(MYNEWT_VAL(CLOCK_FREQ));
+#if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0)
+    rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
     assert(rc == 0);
+#endif
 
 #if MYNEWT_VAL(SPI_0_MASTER)
     rc = hal_spi_init(0, (void *)&os_bsp_spi0m_cfg, HAL_SPI_TYPE_MASTER);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/arduino_primo_nrf52/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/syscfg.yml 
b/hw/bsp/arduino_primo_nrf52/syscfg.yml
index e261799..bbc7875 100644
--- a/hw/bsp/arduino_primo_nrf52/syscfg.yml
+++ b/hw/bsp/arduino_primo_nrf52/syscfg.yml
@@ -28,10 +28,6 @@ syscfg.defs:
         description: 'TBD'
         value: 1
 
-    CLOCK_FREQ:
-        description: 'TBD'
-        value:  1000000
-
     XTAL_32768:
         description: 'TBD'
         value: 1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/bmd300eval/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/bmd300eval/src/hal_bsp.c b/hw/bsp/bmd300eval/src/hal_bsp.c
index 6d70e4a..057e08b 100644
--- a/hw/bsp/bmd300eval/src/hal_bsp.c
+++ b/hw/bsp/bmd300eval/src/hal_bsp.c
@@ -163,9 +163,10 @@ hal_bsp_init(void)
     assert(rc == 0);
 #endif
 
-    /* Set cputime to count at 1 usec increments */
-    rc = os_cputime_init(MYNEWT_VAL(CLOCK_FREQ));
+#if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0)
+    rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
     assert(rc == 0);
+#endif
 
 #if MYNEWT_VAL(SPI_0_MASTER)
     rc = hal_spi_init(0, (void *)&os_bsp_spi0m_cfg, HAL_SPI_TYPE_MASTER);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/bmd300eval/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/bmd300eval/syscfg.yml b/hw/bsp/bmd300eval/syscfg.yml
index 1d3b89b..02b29e0 100644
--- a/hw/bsp/bmd300eval/syscfg.yml
+++ b/hw/bsp/bmd300eval/syscfg.yml
@@ -24,10 +24,6 @@ syscfg.defs:
         description: 'TBD'
         value: 1
 
-    CLOCK_FREQ:
-        description: 'TBD'
-        value:  1000000
-
     XTAL_32768:
         description: 'TBD'
         value: 1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/nrf52840pdk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52840pdk/src/hal_bsp.c b/hw/bsp/nrf52840pdk/src/hal_bsp.c
index cbe15ea..7a1c6e8 100644
--- a/hw/bsp/nrf52840pdk/src/hal_bsp.c
+++ b/hw/bsp/nrf52840pdk/src/hal_bsp.c
@@ -174,9 +174,10 @@ hal_bsp_init(void)
     assert(rc == 0);
 #endif
 
-    /* Set cputime to count at 1 usec increments */
-    rc = os_cputime_init(MYNEWT_VAL(CLOCK_FREQ));
+#if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0)
+    rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
     assert(rc == 0);
+#endif
 
 #if MYNEWT_VAL(I2C_0)
     rc = hal_i2c_init(0, (void *)&hal_i2c_cfg);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/nrf52840pdk/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52840pdk/syscfg.yml b/hw/bsp/nrf52840pdk/syscfg.yml
index 452541c..4756488 100644
--- a/hw/bsp/nrf52840pdk/syscfg.yml
+++ b/hw/bsp/nrf52840pdk/syscfg.yml
@@ -23,12 +23,10 @@ syscfg.defs:
         description: 'TBD'
         value: 1
 
-    CLOCK_FREQ:
-        description: 'TBD'
-        value:  1000000
     XTAL_32768:
         description: 'TBD'
         value: 1
+
     UART_0:
         description: 'TBD'
         value:  1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/nrf52dk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/src/hal_bsp.c b/hw/bsp/nrf52dk/src/hal_bsp.c
index 188b488..be27d0c 100644
--- a/hw/bsp/nrf52dk/src/hal_bsp.c
+++ b/hw/bsp/nrf52dk/src/hal_bsp.c
@@ -182,14 +182,11 @@ hal_bsp_init(void)
     assert(rc == 0);
 #endif
 
-    /*
-     * What this depends on is what the OS_CPUTIME_TIMER_NUM is set to.
-     */
-#if MYNEWT_VAL(TIMER_0)
-    /* Set cputime to count at 1 usec increments */
-    rc = os_cputime_init(MYNEWT_VAL(CLOCK_FREQ));
+#if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0)
+    rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
     assert(rc == 0);
 #endif
+
 #if MYNEWT_VAL(I2C_0)
     rc = hal_i2c_init(0, (void *)&hal_i2c_cfg);
     assert(rc == 0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/nrf52dk/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/syscfg.yml b/hw/bsp/nrf52dk/syscfg.yml
index 458913b..1de4c56 100644
--- a/hw/bsp/nrf52dk/syscfg.yml
+++ b/hw/bsp/nrf52dk/syscfg.yml
@@ -23,12 +23,10 @@ syscfg.defs:
         description: 'TBD'
         value: 1
 
-    CLOCK_FREQ:
-        description: 'TBD'
-        value:  1000000
     XTAL_32768:
         description: 'TBD'
         value: 1
+
     UART_0:
         description: 'TBD'
         value:  1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/rb-nano2/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/rb-nano2/src/hal_bsp.c b/hw/bsp/rb-nano2/src/hal_bsp.c
index 3602354..cdcc354 100644
--- a/hw/bsp/rb-nano2/src/hal_bsp.c
+++ b/hw/bsp/rb-nano2/src/hal_bsp.c
@@ -154,9 +154,11 @@ hal_bsp_init(void)
     rc = hal_timer_init(5, NULL);
     assert(rc == 0);
 #endif
-    /* Set cputime to count at 1 usec increments */
-    rc = os_cputime_init(MYNEWT_VAL(CLOCK_FREQ));
+
+#if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0)
+    rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ));
     assert(rc == 0);
+#endif
 
 #if MYNEWT_VAL(UART_0)
     rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0",

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5d513f8/hw/bsp/rb-nano2/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/rb-nano2/syscfg.yml b/hw/bsp/rb-nano2/syscfg.yml
index 2c8aa6e..e3105ad 100644
--- a/hw/bsp/rb-nano2/syscfg.yml
+++ b/hw/bsp/rb-nano2/syscfg.yml
@@ -24,13 +24,10 @@ syscfg.defs:
         description: 'TBD'
         value: 1
 
-    CLOCK_FREQ:
-        description: 'TBD'
-        value:  1000000
-
     XTAL_32768:
         description: 'TBD'
         value: 1
+
     UART_0:
         description: 'TBD'
         value: 1

Reply via email to