4 #if defined(POWER_OUTPUT_DAC)
10 #define DAC_REF_VCC 3300
15 DBGLN("Init DAC Driver");
17 // I2C initialization is the responsibility of the caller
18 // e.g. Wire.begin(GPIO_PIN_SDA, GPIO_PIN_SCL);
25 if (m_state
!= STANDBY
)
27 Wire
.beginTransmission(POWER_OUTPUT_DAC
);
30 Wire
.endTransmission();
37 if (m_state
!= RUNNING
)
39 DAC::setVoltageRegDirect(m_currVoltageRegVal
);
43 void DAC::setVoltageRegDirect(uint8_t voltReg
)
45 m_currVoltageRegVal
= voltReg
;
46 uint8_t RegH
= ((voltReg
& 0b11110000) >> 4) + (0b0000 << 4);
47 uint8_t RegL
= (voltReg
& 0b00001111) << 4;
49 Wire
.beginTransmission(POWER_OUTPUT_DAC
);
52 Wire
.endTransmission();
55 void DAC::setPower(uint32_t milliVolts
)
57 uint8_t ScaledVolts
= map(milliVolts
, 0, DAC_REF_VCC
, 0, 255);
58 setVoltageRegDirect(ScaledVolts
);
59 DBGLN("DAC::setPower(%umV)", milliVolts
);
64 #endif // defined(POWER_OUTPUT_DAC)