Skip to content

Commit 88b82e3

Browse files
committed
fix init struct analogout
1 parent 373e6ab commit 88b82e3

File tree

7 files changed

+20
-6
lines changed

7 files changed

+20
-6
lines changed

targets/TARGET_STM/TARGET_STM32F0/analogout_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "PeripheralPins.h"
3737

3838
void analogout_init(dac_t *obj, PinName pin) {
39-
DAC_ChannelConfTypeDef sConfig;
39+
DAC_ChannelConfTypeDef sConfig = {0};
4040

4141
// Get the peripheral name from the pin and assign it to the object
4242
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
@@ -71,6 +71,8 @@ void analogout_init(dac_t *obj, PinName pin) {
7171

7272
// Configure DAC
7373
obj->handle.Instance = (DAC_TypeDef *)(obj->dac);
74+
obj->handle.State = HAL_DAC_STATE_RESET;
75+
7476
if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
7577
error("HAL_DAC_Init failed");
7678
}

targets/TARGET_STM/TARGET_STM32F3/analogout_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static int pa4_used = 0;
4040
static int pa5_used = 0;
4141

4242
void analogout_init(dac_t *obj, PinName pin) {
43-
DAC_ChannelConfTypeDef sConfig;
43+
DAC_ChannelConfTypeDef sConfig = {0};
4444

4545
// Get the peripheral name from the pin and assign it to the object
4646
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
@@ -83,6 +83,8 @@ void analogout_init(dac_t *obj, PinName pin) {
8383

8484
// Configure DAC
8585
obj->handle.Instance = (DAC_TypeDef *)(obj->dac);
86+
obj->handle.State = HAL_DAC_STATE_RESET;
87+
8688
if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
8789
error("HAL_DAC_Init failed");
8890
}

targets/TARGET_STM/TARGET_STM32F4/analogout_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "PeripheralPins.h"
3737

3838
void analogout_init(dac_t *obj, PinName pin) {
39-
DAC_ChannelConfTypeDef sConfig;
39+
DAC_ChannelConfTypeDef sConfig = {0};
4040

4141
// Get the peripheral name (DAC_1, ...) from the pin and assign it to the object
4242
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
@@ -71,6 +71,8 @@ void analogout_init(dac_t *obj, PinName pin) {
7171
__HAL_RCC_DAC_CLK_ENABLE();
7272

7373
obj->handle.Instance = DAC;
74+
obj->handle.State = HAL_DAC_STATE_RESET;
75+
7476
if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
7577
error("HAL_DAC_Init failed");
7678
}

targets/TARGET_STM/TARGET_STM32F7/analogout_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "PeripheralPins.h"
3737

3838
void analogout_init(dac_t *obj, PinName pin) {
39-
DAC_ChannelConfTypeDef sConfig;
39+
DAC_ChannelConfTypeDef sConfig = {0};
4040

4141
// Get the peripheral name (DAC_1, ...) from the pin and assign it to the object
4242
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
@@ -71,6 +71,8 @@ void analogout_init(dac_t *obj, PinName pin) {
7171
__DAC_CLK_ENABLE();
7272

7373
obj->handle.Instance = DAC;
74+
obj->handle.State = HAL_DAC_STATE_RESET;
75+
7476
if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
7577
error("HAL_DAC_Init failed");
7678
}

targets/TARGET_STM/TARGET_STM32L0/analogout_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static int channel1_used = 0;
4040
static int channel2_used = 0;
4141

4242
void analogout_init(dac_t *obj, PinName pin) {
43-
DAC_ChannelConfTypeDef sConfig;
43+
DAC_ChannelConfTypeDef sConfig = {0};
4444

4545
// Get the peripheral name from the pin and assign it to the object
4646
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
@@ -74,6 +74,8 @@ void analogout_init(dac_t *obj, PinName pin) {
7474

7575
// Configure DAC
7676
obj->handle.Instance = DAC;
77+
obj->handle.State = HAL_DAC_STATE_RESET;
78+
7779
if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
7880
error("HAL_DAC_Init failed");
7981
}

targets/TARGET_STM/TARGET_STM32L1/analogout_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static int pa4_used = 0;
4040
static int pa5_used = 0;
4141

4242
void analogout_init(dac_t *obj, PinName pin) {
43-
DAC_ChannelConfTypeDef sConfig;
43+
DAC_ChannelConfTypeDef sConfig = {0};
4444

4545
// Get the peripheral name (DAC_1, ...) from the pin and assign it to the object
4646
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
@@ -68,6 +68,8 @@ void analogout_init(dac_t *obj, PinName pin) {
6868
obj->pin = pin;
6969

7070
obj->handle.Instance = DAC;
71+
obj->handle.State = HAL_DAC_STATE_RESET;
72+
7173
if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
7274
error("HAL_DAC_Init failed");
7375
}

targets/TARGET_STM/TARGET_STM32L4/analogout_device.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ void analogout_init(dac_t *obj, PinName pin) {
7575

7676
// Configure DAC
7777
obj->handle.Instance = DAC;
78+
obj->handle.State = HAL_DAC_STATE_RESET;
79+
7880
if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
7981
error("HAL_DAC_Init failed");
8082
}

0 commit comments

Comments
 (0)