lzbp li / mbed-stm32l0l1-src-un

Fork of mbed-stm32l0/l1-src by lzbp li

Revision:
630:825f75ca301e
Parent:
469:fc4922e0c183
--- a/targets/hal/TARGET_STM/TARGET_STM32F0/analogout_api.c	Mon Sep 28 10:30:09 2015 +0100
+++ b/targets/hal/TARGET_STM/TARGET_STM32F0/analogout_api.c	Mon Sep 28 10:45:10 2015 +0100
@@ -39,8 +39,7 @@
 
 static DAC_HandleTypeDef DacHandle;
 
-void analogout_init(dac_t *obj, PinName pin)
-{
+void analogout_init(dac_t *obj, PinName pin) {
     DAC_ChannelConfTypeDef sConfig;
 
     DacHandle.Instance = DAC;
@@ -71,8 +70,7 @@
     analogout_write_u16(obj, 0);
 }
 
-void analogout_free(dac_t *obj)
-{
+void analogout_free(dac_t *obj) {
     // Reset DAC and disable clock
     __DAC1_FORCE_RESET();
     __DAC1_RELEASE_RESET();
@@ -82,8 +80,7 @@
     pin_function(obj->pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
 }
 
-static inline void dac_write(dac_t *obj, uint16_t value)
-{
+static inline void dac_write(dac_t *obj, uint16_t value) {
     if (obj->pin == PA_4) {
         HAL_DAC_SetValue(&DacHandle, DAC_CHANNEL_1, DAC_ALIGN_12B_R, value);
         HAL_DAC_Start(&DacHandle, DAC_CHANNEL_1);
@@ -93,8 +90,7 @@
     }
 }
 
-static inline int dac_read(dac_t *obj)
-{
+static inline int dac_read(dac_t *obj) {
     if (obj->pin == PA_4) {
         return (int)HAL_DAC_GetValue(&DacHandle, DAC_CHANNEL_1);
     } else { // PA_5
@@ -102,8 +98,7 @@
     }
 }
 
-void analogout_write(dac_t *obj, float value)
-{
+void analogout_write(dac_t *obj, float value) {
     if (value < 0.0f) {
         dac_write(obj, 0); // Min value
     } else if (value > 1.0f) {
@@ -113,8 +108,7 @@
     }
 }
 
-void analogout_write_u16(dac_t *obj, uint16_t value)
-{
+void analogout_write_u16(dac_t *obj, uint16_t value) {
     if (value > (uint16_t)DAC_RANGE) {
         dac_write(obj, (uint16_t)DAC_RANGE); // Max value
     } else {
@@ -122,14 +116,12 @@
     }
 }
 
-float analogout_read(dac_t *obj)
-{
+float analogout_read(dac_t *obj) {
     uint32_t value = dac_read(obj);
     return (float)((float)value * (1.0f / (float)DAC_RANGE));
 }
 
-uint16_t analogout_read_u16(dac_t *obj)
-{
+uint16_t analogout_read_u16(dac_t *obj) {
     return (uint16_t)dac_read(obj);
 }