File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 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;
2929
3030#if DEVICE_ANALOGOUT
3131#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);
3636 }
3737 float percent = (float )val/(float )((1 << write_resolution)-1 );
3838 if (percent > 1 .0f ) {
3939 percent = 1 .0f ;
4040 }
41- dac->write (percent);
41+ dac[idx] ->write (percent);
4242}
4343#endif
4444
@@ -63,7 +63,7 @@ void analogWrite(pin_size_t pin, int val)
6363#ifdef DAC
6464 for (int i=0 ; i<NUM_ANALOG_OUTPUTS; i++) {
6565 if (digitalPinToPinName (pin) == g_AAnalogOutPinDescription[i].name ) {
66- analogWriteDAC (digitalPinToPinName (pin), val);
66+ analogWriteDAC (digitalPinToPinName (pin), val, i );
6767 return ;
6868 }
6969 }
You can’t perform that action at this time.
0 commit comments