diff --git a/ion/src/device/battery.cpp b/ion/src/device/battery.cpp index 72e16ac6f..1a84f7242 100644 --- a/ion/src/device/battery.cpp +++ b/ion/src/device/battery.cpp @@ -10,10 +10,10 @@ bool isCharging() { } float voltage() { - ADC1.CR2()->setSWSTART(true); - while (ADC1.SR()->getEOC() != true) { + ADC.CR2()->setSWSTART(true); + while (ADC.SR()->getEOC() != true) { } - uint16_t value = ADC1.DR()->get(); + uint16_t value = ADC.DR()->get(); // The ADC is 12 bits by default return Device::ADCDividerBridgeRatio*(Device::ADCReferenceVoltage * value)/0xFFF; @@ -41,12 +41,12 @@ void initGPIO() { ChargingGPIO.PUPDR()->setPull(ChargingPin, GPIO::PUPDR::Pull::Up); /* The BAT_SNS pin is connected to Vbat through a divider bridge. It therefore - * has a voltage of Vbat/2. We'll measure this using ADC1 channel 0. */ + * has a voltage of Vbat/2. We'll measure this using ADC channel 0. */ ADCGPIO.MODER()->setMode(ADCPin, GPIO::MODER::Mode::Analog); } void initADC() { - ADC1.CR2()->setADON(true); + ADC.CR2()->setADON(true); } } diff --git a/ion/src/device/regs/adc.h b/ion/src/device/regs/adc.h index 4d8db1b2f..1c79145d4 100644 --- a/ion/src/device/regs/adc.h +++ b/ion/src/device/regs/adc.h @@ -46,7 +46,7 @@ public: class DR : public Register16 { }; - constexpr ADC(int i) : m_index(i) {} + constexpr ADC() {}; REGS_REGISTER_AT(SR, 0x0); REGS_REGISTER_AT(CR2, 0x08); REGS_REGISTER_AT(DR, 0x4C); @@ -54,9 +54,8 @@ private: constexpr uint32_t Base() const { return 0x40012000; }; - int m_index; }; -constexpr ADC ADC1(1); +constexpr ADC ADC; #endif