api to get pump duty

This commit is contained in:
Matthew Kennedy 2020-12-15 14:58:39 -08:00
parent 2d5d6a0026
commit fb66c03ac7
4 changed files with 15 additions and 0 deletions

View File

@ -36,3 +36,8 @@ void SetPumpCurrentTarget(int32_t microampere)
pumpDac.SetDuty(volts / VCC_VOLTS);
}
uint16_t GetPumpOutputDuty()
{
return pumpDac.GetLastDuty();
}

View File

@ -4,3 +4,4 @@
void InitPumpDac();
void SetPumpCurrentTarget(int32_t microamperes);
uint16_t GetPumpOutputDuty();

View File

@ -45,5 +45,12 @@ float clampF(float min, float clamp, float max) {
void Pwm::SetDuty(float duty) {
pwmcnt_t highTime = m_counterPeriod * clampF(0, duty, 1);
m_lastDuty = highTime;
pwm_lld_enable_channel(m_driver, m_channel, highTime);
}
uint16_t Pwm::GetLastDuty() const
{
return m_lastDuty;
}

View File

@ -11,9 +11,11 @@ public:
void Start();
void SetDuty(float duty);
uint16_t GetLastDuty() const;
private:
PWMDriver* const m_driver;
const uint8_t m_channel;
const uint32_t m_counterFrequency;
const uint16_t m_counterPeriod;
uint16_t m_lastDuty;
};