Skip to content

STM32: Fix analogout structure/variable wrong initialization #5263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F0/analogout_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "PeripheralPins.h"

void analogout_init(dac_t *obj, PinName pin) {
DAC_ChannelConfTypeDef sConfig;
DAC_ChannelConfTypeDef sConfig = {0};

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

// Configure DAC
obj->handle.Instance = (DAC_TypeDef *)(obj->dac);
obj->handle.State = HAL_DAC_STATE_RESET;

if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
error("HAL_DAC_Init failed");
}
Expand Down
4 changes: 3 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F3/analogout_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int pa4_used = 0;
static int pa5_used = 0;

void analogout_init(dac_t *obj, PinName pin) {
DAC_ChannelConfTypeDef sConfig;
DAC_ChannelConfTypeDef sConfig = {0};

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

// Configure DAC
obj->handle.Instance = (DAC_TypeDef *)(obj->dac);
obj->handle.State = HAL_DAC_STATE_RESET;

if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
error("HAL_DAC_Init failed");
}
Expand Down
4 changes: 3 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F4/analogout_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "PeripheralPins.h"

void analogout_init(dac_t *obj, PinName pin) {
DAC_ChannelConfTypeDef sConfig;
DAC_ChannelConfTypeDef sConfig = {0};

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

obj->handle.Instance = DAC;
obj->handle.State = HAL_DAC_STATE_RESET;

if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
error("HAL_DAC_Init failed");
}
Expand Down
4 changes: 3 additions & 1 deletion targets/TARGET_STM/TARGET_STM32F7/analogout_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "PeripheralPins.h"

void analogout_init(dac_t *obj, PinName pin) {
DAC_ChannelConfTypeDef sConfig;
DAC_ChannelConfTypeDef sConfig = {0};

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

obj->handle.Instance = DAC;
obj->handle.State = HAL_DAC_STATE_RESET;

if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
error("HAL_DAC_Init failed");
}
Expand Down
4 changes: 3 additions & 1 deletion targets/TARGET_STM/TARGET_STM32L0/analogout_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int channel1_used = 0;
static int channel2_used = 0;

void analogout_init(dac_t *obj, PinName pin) {
DAC_ChannelConfTypeDef sConfig;
DAC_ChannelConfTypeDef sConfig = {0};

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

// Configure DAC
obj->handle.Instance = DAC;
obj->handle.State = HAL_DAC_STATE_RESET;

if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
error("HAL_DAC_Init failed");
}
Expand Down
4 changes: 3 additions & 1 deletion targets/TARGET_STM/TARGET_STM32L1/analogout_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static int pa4_used = 0;
static int pa5_used = 0;

void analogout_init(dac_t *obj, PinName pin) {
DAC_ChannelConfTypeDef sConfig;
DAC_ChannelConfTypeDef sConfig = {0};

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

obj->handle.Instance = DAC;
obj->handle.State = HAL_DAC_STATE_RESET;

if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
error("HAL_DAC_Init failed");
}
Expand Down
2 changes: 2 additions & 0 deletions targets/TARGET_STM/TARGET_STM32L4/analogout_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ void analogout_init(dac_t *obj, PinName pin) {

// Configure DAC
obj->handle.Instance = DAC;
obj->handle.State = HAL_DAC_STATE_RESET;

if (HAL_DAC_Init(&obj->handle) != HAL_OK ) {
error("HAL_DAC_Init failed");
}
Expand Down