mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: targets/TARGET_STM/TARGET_STM32L0/analogout_device.c
- Revision:
- 187:0387e8f68319
- Parent:
- 176:447f873cad2f
--- a/targets/TARGET_STM/TARGET_STM32L0/analogout_device.c Fri Jun 22 16:45:37 2018 +0100 +++ b/targets/TARGET_STM/TARGET_STM32L0/analogout_device.c Thu Sep 06 13:40:20 2018 +0100 @@ -39,7 +39,8 @@ static int channel1_used = 0; static int channel2_used = 0; -void analogout_init(dac_t *obj, PinName pin) { +void analogout_init(dac_t *obj, PinName pin) +{ DAC_ChannelConfTypeDef sConfig = {0}; // Get the peripheral name from the pin and assign it to the object @@ -76,7 +77,7 @@ obj->handle.Instance = DAC; obj->handle.State = HAL_DAC_STATE_RESET; - if (HAL_DAC_Init(&obj->handle) != HAL_OK ) { + if (HAL_DAC_Init(&obj->handle) != HAL_OK) { error("HAL_DAC_Init failed"); } @@ -96,11 +97,16 @@ analogout_write_u16(obj, 0); } -void analogout_free(dac_t *obj) { +void analogout_free(dac_t *obj) +{ // Reset DAC and disable clock - if (obj->channel == DAC_CHANNEL_1) channel1_used = 0; + if (obj->channel == DAC_CHANNEL_1) { + channel1_used = 0; + } #if defined(DAC_CHANNEL_2) - if (obj->channel == DAC_CHANNEL_2) channel2_used = 0; + if (obj->channel == DAC_CHANNEL_2) { + channel2_used = 0; + } #endif if ((channel1_used == 0) && (channel2_used == 0)) { __DAC_FORCE_RESET();