[18/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-79: move common hal code from mcu to hal

2016-07-08 Thread ccollins
MYNEWT-79: move common hal code from mcu to hal


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

Branch: refs/heads/master
Commit: 183873d8890de9fb6579dc3a738937c1b1d8006d
Parents: 7bd50b3
Author: William San Filippo 
Authored: Fri Jun 17 10:46:20 2016 -0700
Committer: William San Filippo 
Committed: Thu Jun 23 16:39:04 2016 -0700

--
 hw/hal/include/hal/hal_cputime.h |  30 +-
 hw/mcu/native/src/hal_cputime.c  | 385 +++---
 hw/mcu/nordic/nrf51xxx/src/hal_cputime.c | 308 +
 hw/mcu/nordic/nrf52xxx/src/hal_cputime.c | 318 +
 hw/mcu/stm/stm32f4xx/src/hal_cputime.c   | 355 +++-
 5 files changed, 111 insertions(+), 1285 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/183873d8/hw/hal/include/hal/hal_cputime.h
--
diff --git a/hw/hal/include/hal/hal_cputime.h b/hw/hal/include/hal/hal_cputime.h
index 63b723b..001bac5 100644
--- a/hw/hal/include/hal/hal_cputime.h
+++ b/hw/hal/include/hal/hal_cputime.h
@@ -38,6 +38,23 @@ struct cpu_timer {
 TAILQ_ENTRY(cpu_timer) link;
 };
 
+/* CPUTIME data. */
+struct cputime_data
+{
+uint32_t ticks_per_usec;/* number of ticks per usec */
+uint32_t cputime_high;  /* high word of 64-bit cpu time */
+uint32_t timer_isrs;/* Number of timer interrupts */
+uint32_t ocmp_ints; /* Number of ocmp interrupts */
+uint32_t uif_ints;  /* Number of overflow interrupts */
+};
+extern struct cputime_data g_cputime;
+
+/* Helpful macros to compare cputimes */
+#define CPUTIME_LT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) < 0)
+#define CPUTIME_GT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) > 0)
+#define CPUTIME_GEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) >= 0)
+#define CPUTIME_LEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) <= 0)
+
 /**
  * cputime init
  *
@@ -183,11 +200,16 @@ void cputime_timer_relative(struct cpu_timer *timer, 
uint32_t usecs);
  */
 void cputime_timer_stop(struct cpu_timer *timer);
 
-#define CPUTIME_LT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) < 0)
-#define CPUTIME_GT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) > 0)
-#define CPUTIME_GEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) >= 0)
-#define CPUTIME_LEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) <= 0)
+/*
+ * Used between MCU specific files and generic HAL. Not intended as an API
+ * to be called by the user.
+ */
+void cputime_chk_expiration(void);
 
+/*--- HW specific API. These are not intended to be called by user  ---*/
+void cputime_disable_ocmp(void);
+void cputime_set_ocmp(struct cpu_timer *timer);
+int cputime_hw_init(uint32_t clock_freq);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/183873d8/hw/mcu/native/src/hal_cputime.c
--
diff --git a/hw/mcu/native/src/hal_cputime.c b/hw/mcu/native/src/hal_cputime.c
index b493a7d..850bfc5 100644
--- a/hw/mcu/native/src/hal_cputime.c
+++ b/hw/mcu/native/src/hal_cputime.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,
@@ -21,21 +21,6 @@
 #include "os/os.h"
 #include "hal/hal_cputime.h"
 
-/* CPUTIME data */
-struct cputime_data
-{
-uint32_t ticks_per_usec;/* number of ticks per usec */
-uint32_t timer_isrs;/* Number of timer interrupts */
-uint32_t ocmp_ints; /* Number of ocmp interrupts */
-uint32_t uif_ints;  /* Number of overflow interrupts */
-uint32_t last_ostime;
-uint64_t cputime;   /* 64-bit cputime */
-};
-struct cputime_data g_cputime;
-
-/* Queue for timers */
-TAILQ_HEAD(cputime_qhead, cpu_timer) g_cputimer_q;
-
 /* For native cpu implementation */
 #define NATIVE_CPUTIME_STACK_SIZE   (1024)
 os_stack_t g_native_cputime_stack[NATIVE_CPUTIME_STACK_SIZE];
@@ -44,15 +29,16 @@ struct os_task g_native_cputime_task;
 struct os_callout_func g_native_cputimer;
 struct os_eventq g_native_cputime_evq;
 static uint32_t g_native_cputime_cputicks_per_ostick;
-
+static uint64_t g_native_cputime;
+static uint32_t g_native_cputime_last_ostime;
 
 /**
  * Convert cpu time ticks to os ticks.
- * 
- * 
- * @param cputicks 
- * 
- * @return uint32_t 
+ *
+ *

[2/2] incubator-mynewt-core git commit: MYNEWT-79: move common hal code from mcu to hal

2016-06-23 Thread wes3
MYNEWT-79: move common hal code from mcu to hal


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

Branch: refs/heads/develop
Commit: 183873d8890de9fb6579dc3a738937c1b1d8006d
Parents: 7bd50b3
Author: William San Filippo 
Authored: Fri Jun 17 10:46:20 2016 -0700
Committer: William San Filippo 
Committed: Thu Jun 23 16:39:04 2016 -0700

--
 hw/hal/include/hal/hal_cputime.h |  30 +-
 hw/mcu/native/src/hal_cputime.c  | 385 +++---
 hw/mcu/nordic/nrf51xxx/src/hal_cputime.c | 308 +
 hw/mcu/nordic/nrf52xxx/src/hal_cputime.c | 318 +
 hw/mcu/stm/stm32f4xx/src/hal_cputime.c   | 355 +++-
 5 files changed, 111 insertions(+), 1285 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/183873d8/hw/hal/include/hal/hal_cputime.h
--
diff --git a/hw/hal/include/hal/hal_cputime.h b/hw/hal/include/hal/hal_cputime.h
index 63b723b..001bac5 100644
--- a/hw/hal/include/hal/hal_cputime.h
+++ b/hw/hal/include/hal/hal_cputime.h
@@ -38,6 +38,23 @@ struct cpu_timer {
 TAILQ_ENTRY(cpu_timer) link;
 };
 
+/* CPUTIME data. */
+struct cputime_data
+{
+uint32_t ticks_per_usec;/* number of ticks per usec */
+uint32_t cputime_high;  /* high word of 64-bit cpu time */
+uint32_t timer_isrs;/* Number of timer interrupts */
+uint32_t ocmp_ints; /* Number of ocmp interrupts */
+uint32_t uif_ints;  /* Number of overflow interrupts */
+};
+extern struct cputime_data g_cputime;
+
+/* Helpful macros to compare cputimes */
+#define CPUTIME_LT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) < 0)
+#define CPUTIME_GT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) > 0)
+#define CPUTIME_GEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) >= 0)
+#define CPUTIME_LEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) <= 0)
+
 /**
  * cputime init
  *
@@ -183,11 +200,16 @@ void cputime_timer_relative(struct cpu_timer *timer, 
uint32_t usecs);
  */
 void cputime_timer_stop(struct cpu_timer *timer);
 
-#define CPUTIME_LT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) < 0)
-#define CPUTIME_GT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) > 0)
-#define CPUTIME_GEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) >= 0)
-#define CPUTIME_LEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) <= 0)
+/*
+ * Used between MCU specific files and generic HAL. Not intended as an API
+ * to be called by the user.
+ */
+void cputime_chk_expiration(void);
 
+/*--- HW specific API. These are not intended to be called by user  ---*/
+void cputime_disable_ocmp(void);
+void cputime_set_ocmp(struct cpu_timer *timer);
+int cputime_hw_init(uint32_t clock_freq);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/183873d8/hw/mcu/native/src/hal_cputime.c
--
diff --git a/hw/mcu/native/src/hal_cputime.c b/hw/mcu/native/src/hal_cputime.c
index b493a7d..850bfc5 100644
--- a/hw/mcu/native/src/hal_cputime.c
+++ b/hw/mcu/native/src/hal_cputime.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,
@@ -21,21 +21,6 @@
 #include "os/os.h"
 #include "hal/hal_cputime.h"
 
-/* CPUTIME data */
-struct cputime_data
-{
-uint32_t ticks_per_usec;/* number of ticks per usec */
-uint32_t timer_isrs;/* Number of timer interrupts */
-uint32_t ocmp_ints; /* Number of ocmp interrupts */
-uint32_t uif_ints;  /* Number of overflow interrupts */
-uint32_t last_ostime;
-uint64_t cputime;   /* 64-bit cputime */
-};
-struct cputime_data g_cputime;
-
-/* Queue for timers */
-TAILQ_HEAD(cputime_qhead, cpu_timer) g_cputimer_q;
-
 /* For native cpu implementation */
 #define NATIVE_CPUTIME_STACK_SIZE   (1024)
 os_stack_t g_native_cputime_stack[NATIVE_CPUTIME_STACK_SIZE];
@@ -44,15 +29,16 @@ struct os_task g_native_cputime_task;
 struct os_callout_func g_native_cputimer;
 struct os_eventq g_native_cputime_evq;
 static uint32_t g_native_cputime_cputicks_per_ostick;
-
+static uint64_t g_native_cputime;
+static uint32_t g_native_cputime_last_ostime;
 
 /**
  * Convert cpu time ticks to os ticks.
- * 
- * 
- * @param cputicks 
- * 
- * @return uint32_t 
+ *
+ *

incubator-mynewt-core git commit: MYNEWT-79: move common hal code from mcu to hal

2016-06-17 Thread wes3
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/cputime [created] 8bcec2849


MYNEWT-79: move common hal code from mcu to hal


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

Branch: refs/heads/cputime
Commit: 8bcec284909029f588d493d31e211766f1efbb21
Parents: daab074
Author: William San Filippo 
Authored: Fri Jun 17 10:46:20 2016 -0700
Committer: William San Filippo 
Committed: Fri Jun 17 10:46:20 2016 -0700

--
 hw/hal/include/hal/hal_cputime.h |  30 +-
 hw/mcu/native/src/hal_cputime.c  | 385 +++---
 hw/mcu/nordic/nrf51xxx/src/hal_cputime.c | 308 +
 hw/mcu/nordic/nrf52xxx/src/hal_cputime.c | 318 +
 hw/mcu/stm/stm32f4xx/src/hal_cputime.c   | 355 +++-
 5 files changed, 111 insertions(+), 1285 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8bcec284/hw/hal/include/hal/hal_cputime.h
--
diff --git a/hw/hal/include/hal/hal_cputime.h b/hw/hal/include/hal/hal_cputime.h
index 63b723b..001bac5 100644
--- a/hw/hal/include/hal/hal_cputime.h
+++ b/hw/hal/include/hal/hal_cputime.h
@@ -38,6 +38,23 @@ struct cpu_timer {
 TAILQ_ENTRY(cpu_timer) link;
 };
 
+/* CPUTIME data. */
+struct cputime_data
+{
+uint32_t ticks_per_usec;/* number of ticks per usec */
+uint32_t cputime_high;  /* high word of 64-bit cpu time */
+uint32_t timer_isrs;/* Number of timer interrupts */
+uint32_t ocmp_ints; /* Number of ocmp interrupts */
+uint32_t uif_ints;  /* Number of overflow interrupts */
+};
+extern struct cputime_data g_cputime;
+
+/* Helpful macros to compare cputimes */
+#define CPUTIME_LT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) < 0)
+#define CPUTIME_GT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) > 0)
+#define CPUTIME_GEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) >= 0)
+#define CPUTIME_LEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) <= 0)
+
 /**
  * cputime init
  *
@@ -183,11 +200,16 @@ void cputime_timer_relative(struct cpu_timer *timer, 
uint32_t usecs);
  */
 void cputime_timer_stop(struct cpu_timer *timer);
 
-#define CPUTIME_LT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) < 0)
-#define CPUTIME_GT(__t1, __t2) ((int32_t)   ((__t1) - (__t2)) > 0)
-#define CPUTIME_GEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) >= 0)
-#define CPUTIME_LEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) <= 0)
+/*
+ * Used between MCU specific files and generic HAL. Not intended as an API
+ * to be called by the user.
+ */
+void cputime_chk_expiration(void);
 
+/*--- HW specific API. These are not intended to be called by user  ---*/
+void cputime_disable_ocmp(void);
+void cputime_set_ocmp(struct cpu_timer *timer);
+int cputime_hw_init(uint32_t clock_freq);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8bcec284/hw/mcu/native/src/hal_cputime.c
--
diff --git a/hw/mcu/native/src/hal_cputime.c b/hw/mcu/native/src/hal_cputime.c
index b493a7d..850bfc5 100644
--- a/hw/mcu/native/src/hal_cputime.c
+++ b/hw/mcu/native/src/hal_cputime.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,
@@ -21,21 +21,6 @@
 #include "os/os.h"
 #include "hal/hal_cputime.h"
 
-/* CPUTIME data */
-struct cputime_data
-{
-uint32_t ticks_per_usec;/* number of ticks per usec */
-uint32_t timer_isrs;/* Number of timer interrupts */
-uint32_t ocmp_ints; /* Number of ocmp interrupts */
-uint32_t uif_ints;  /* Number of overflow interrupts */
-uint32_t last_ostime;
-uint64_t cputime;   /* 64-bit cputime */
-};
-struct cputime_data g_cputime;
-
-/* Queue for timers */
-TAILQ_HEAD(cputime_qhead, cpu_timer) g_cputimer_q;
-
 /* For native cpu implementation */
 #define NATIVE_CPUTIME_STACK_SIZE   (1024)
 os_stack_t g_native_cputime_stack[NATIVE_CPUTIME_STACK_SIZE];
@@ -44,15 +29,16 @@ struct os_task g_native_cputime_task;
 struct os_callout_func g_native_cputimer;
 struct os_eventq g_native_cputime_evq;
 static uint32_t g_native_cputime_cputicks_per_ostick;
-
+static uint64_t g_native_cputime;
+static uint32_t g_native_cputime_last_ostime;
 
 /**
  *