Skip to content

Commit c482ad7

Browse files
committed
[NUCLEO_L152RE] Fix issue with analog_out and -O3/Otime options
1 parent 1c2bc03 commit c482ad7

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_L152RE/analogout_api.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ void analogout_init(dac_t *obj, PinName pin) {
6565
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
6666
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
6767

68-
if (pin == PA_4) {
68+
if (obj->channel == PA_4) {
6969
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
7070
DAC_Cmd(DAC_Channel_1, ENABLE);
7171
}
72-
else { // PA_5
73-
DAC_Init(DAC_Channel_2, &DAC_InitStructure);
74-
DAC_Cmd(DAC_Channel_2, ENABLE);
75-
}
72+
//if (obj->channel == PA_5) {
73+
// DAC_Init(DAC_Channel_2, &DAC_InitStructure);
74+
// DAC_Cmd(DAC_Channel_2, ENABLE);
75+
//}
7676

7777
analogout_write_u16(obj, 0);
7878
}
@@ -84,18 +84,19 @@ static inline void dac_write(dac_t *obj, uint16_t value) {
8484
if (obj->channel == PA_4) {
8585
DAC_SetChannel1Data(DAC_Align_12b_R, value);
8686
}
87-
else { // PA_5
88-
DAC_SetChannel2Data(DAC_Align_12b_R, value);
89-
}
87+
//if (obj->channel == PA_5) {
88+
// DAC_SetChannel2Data(DAC_Align_12b_R, value);
89+
//}
9090
}
9191

9292
static inline int dac_read(dac_t *obj) {
9393
if (obj->channel == PA_4) {
9494
return (int)DAC_GetDataOutputValue(DAC_Channel_1);
9595
}
96-
else { // PA_5
97-
return (int)DAC_GetDataOutputValue(DAC_Channel_2);
98-
}
96+
//if (obj->channel == PA_5) {
97+
// return (int)DAC_GetDataOutputValue(DAC_Channel_2);
98+
//}
99+
return 0;
99100
}
100101

101102
void analogout_write(dac_t *obj, float value) {

0 commit comments

Comments
 (0)