File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -29,16 +29,16 @@ static int read_resolution = 10;
29
29
30
30
#if DEVICE_ANALOGOUT
31
31
#include " drivers/AnalogOut.h"
32
- mbed::AnalogOut* dac = NULL ;
33
- void analogWriteDAC (PinName pin, int val) {
34
- if (dac == NULL ) {
35
- dac = new mbed::AnalogOut (pin);
32
+ mbed::AnalogOut* dac[NUM_ANALOG_OUTPUTS] = { NULL } ;
33
+ void analogWriteDAC (PinName pin, int val, int idx ) {
34
+ if (dac[idx] == NULL ) {
35
+ dac[idx] = new mbed::AnalogOut (pin);
36
36
}
37
37
float percent = (float )val/(float )((1 << write_resolution)-1 );
38
38
if (percent > 1 .0f ) {
39
39
percent = 1 .0f ;
40
40
}
41
- dac->write (percent);
41
+ dac[idx] ->write (percent);
42
42
}
43
43
#endif
44
44
@@ -63,7 +63,7 @@ void analogWrite(pin_size_t pin, int val)
63
63
#ifdef DAC
64
64
for (int i=0 ; i<NUM_ANALOG_OUTPUTS; i++) {
65
65
if (digitalPinToPinName (pin) == g_AAnalogOutPinDescription[i].name ) {
66
- analogWriteDAC (digitalPinToPinName (pin), val);
66
+ analogWriteDAC (digitalPinToPinName (pin), val, i );
67
67
return ;
68
68
}
69
69
}
You can’t perform that action at this time.
0 commit comments