You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/05/17 20:51:32 UTC

[09/50] [abbrv] incubator-mynewt-core git commit: add C++ guards, minor coding style updates

add C++ guards, minor coding style updates


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

Branch: refs/heads/master
Commit: d4d5d75fb55fb814877a4c8a4979f5080fa74be3
Parents: 7ce7eb1
Author: Sterling Hughes <st...@apache.org>
Authored: Mon May 9 17:52:58 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Mon May 9 17:53:09 2016 -0700

----------------------------------------------------------------------
 hw/hal/include/hal/flash_map.h     |  10 ++-
 hw/hal/include/hal/hal_adc.h       |  55 ++++++++-----
 hw/hal/include/hal/hal_adc_int.h   |  33 +++++---
 hw/hal/include/hal/hal_cputime.h   | 139 +++++++++++++++++---------------
 hw/hal/include/hal/hal_dac.h       |  63 +++++++++------
 hw/hal/include/hal/hal_dac_int.h   |  47 ++++++-----
 hw/hal/include/hal/hal_flash.h     |  10 ++-
 hw/hal/include/hal/hal_flash_int.h |  18 ++++-
 hw/hal/include/hal/hal_gpio.h      |  19 +++--
 hw/hal/include/hal/hal_i2c.h       |  57 ++++++-------
 hw/hal/include/hal/hal_i2c_int.h   |   9 +--
 hw/hal/include/hal/hal_os_tick.h   |  15 +++-
 hw/hal/include/hal/hal_pwm.h       |  47 +++++++----
 hw/hal/include/hal/hal_pwm_int.h   |  28 ++++---
 hw/hal/include/hal/hal_spi.h       |  29 +++----
 hw/hal/include/hal/hal_spi_int.h   |  53 +++++++-----
 hw/hal/include/hal/hal_system.h    |  11 ++-
 hw/hal/include/hal/hal_uart.h      |   7 +-
 18 files changed, 393 insertions(+), 257 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/flash_map.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/flash_map.h b/hw/hal/include/hal/flash_map.h
index 426a549..078d0a3 100644
--- a/hw/hal/include/hal/flash_map.h
+++ b/hw/hal/include/hal/flash_map.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,
@@ -20,6 +20,10 @@
 #ifndef H_UTIL_FLASH_MAP_
 #define H_UTIL_FLASH_MAP_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /**
  *
  * Provides abstraction of flash regions for type of use.
@@ -93,4 +97,8 @@ int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret);
 struct nffs_area_desc;
 int flash_area_to_nffs_desc(int idx, int *cnt, struct nffs_area_desc *nad);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* H_UTIL_FLASH_MAP_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_adc.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_adc.h b/hw/hal/include/hal/hal_adc.h
index 0577de5..84b16d5 100644
--- a/hw/hal/include/hal/hal_adc.h
+++ b/hw/hal/include/hal/hal_adc.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,
@@ -17,44 +17,57 @@
  * under the License.
  */
 
-#ifndef HAL_ADC_H
-#define HAL_ADC_H
+#ifndef H_HAL_ADC_
+#define H_HAL_ADC_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* for the pin descriptor enum */
-#include <bsp/bsp_sysid.h>    
+#include <bsp/bsp_sysid.h>
 
 /* This is the device for an ADC. The application using the ADC device
-  *does not need to know the definition of this device and can operate 
- * with a pointer to this device.  you can get/build device pointers in the 
- * BSP */
-struct hal_adc; 
+ * does not need to know the definition of this device and can operate
+ * with a pointer to this device.  you can get/build device pointers in the
+ * BSP
+ */
+struct hal_adc;
 
 /* initialize the ADC on the corresponding BSP Pin. Returns a pointer
- * to the adc object to use for the methods below. Returns NULL on 
- * error */
+ * to the adc object to use for the methods below. Returns NULL on
+ * error
+ */
  struct hal_adc *hal_adc_init(enum system_device_id sysid);
 
-/*
- * read the ADC corresponding to sysid in your system.  Returns
- * the  adc value read or negative on error, See 
- * hal_adc_get_resolution to check the range of the return value */
+/* read the ADC corresponding to sysid in your system.  Returns
+ * the  adc value read or negative on error, See
+ * hal_adc_get_resolution to check the range of the return value
+ */
 int hal_adc_read(struct hal_adc *padc);
 
-/* returns the number of bit of resolution in this ADC.  
- * For example if the system has an 8-bit ADC reporting 
+/* returns the number of bit of resolution in this ADC.
+ * For example if the system has an 8-bit ADC reporting
  * values from 0= to 255 (2^8-1), this function would return
- * the value 8. returns negative or zero on error */
+ * the value 8. returns negative or zero on error
+ */
 int hal_adc_get_bits(struct hal_adc *padc);
 
 /* Returns the positive reference voltage for a maximum ADC reading.
  * This API assumes the negative reference voltage is zero volt.
- * Returns negative or zero on error.  
+ * Returns negative or zero on error.
  */
 int hal_adc_get_ref_mv(struct hal_adc *padc);
 
 /* Converts and ADC value to millivolts. This is a helper function
- * but does call the ADC to get the reference voltage and 
- * resolution */
+ * but does call the ADC to get the reference voltage and
+ * resolution
+ */
 int hal_adc_to_mv(struct hal_adc *padc, int val);
 
-#endif /* HAL_ADC_H */  
\ No newline at end of file
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_HAL_ADC_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_adc_int.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_adc_int.h b/hw/hal/include/hal/hal_adc_int.h
index 53b10a4..109bb0a 100644
--- a/hw/hal/include/hal/hal_adc_int.h
+++ b/hw/hal/include/hal/hal_adc_int.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,
@@ -20,43 +20,52 @@
 #ifndef HAL_ADC_INT_H
 #define HAL_ADC_INT_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <inttypes.h>
 #include <bsp/bsp_sysid.h>
 
 
 struct hal_adc;
 
-/* These functions make up the driver API for ADC devices.  All 
- * ADC devices with Mynewt support implement this interface */
+/* These functions make up the driver API for ADC devices.  All
+ * ADC devices with Mynewt support implement this interface
+ */
 struct hal_adc_funcs {
     int (*hadc_read)            (struct hal_adc *padc);
     int (*hadc_get_bits)         (struct hal_adc *padc);
-    int (*hadc_get_ref_mv)       (struct hal_adc *padc);    
+    int (*hadc_get_ref_mv)       (struct hal_adc *padc);
 };
 
 /* This is the internal device representation for a hal_adc device.
- * 
+ *
  * Its main goal is to wrap the const drivers in a non-const structure.
  * Thus these can be made on the stack and wrapped with other non-const
- * structures. 
- * 
+ * structures.
+ *
  * For example, if you are creating a adc driver you can use
- * 
+ *
  * struct my_adc_driver {
  *     struct hal_adc_s parent;
  *     int              my_stuff 1;
  *     char            *mybuff;
  * };
- * 
- * See the native MCU and BSP for examples 
+ *
+ * See the native MCU and BSP for examples
  */
 struct hal_adc {
     const struct hal_adc_funcs  *driver_api;
 };
 
-/* The  BSP must implement this factory to get devices for the 
+/* The  BSP must implement this factory to get devices for the
  * application.  */
 extern struct hal_adc *
 bsp_get_hal_adc(enum system_device_id sysid);
 
-#endif /* HAL_ADC_INT_H */ 
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_ADC_INT_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/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 99662ca..63b723b 100644
--- a/hw/hal/include/hal/hal_cputime.h
+++ b/hw/hal/include/hal/hal_cputime.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,
@@ -16,9 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 #ifndef H_HAL_CPUTIME_
 #define H_HAL_CPUTIME_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "os/queue.h"
 
 /* CPU timer callback function */
@@ -26,8 +31,7 @@ struct cpu_timer;
 typedef void (*cputimer_func)(void *arg);
 
 /* CPU timer */
-struct cpu_timer
-{
+struct cpu_timer {
     cputimer_func   cb;
     void            *arg;
     uint32_t        cputime;
@@ -35,146 +39,146 @@ struct cpu_timer
 };
 
 /**
- * cputime init 
- *  
- * Initialize the cputime module. This must be called after os_init is called 
- * and before any other timer API are used. This should be called only once 
- * and should be called before the hardware timer is used. 
- * 
+ * cputime init
+ *
+ * Initialize the cputime module. This must be called after os_init is called
+ * and before any other timer API are used. This should be called only once
+ * and should be called before the hardware timer is used.
+ *
  * @param clock_freq The desired cputime frequency, in hertz (Hz).
- * 
+ *
  * @return int 0 on success; -1 on error.
  */
 int cputime_init(uint32_t clock_freq);
 
 /**
  * cputime get64
- *  
- * Returns cputime as a 64-bit number. 
- * 
+ *
+ * Returns cputime as a 64-bit number.
+ *
  * @return uint64_t The 64-bit representation of cputime.
  */
 uint64_t cputime_get64(void);
 
 /**
- * cputime get32 
- *  
- * Returns the low 32 bits of cputime. 
- * 
+ * cputime get32
+ *
+ * Returns the low 32 bits of cputime.
+ *
  * @return uint32_t The lower 32 bits of cputime
  */
 uint32_t cputime_get32(void);
 
 /**
- * cputime nsecs to ticks 
- *  
- * Converts the given number of nanoseconds into cputime ticks. 
- * 
+ * cputime nsecs to ticks
+ *
+ * Converts the given number of nanoseconds into cputime ticks.
+ *
  * @param usecs The number of nanoseconds to convert to ticks
- * 
+ *
  * @return uint32_t The number of ticks corresponding to 'nsecs'
  */
 uint32_t cputime_nsecs_to_ticks(uint32_t nsecs);
 
 /**
  * cputime ticks to nsecs
- *  
- * Convert the given number of ticks into nanoseconds. 
- * 
+ *
+ * Convert the given number of ticks into nanoseconds.
+ *
  * @param ticks The number of ticks to convert to nanoseconds.
- * 
+ *
  * @return uint32_t The number of nanoseconds corresponding to 'ticks'
  */
 uint32_t cputime_ticks_to_nsecs(uint32_t ticks);
 
 /**
- * cputime usecs to ticks 
- *  
- * Converts the given number of microseconds into cputime ticks. 
- * 
+ * cputime usecs to ticks
+ *
+ * Converts the given number of microseconds into cputime ticks.
+ *
  * @param usecs The number of microseconds to convert to ticks
- * 
+ *
  * @return uint32_t The number of ticks corresponding to 'usecs'
  */
 uint32_t cputime_usecs_to_ticks(uint32_t usecs);
 
 /**
  * cputime ticks to usecs
- *  
- * Convert the given number of ticks into microseconds. 
- * 
+ *
+ * Convert the given number of ticks into microseconds.
+ *
  * @param ticks The number of ticks to convert to microseconds.
- * 
+ *
  * @return uint32_t The number of microseconds corresponding to 'ticks'
  */
 uint32_t cputime_ticks_to_usecs(uint32_t ticks);
 
 /**
  * cputime delay ticks
- *  
- * Wait until the number of ticks has elapsed. This is a blocking delay. 
- * 
+ *
+ * Wait until the number of ticks has elapsed. This is a blocking delay.
+ *
  * @param ticks The number of ticks to wait.
  */
 void cputime_delay_ticks(uint32_t ticks);
 
 /**
- * cputime delay nsecs 
- *  
- * Wait until 'nsecs' nanoseconds has elapsed. This is a blocking delay. 
- *  
+ * cputime delay nsecs
+ *
+ * Wait until 'nsecs' nanoseconds has elapsed. This is a blocking delay.
+ *
  * @param nsecs The number of nanoseconds to wait.
  */
 void cputime_delay_nsecs(uint32_t nsecs);
 
 /**
- * cputime delay usecs 
- *  
- * Wait until 'usecs' microseconds has elapsed. This is a blocking delay. 
- *  
+ * cputime delay usecs
+ *
+ * Wait until 'usecs' microseconds has elapsed. This is a blocking delay.
+ *
  * @param usecs The number of usecs to wait.
  */
 void cputime_delay_usecs(uint32_t usecs);
 
 /**
  * cputime timer init
- * 
- * 
+ *
+ *
  * @param timer The timer to initialize. Cannot be NULL.
  * @param fp    The timer callback function. Cannot be NULL.
- * @param arg   Pointer to data object to pass to timer. 
+ * @param arg   Pointer to data object to pass to timer.
  */
 void cputime_timer_init(struct cpu_timer *timer, cputimer_func fp, void *arg);
 
 /**
- * cputime timer start 
- *  
- * Start a cputimer that will expire at 'cputime'. If cputime has already 
- * passed, the timer callback will still be called (at interrupt context). 
- * 
+ * cputime timer start
+ *
+ * Start a cputimer that will expire at 'cputime'. If cputime has already
+ * passed, the timer callback will still be called (at interrupt context).
+ *
  * @param timer     Pointer to timer to start. Cannot be NULL.
  * @param cputime   The cputime at which the timer should expire.
  */
 void cputime_timer_start(struct cpu_timer *timer, uint32_t cputime);
 
 /**
- * cputimer timer relative 
- *  
- * Sets a cpu timer that will expire 'usecs' microseconds from the current 
- * cputime. 
- * 
+ * cputimer timer relative
+ *
+ * Sets a cpu timer that will expire 'usecs' microseconds from the current
+ * cputime.
+ *
  * @param timer Pointer to timer. Cannot be NULL.
  * @param usecs The number of usecs from now at which the timer will expire.
  */
 void cputime_timer_relative(struct cpu_timer *timer, uint32_t usecs);
 
 /**
- * cputime timer stop 
- *  
- * Stops a cputimer from running. The timer is removed from the timer queue 
- * and interrupts are disabled if no timers are left on the queue. Can be 
- * called even if timer is not running. 
- * 
+ * cputime timer stop
+ *
+ * Stops a cputimer from running. The timer is removed from the timer queue
+ * and interrupts are disabled if no timers are left on the queue. Can be
+ * called even if timer is not running.
+ *
  * @param timer Pointer to cputimer to stop. Cannot be NULL.
  */
 void cputime_timer_stop(struct cpu_timer *timer);
@@ -184,4 +188,9 @@ void cputime_timer_stop(struct cpu_timer *timer);
 #define CPUTIME_GEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) >= 0)
 #define CPUTIME_LEQ(__t1, __t2) ((int32_t)  ((__t1) - (__t2)) <= 0)
 
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* H_HAL_CPUTIMER_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_dac.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_dac.h b/hw/hal/include/hal/hal_dac.h
index 5ae3f94..93eded4 100644
--- a/hw/hal/include/hal/hal_dac.h
+++ b/hw/hal/include/hal/hal_dac.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,
@@ -17,58 +17,64 @@
  * under the License.
  */
 
-#ifndef HAL_DAC_H
-#define HAL_DAC_H
+#ifndef HAL_DAC_H_
+#define HAL_DAC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* for the pin descriptor enum */
-#include <bsp/bsp_sysid.h>    
+#include <bsp/bsp_sysid.h>
 
-/* This is the device for a Digital to Analog Converter (DAC). 
+/* This is the device for a Digital to Analog Converter (DAC).
  * The application using the DAC device
- * does not need to know the definition of this device and can operate 
- * with a pointer to this device.  you can get/build device pointers in the 
- * BSP 
+ * does not need to know the definition of this device and can operate
+ * with a pointer to this device.  you can get/build device pointers in the
+ * BSP
  *
  * NOTE: You can also use PWM devices to simulate analog output.
- * These are defined in hal_pwm.h */
-struct hal_dac; 
+ * These are defined in hal_pwm.h
+ */
+struct hal_dac;
 
 /* initialize the DAC on the corresponding BSP device. Returns a pointer
- * to the DAC object to use for the methods below. Returns NULL on 
- * error */
+ * to the DAC object to use for the methods below. Returns NULL on
+ * error
+ */
 struct hal_dac *
 hal_dac_init(enum system_device_id sysid);
 
 /*
  * write the DAC corresponding to sysid in your system
- * and enables the DAC.  Return 0 on success negative on failures. If you 
- * write a value larger than the DAC size, it will get truncated to the 
+ * and enables the DAC.  Return 0 on success negative on failures. If you
+ * write a value larger than the DAC size, it will get truncated to the
  * maximum DAC value but the write will succeed.
  */
-int 
+int
 hal_dac_write(struct hal_dac *pdac, int val);
 
-/* 
+/*
  * Gets the current value that is output on the DAC .
  * Return the current value on success negative on failures.
  */
-int 
+int
 hal_dac_get_current(struct hal_dac *pdac);
 
-/* 
- * Returns the number of bit of resolution in this DAC.  
- * For example if the system has an 8-bit DAC reporting 
+/*
+ * Returns the number of bit of resolution in this DAC.
+ * For example if the system has an 8-bit DAC reporting
  * values from 0= to 255 (2^8-1), this function would return
  * the value 8. returns negative or zero on error */
-int 
+int
 hal_dac_get_bits(struct hal_dac *pdac);
 
-/* 
+/*
  * Returns the positive reference voltage for a maximum DAC reading.
  * This API assumes the negative reference voltage is zero volt.
- * Returns negative or zero on error.  
+ * Returns negative or zero on error.
  */
-int 
+int
 hal_dac_get_ref_mv(struct hal_dac *pdac);
 
 /* turns the DAC off.  Re-enable with hal_dac_write */
@@ -77,7 +83,12 @@ hal_dac_disable(struct hal_dac *pdac);
 
 
 /* Converts a value in millivolts to a DAC value for this DAC */
-int 
+int
 hal_dac_to_val(struct hal_dac *pdac, int mvolts);
 
-#endif /* HAL_DAC_H */  
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_HAL_DAC_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_dac_int.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_dac_int.h b/hw/hal/include/hal/hal_dac_int.h
index dcb0c31..2bb01cd 100644
--- a/hw/hal/include/hal/hal_dac_int.h
+++ b/hw/hal/include/hal/hal_dac_int.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,
@@ -17,49 +17,58 @@
  * under the License.
  */
 
-#ifndef HAL_DAC_INT_H
-#define HAL_DAC_INT_H
+#ifndef H_HAL_DAC_INT_
+#define H_HAL_DAC_INT_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include <bsp/bsp_sysid.h>
 
 
 struct hal_dac;
 
-/* These functions make up the driver API for DAC devices.  All 
- * DAC devices with Mynewt support implement this interface */
-struct hal_dac_funcs 
-{
+/* These functions make up the driver API for DAC devices.  All
+ * DAC devices with Mynewt support implement this interface
+ */
+struct hal_dac_funcs {
     int (*hdac_write)            (struct hal_dac *pdac, int val);
     int (*hdac_current)          (struct hal_dac *pdac);
     int (*hdac_disable)          (struct hal_dac *pdac);
     int (*hdac_get_bits)         (struct hal_dac *pdac);
-    int (*hdac_get_ref_mv)       (struct hal_dac *pdac);    
+    int (*hdac_get_ref_mv)       (struct hal_dac *pdac);
 };
 
 /* This is the internal device representation for a hal_dac device.
- * 
+ *
  * Its main goal is to wrap the const drivers in a non-const structure.
  * Thus these can be made on the stack and wrapped with other non-const
- * structures. 
- * 
+ * structures.
+ *
  * For example, if you are creating a dac driver you can use
- * 
+ *
  * struct my_dac_driver {
  *     struct hal_dac   parent;
  *     int              my_stuff 1;
  *     char            *mybuff;
  * };
- * 
- * See the native MCU and BSP for examples 
+ *
+ * See the native MCU and BSP for examples
  */
-struct hal_dac 
-{
+struct hal_dac {
     const struct hal_dac_funcs  *driver_api;
 };
 
-/* The  BSP must implement this factory to get devices for the 
- * application.  */
+/* The  BSP must implement this factory to get devices for the
+ * application.
+ */
 extern struct hal_dac *
 bsp_get_hal_dac(enum system_device_id sysid);
 
-#endif /* HAL_DAC_INT_H */ 
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_DAC_INT_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_flash.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_flash.h b/hw/hal/include/hal/hal_flash.h
index 6f024b7..d55a603 100644
--- a/hw/hal/include/hal/hal_flash.h
+++ b/hw/hal/include/hal/hal_flash.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,
@@ -20,6 +20,10 @@
 #ifndef H_HAL_FLASH_
 #define H_HAL_FLASH_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <inttypes.h>
 
 int hal_flash_read(uint8_t flash_id, uint32_t address, void *dst,
@@ -31,5 +35,9 @@ int hal_flash_erase(uint8_t flash_id, uint32_t address, uint32_t num_bytes);
 uint8_t hal_flash_align(uint8_t flash_id);
 int hal_flash_init(void);
 
+
+#ifdef __cplusplus
+}
 #endif
 
+#endif /* H_HAL_FLASH_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_flash_int.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_flash_int.h b/hw/hal/include/hal/hal_flash_int.h
index f3a6602..3be4572 100644
--- a/hw/hal/include/hal/hal_flash_int.h
+++ b/hw/hal/include/hal/hal_flash_int.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,
@@ -17,10 +17,15 @@
  * under the License.
  */
 
-#ifndef H_HAL_FLASH_INT
-#define H_HAL_FLASH_INT
+#ifndef H_HAL_FLASH_INT_
+#define H_HAL_FLASH_INT_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include <inttypes.h>
+
 /*
  * API that flash driver has to implement.
  */
@@ -48,4 +53,9 @@ uint32_t hal_flash_sector_size(const struct hal_flash *hf, int sec_idx);
 /* External function prototype supplied by BSP */
 const struct hal_flash *bsp_flash_dev(uint8_t flash_id);
 
-#endif /* H_HAL_FLASH_INT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_HAL_FLASH_INT_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_gpio.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_gpio.h b/hw/hal/include/hal/hal_gpio.h
index cc8a3fe..d85c682 100644
--- a/hw/hal/include/hal/hal_gpio.h
+++ b/hw/hal/include/hal/hal_gpio.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,
@@ -20,12 +20,15 @@
 #ifndef H_HAL_GPIO_
 #define H_HAL_GPIO_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * The "mode" of the gpio. The gpio is either an input, output, or it is
  * "not connected" (the pin specified is not functioning as a gpio)
  */
-enum gpio_mode_e
-{
+enum gpio_mode_e {
     GPIO_MODE_NC = -1,
     GPIO_MODE_IN = 0,
     GPIO_MODE_OUT = 1
@@ -35,8 +38,7 @@ typedef enum gpio_mode_e gpio_mode_t;
 /*
  * The "pull" of the gpio. This is either an input or an output.
  */
-enum gpio_pull
-{
+enum gpio_pull {
     GPIO_PULL_NONE = 0,     /* pull-up/down not enabled */
     GPIO_PULL_UP = 1,       /* pull-up enabled */
     GPIO_PULL_DOWN = 2      /* pull-down enabled */
@@ -46,8 +48,7 @@ typedef enum gpio_pull gpio_pull_t;
 /*
  * IRQ trigger type.
  */
-enum gpio_irq_trigger
-{
+enum gpio_irq_trigger {
     GPIO_TRIG_NONE = 0,
     GPIO_TRIG_RISING = 1,   /* IRQ occurs on rising edge */
     GPIO_TRIG_FALLING = 2,  /* IRQ occurs on falling edge */
@@ -143,4 +144,8 @@ void hal_gpio_irq_enable(int pin);
 void hal_gpio_irq_disable(int pin);
 
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* H_HAL_GPIO_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_i2c.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_i2c.h b/hw/hal/include/hal/hal_i2c.h
index 20b697d..a1361cd 100644
--- a/hw/hal/include/hal/hal_i2c.h
+++ b/hw/hal/include/hal/hal_i2c.h
@@ -17,8 +17,8 @@
  * under the License.
  */
 
-#ifndef HAL_I2C_H
-#define HAL_I2C_H
+#ifndef H_HAL_I2C_
+#define H_HAL_I2C_
 
 #include <inttypes.h>
 #include <bsp/bsp_sysid.h>
@@ -31,19 +31,19 @@ extern "C" {
  * allowing the mynewt device to function as an I2C master.
  *
  * A slave API is pending for future release
- * 
+ *
  * Typical usage of this API is as follows:
- * 
- * Initialize an i2c device with 
+ *
+ * Initialize an i2c device with
  *      hal_i2c_init()
- * 
+ *
  * When you with to perform an i2c transaction, issue
  *      hal_i2c_master_begin()l
  * followed by the transaction.  For example, in an I2C memory access access
  * you might write and address and then read back data
  *      hal_i2c_write(); -- write amemory ddress to device
  *      hal_i2c_read(); --- read back data
- * then end the transaction 
+ * then end the transaction
  *      hal_i2c_end();
  */
 
@@ -52,12 +52,12 @@ struct hal_i2c;
 /* when sending a packet, use this structure to pass the arguments */
 struct hal_i2c_master_data {
     uint8_t  address;   /* destination address */
-            /* a I2C address has 7 bits. In the protocol these 
+            /* a I2C address has 7 bits. In the protocol these
              * 7 bits are combined with a 1 bit R/W bit to specify read
-             * or write operation in an 8-bit address field sent to 
+             * or write operation in an 8-bit address field sent to
              * the remote device .  This API accepts the 7-bit
-             * address as its argument in the 7 LSBs of the 
-             * address field above.  For example if I2C was 
+             * address as its argument in the 7 LSBs of the
+             * address field above.  For example if I2C was
              * writing a 0x81 in its protocol, you would pass
              * only the top 7-bits to this function as 0x40 */
     uint16_t len;       /* number of buffer bytes to transmit or receive */
@@ -65,53 +65,56 @@ struct hal_i2c_master_data {
 };
 
 /* Initialize a new i2c device with the given system id.
- * Returns a pointer to the i2c device or NULL on error  */
+ * Returns a pointer to the i2c device or NULL on error
+ */
 struct hal_i2c*
 hal_i2c_init(enum system_device_id sysid);
 
-/* Sends a start condition and writes <len> bytes of data on the i2c.  
+/* Sends a start condition and writes <len> bytes of data on the i2c.
  * This API assumes that you have already called hal_i2c_master_begin
- *  It will fail if you have not. This API does NOT issue a stop condition.  
- * You must stop the bus after successful or unsuccessful write attempts.  
+ *  It will fail if you have not. This API does NOT issue a stop condition.
+ * You must stop the bus after successful or unsuccessful write attempts.
  * This API is blocking until an error or NaK occurs. Timeout is platform
  * dependent
- * Returns 0 on success, negative on failure */
+ * Returns 0 on success, negative on failure
+ */
 int
 hal_i2c_master_write(struct hal_i2c*, struct hal_i2c_master_data *pdata);
 
-/* Sends a start condition and reads <len> bytes of data on the i2c.  
+/* Sends a start condition and reads <len> bytes of data on the i2c.
  * This API assumes that you have already called hal_i2c_master_begin
- *  It will fail if you have not. This API does NOT issue a stop condition.  
- * You must stop the bus after successful or unsuccessful write attempts.  
+ *  It will fail if you have not. This API does NOT issue a stop condition.
+ * You must stop the bus after successful or unsuccessful write attempts.
  * This API is blocking until an error or NaK occurs. Timeout is platform
  * dependent
- * Returns 0 on success, negative on failure */
+ * Returns 0 on success, negative on failure
+ */
 int
 hal_i2c_master_read(struct hal_i2c*, struct hal_i2c_master_data *pdata);
 
-/* 
+/*
  * Starts an I2C transaction with the driver. This API does not send
  * anything over the bus itself
  */
-int 
+int
 hal_i2c_master_begin(struct hal_i2c*);
 
 /* issues a stop condition on the bus and ends the I2C transaction.
  * You must call i2c_master_end for every hal_i2c_master_begin
  * API call that succeeds  */
-int 
+int
 hal_i2c_master_end(struct hal_i2c*);
 
-/* Probes the i2c bus for a device with this address.  THIS API 
- * issues a start condition, probes the address using a read 
+/* Probes the i2c bus for a device with this address.  THIS API
+ * issues a start condition, probes the address using a read
  * command and issues a stop condition.   There is no need to call
  * hal_i2c_master_begin/end with this method
  */
-int 
+int
 hal_i2c_master_probe(struct hal_i2c*, uint8_t address);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* HAL_I2C_H */
+#endif /* H_HAL_I2C_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_i2c_int.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_i2c_int.h b/hw/hal/include/hal/hal_i2c_int.h
index 59593e0..13e6e5f 100644
--- a/hw/hal/include/hal/hal_i2c_int.h
+++ b/hw/hal/include/hal/hal_i2c_int.h
@@ -18,8 +18,8 @@
  */
 
 
-#ifndef HAL_I2C_INT_H
-#define HAL_I2C_INT_H
+#ifndef H_HAL_I2C_INT_
+#define H_HAL_I2C_INT_
 
 #ifdef __cplusplus
 extern "C" {
@@ -38,8 +38,7 @@ struct hal_i2c_funcs {
     int (*hi2cm_stop)       (struct hal_i2c *pi2c);
 };
 
-struct hal_i2c
-{
+struct hal_i2c {
     const struct hal_i2c_funcs *driver_api;
 };
 
@@ -50,5 +49,5 @@ bsp_get_hal_i2c_driver(enum system_device_id sysid);
 }
 #endif
 
-#endif /* HAL_I2C_INT_H */
+#endif /* H_HAL_I2C_INT_ */
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_os_tick.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_os_tick.h b/hw/hal/include/hal/hal_os_tick.h
index dce419e..85cff7a 100644
--- a/hw/hal/include/hal/hal_os_tick.h
+++ b/hw/hal/include/hal/hal_os_tick.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,
@@ -16,8 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#ifndef _HAL_OS_TICK_H_
-#define _HAL_OS_TICK_H_
+#ifndef H_HAL_OS_TICK_
+#define H_HAL_OS_TICK_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include <os/os_time.h>
 
@@ -32,4 +36,9 @@ void os_tick_init(uint32_t os_ticks_per_sec, int prio);
  */
 void os_tick_idle(os_time_t n);
 
+
+#ifdef __cplusplus
+}
 #endif
+
+#endif /* H_HAL_OS_TICK_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_pwm.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_pwm.h b/hw/hal/include/hal/hal_pwm.h
index 8eabc70..6deb1e7 100644
--- a/hw/hal/include/hal/hal_pwm.h
+++ b/hw/hal/include/hal/hal_pwm.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,
@@ -17,29 +17,37 @@
  * under the License.
  */
 
-#ifndef _HAL_HAL_PWM_H
-#define _HAL_HAL_PWM_H
+#ifndef H_HAL_HAL_PWM_
+#define H_HAL_HAL_PWM_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include <inttypes.h>
 #include <bsp/bsp_sysid.h>
 
 /* This is an abstract hardware API to Pulse Width Modulators.
- * A Pulse width module produces an output pulse stream with 
- * a specified period, and duty cycle. */
+ * A Pulse width module produces an output pulse stream with
+ * a specified period, and duty cycle.
+ */
 struct hal_pwm;
 
 /* Initialize a new PWM device with the given system id.
- * Returns negative on error, 0 on success. */
+ * Returns negative on error, 0 on success.
+ */
 struct hal_pwm*
 hal_pwm_init(enum system_device_id sysid);
 
 /* gets the underlying clock driving the PWM output. Return value
- * is in Hz. Returns negative on error */
-int 
+ * is in Hz. Returns negative on error
+ */
+int
 hal_pwm_get_source_clock_freq(struct hal_pwm *ppwm);
 
-/* gets the resolution of the PWM in bits.  An N-bit PWM can have 
- * on values between 0 and 2^bits - 1. Returns negative on error  */
+/* gets the resolution of the PWM in bits.  An N-bit PWM can have
+ * on values between 0 and 2^bits - 1. Returns negative on error
+ */
 int
 hal_pwm_get_resolution_bits(struct hal_pwm *ppwm);
 
@@ -47,16 +55,16 @@ hal_pwm_get_resolution_bits(struct hal_pwm *ppwm);
 int
 hal_pwm_disable(struct hal_pwm *ppwm);
 
-/* enables the PWM with duty cycle specified. This duty cycle is 
- * a fractional duty cycle where 0 == off, 65535=on, and 
+/* enables the PWM with duty cycle specified. This duty cycle is
+ * a fractional duty cycle where 0 == off, 65535=on, and
  * any value in between is on for fraction clocks and off
- * for 65535-fraction clocks.  
+ * for 65535-fraction clocks.
  */
 int
 hal_pwm_enable_duty_cycle(struct hal_pwm *ppwm, uint16_t fraction);
 
-/* 
- * This frequency must be between 1/2 the clock frequency and 
+/*
+ * This frequency must be between 1/2 the clock frequency and
  * the clock divided by the resolution. NOTE: This may affect
  * other PWM channels.
  */
@@ -64,8 +72,13 @@ int
 hal_pwm_set_frequency(struct hal_pwm *ppwm, uint32_t freq_hz);
 
 /* NOTE: If you know the resolution and clock frequency, you can
- * compute the period of the PWM Its 2^resolution/clock_freq */
+ * compute the period of the PWM Its 2^resolution/clock_freq
+ */
+
 
+#ifdef __cplusplus
+}
+#endif
 
-#endif /* _HAL_HAL_PWM_H */
 
+#endif /* H_HAL_HAL_PWM_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_pwm_int.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_pwm_int.h b/hw/hal/include/hal/hal_pwm_int.h
index f47233c..b081da1 100644
--- a/hw/hal/include/hal/hal_pwm_int.h
+++ b/hw/hal/include/hal/hal_pwm_int.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,
@@ -17,37 +17,43 @@
  * under the License.
  */
 
-#ifndef HAL_PWM_INT_H
-#define HAL_PWM_INT_H
+#ifndef H_HAL_PWM_INT_
+#define H_HAL_PWM_INT_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #include <hal/hal_pwm.h>
 #include <inttypes.h>
 
 /* when you are implementing a driver for the hal_pwm. This is the interface
- * you must provide.  
+ * you must provide.
  */
 
 struct hal_pwm;
 
-struct hal_pwm_funcs 
-{
-
+struct hal_pwm_funcs {
     /* the low level hal API */
     int     (*hpwm_get_bits)        (struct hal_pwm *ppwm);
     int     (*hpwm_get_clk)         (struct hal_pwm *ppwm);
     int     (*hpwm_disable)         (struct hal_pwm *ppwm);
     int     (*hpwm_ena_duty)  (struct hal_pwm *ppwm, uint16_t frac_duty);
     int     (*hpwm_set_freq)  (struct hal_pwm *ppwm, uint32_t freq_hz);
-    
+
 };
 
-struct hal_pwm 
-{
+struct hal_pwm {
     const struct hal_pwm_funcs *driver_api;
 };
 
 struct hal_pwm *
 bsp_get_hal_pwm_driver(enum system_device_id sysid);
 
-#endif /* HAL_PWM_INT_H */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_HAL_PWM_INT_ */
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_spi.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_spi.h b/hw/hal/include/hal/hal_spi.h
index a483563..587812f 100644
--- a/hw/hal/include/hal/hal_spi.h
+++ b/hw/hal/include/hal/hal_spi.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,
@@ -18,8 +18,8 @@
  */
 
 
-#ifndef HAL_SPI_H
-#define HAL_SPI_H
+#ifndef H_HAL_SPI_
+#define H_HAL_SPI_
 
 #ifdef __cplusplus
 extern "C" {
@@ -29,7 +29,7 @@ extern "C" {
 #include <bsp/bsp_sysid.h>
 
 struct hal_spi;
-   
+
 enum hal_spi_data_mode{
     HAL_SPI_MODE0,
     HAL_SPI_MODE1,
@@ -59,21 +59,23 @@ struct hal_spi_settings {
 };
 
 /* initialize the SPI on the corresponding BSP device. Returns a pointer
- * to the SPI object to use for the methods below. Returns NULL on 
- * error */
+ * to the SPI object to use for the methods below. Returns NULL on
+ * error
+ */
 struct hal_spi *
 hal_spi_init(enum system_device_id sysid);
 
 /* configure the spi., Reutrns 0 on success, negative on error */
-int 
+int
 hal_spi_config(struct hal_spi *pspi, struct hal_spi_settings *psettings);
 
-/* Do a blocking master spi transfer of one SPI data word. 
- * The data to send is an 8 or 9-bit pattern (depending on configuration) 
- * stored in <tx>.  NOTE: This does not send multiple bytes. The argument is 
+/* Do a blocking master spi transfer of one SPI data word.
+ * The data to send is an 8 or 9-bit pattern (depending on configuration)
+ * stored in <tx>.  NOTE: This does not send multiple bytes. The argument is
  * a 16-bit number to allow up to 9-bit SPI data words.
- * Returns the data received from the remote device or negative on error. */
-int 
+ * Returns the data received from the remote device or negative on error.
+ */
+int
 hal_spi_master_transfer(struct hal_spi *psdi, uint16_t tx);
 
 
@@ -81,5 +83,4 @@ hal_spi_master_transfer(struct hal_spi *psdi, uint16_t tx);
 }
 #endif
 
-#endif /* HAL_SPI_H */
-
+#endif /* H_HAL_SPI_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_spi_int.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_spi_int.h b/hw/hal/include/hal/hal_spi_int.h
index f30afdd..473e07e 100644
--- a/hw/hal/include/hal/hal_spi_int.h
+++ b/hw/hal/include/hal/hal_spi_int.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,
@@ -16,54 +16,63 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#include <bsp/bsp_sysid.h>
 
+#ifndef H_HAL_SPI_INT_
+#define H_HAL_SPI_INT_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-#ifndef HAL_SPI_INT_H
-#define HAL_SPI_INT_H
+#include <bsp/bsp_sysid.h>
 
 struct hal_spi;
 
 /* configure the spi */
-int 
+int
 hal_spi_config(struct hal_spi *pspi, struct hal_spi_settings *psettings);
 
 /* do a blocking master spi transfer */
-int 
+int
 hal_spi_master_transfer(struct hal_spi *psdi, uint16_t tx);
 
-/* These functions make up the driver API for DAC devices.  All 
- * DAC devices with Mynewt support implement this interface */
-struct hal_spi_funcs 
-{
+/* These functions make up the driver API for DAC devices.  All
+ * DAC devices with Mynewt support implement this interface
+ */
+struct hal_spi_funcs {
     int (*hspi_config)           (struct hal_spi *pspi, struct hal_spi_settings *psettings);
-    int (*hspi_master_transfer)  (struct hal_spi *psdi, uint16_t tx);  
+    int (*hspi_master_transfer)  (struct hal_spi *psdi, uint16_t tx);
 };
 
 /* This is the internal device representation for a hal_spi device.
- * 
+ *
  * Its main goal is to wrap the const drivers in a non-const structure.
  * Thus these can be made on the stack and wrapped with other non-const
- * structures. 
- * 
+ * structures.
+ *
  * For example, if you are creating a spi driver you can use
- * 
+ *
  * struct my_spi_driver {
  *     struct hal_spi   parent;
  *     int              my_stuff 1;
  *     char            *mybuff;
  * };
- * 
- * See the native MCU and BSP for examples 
+ *
+ * See the native MCU and BSP for examples
  */
-struct hal_spi 
-{
+struct hal_spi {
     const struct hal_spi_funcs  *driver_api;
 };
 
-/* The  BSP must implement this factory to get devices for the 
- * application.  */
+/* The  BSP must implement this factory to get devices for the
+ * application.
+ */
 extern struct hal_spi *
 bsp_get_hal_spi(enum system_device_id sysid);
 
-#endif /* HAL_SPI_INT_H */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_HAL_SPI_INT_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_system.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_system.h b/hw/hal/include/hal/hal_system.h
index 2a6a3a0..32aad1a 100644
--- a/hw/hal/include/hal/hal_system.h
+++ b/hw/hal/include/hal/hal_system.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,
@@ -20,6 +20,10 @@
 #ifndef H_HAL_SYSTEM_
 #define H_HAL_SYSTEM_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * System reset.
  */
@@ -30,4 +34,9 @@ void system_reset(void) __attribute((noreturn));
  */
 void system_start(void *img_start) __attribute((noreturn));
 
+
+#ifdef __cplusplus
+}
 #endif
+
+#endif /* H_HAL_SYSTEM_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d4d5d75f/hw/hal/include/hal/hal_uart.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_uart.h b/hw/hal/include/hal/hal_uart.h
index 041bc4a..e9a0157 100644
--- a/hw/hal/include/hal/hal_uart.h
+++ b/hw/hal/include/hal/hal_uart.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,
@@ -16,9 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 #ifndef H_HAL_UART_H_
 #define H_HAL_UART_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <inttypes.h>
 
 /*