[NUCLEO_L152RE] Fix issue with analog_out and -O3/Otime options

pull/172/head
bcostm 2014-02-18 10:56:16 +01:00
parent 1c2bc03f99
commit c482ad79a1
1 changed files with 12 additions and 11 deletions

View File

@ -65,14 +65,14 @@ void analogout_init(dac_t *obj, PinName pin) {
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
if (pin == PA_4) {
if (obj->channel == PA_4) {
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
DAC_Cmd(DAC_Channel_1, ENABLE);
}
else { // PA_5
DAC_Init(DAC_Channel_2, &DAC_InitStructure);
DAC_Cmd(DAC_Channel_2, ENABLE);
}
//if (obj->channel == PA_5) {
// DAC_Init(DAC_Channel_2, &DAC_InitStructure);
// DAC_Cmd(DAC_Channel_2, ENABLE);
//}
analogout_write_u16(obj, 0);
}
@ -84,18 +84,19 @@ static inline void dac_write(dac_t *obj, uint16_t value) {
if (obj->channel == PA_4) {
DAC_SetChannel1Data(DAC_Align_12b_R, value);
}
else { // PA_5
DAC_SetChannel2Data(DAC_Align_12b_R, value);
}
//if (obj->channel == PA_5) {
// DAC_SetChannel2Data(DAC_Align_12b_R, value);
//}
}
static inline int dac_read(dac_t *obj) {
if (obj->channel == PA_4) {
return (int)DAC_GetDataOutputValue(DAC_Channel_1);
}
else { // PA_5
return (int)DAC_GetDataOutputValue(DAC_Channel_2);
}
//if (obj->channel == PA_5) {
// return (int)DAC_GetDataOutputValue(DAC_Channel_2);
//}
return 0;
}
void analogout_write(dac_t *obj, float value) {