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/04/12 22:34:50 UTC

[2/4] incubator-mynewt-core git commit: added a disable API for hal_dac

added a disable API for hal_dac

Also fixed code to better match coding standard


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

Branch: refs/heads/develop
Commit: 18324c89dc63ecb7afefaae9261fca9756ecdb0e
Parents: 9e1d390
Author: Paul Dietrich <pa...@yahoo.com>
Authored: Sat Apr 9 17:33:20 2016 -0700
Committer: Paul Dietrich <pa...@yahoo.com>
Committed: Tue Apr 12 12:16:56 2016 -0700

----------------------------------------------------------------------
 hw/hal/include/hal/hal_dac.h     | 26 ++++++++++++++++----------
 hw/hal/include/hal/hal_dac_int.h |  8 +++++---
 hw/hal/src/hal_dac.c             | 10 +++++++++-
 3 files changed, 30 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/18324c89/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 ab765de..5ae3f94 100644
--- a/hw/hal/include/hal/hal_dac.h
+++ b/hw/hal/include/hal/hal_dac.h
@@ -40,38 +40,44 @@ struct hal_dac *
 hal_dac_init(enum system_device_id sysid);
 
 /*
- * write the DAC corresponding to sysid in your system.  
- * 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.
+ * 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 
+ * maximum DAC value but the write will succeed.
  */
 int 
 hal_dac_write(struct hal_dac *pdac, int val);
 
-/* gets the current value that is output on the DAC .
+/* 
+ * Gets the current value that is output on the DAC .
  * Return the current value on success negative on failures.
  */
 int 
 hal_dac_get_current(struct hal_dac *pdac);
 
-/* returns the number of bit of resolution in this DAC.  
+/* 
+ * 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 
 hal_dac_get_bits(struct hal_dac *pdac);
 
-/* Returns the positive reference voltage for a maximum DAC reading.
+/* 
+ * 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.  
  */
 int 
 hal_dac_get_ref_mv(struct hal_dac *pdac);
 
+/* turns the DAC off.  Re-enable with hal_dac_write */
+int
+hal_dac_disable(struct hal_dac *pdac);
+
+
 /* Converts a value in millivolts to a DAC value for this DAC */
 int 
 hal_dac_to_val(struct hal_dac *pdac, int mvolts);
 
-
-#endif /* HAL_DAC_H */  
\ No newline at end of file
+#endif /* HAL_DAC_H */  

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/18324c89/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 fa679d7..dcb0c31 100644
--- a/hw/hal/include/hal/hal_dac_int.h
+++ b/hw/hal/include/hal/hal_dac_int.h
@@ -20,7 +20,6 @@
 #ifndef HAL_DAC_INT_H
 #define HAL_DAC_INT_H
 
-#include <inttypes.h>
 #include <bsp/bsp_sysid.h>
 
 
@@ -28,9 +27,11 @@ 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 {
+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);    
 };
@@ -51,7 +52,8 @@ struct hal_dac_funcs {
  * 
  * See the native MCU and BSP for examples 
  */
-struct hal_dac {
+struct hal_dac 
+{
     const struct hal_dac_funcs  *driver_api;
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/18324c89/hw/hal/src/hal_dac.c
----------------------------------------------------------------------
diff --git a/hw/hal/src/hal_dac.c b/hw/hal/src/hal_dac.c
index 3e334a3..c083a75 100644
--- a/hw/hal/src/hal_dac.c
+++ b/hw/hal/src/hal_dac.c
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#include <inttypes.h>
 #include <hal/hal_dac.h>
 #include <hal/hal_dac_int.h>
 
@@ -86,3 +85,12 @@ hal_dac_to_val(struct hal_dac *pdac, int mvolts)
     }
     return rc;
 }
+
+int 
+hal_dac_disable(struct hal_dac *pdac) 
+{
+    if (pdac && pdac->driver_api && pdac->driver_api->hdac_disable) {
+        return pdac->driver_api->hdac_disable(pdac);
+    }
+    return -1;
+}