mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c
- Revision:
- 174:8bb9f3a33240
- Parent:
- 129:0182c99221bc
- Child:
- 215:83cf97a28428
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c Mon Apr 28 18:15:06 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c Tue Apr 29 11:15:07 2014 +0100 @@ -43,7 +43,7 @@ void analogout_init(dac_t *obj, PinName pin) { DAC_InitTypeDef DAC_InitStructure; - + // Get the peripheral name (DAC_1, ...) from the pin and assign it to the object obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC); @@ -65,7 +65,7 @@ DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0; DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable; - + if (obj->channel == PA_4) { DAC_Init(DAC_Channel_1, &DAC_InitStructure); DAC_Cmd(DAC_Channel_1, ENABLE); @@ -74,7 +74,7 @@ DAC_Init(DAC_Channel_2, &DAC_InitStructure); DAC_Cmd(DAC_Channel_2, ENABLE); } - + analogout_write_u16(obj, 0); } @@ -112,10 +112,9 @@ void analogout_write_u16(dac_t *obj, uint16_t value) { if (value > (uint16_t)RANGE_12BIT) { - dac_write(obj, (uint16_t)RANGE_12BIT); // Max value - } - else { - dac_write(obj, value); + dac_write(obj, (uint16_t)RANGE_12BIT); // Max value + } else { + dac_write(obj, value); } }