| 257 | } |
| 258 | |
| 259 | std::shared_ptr<PowerDevice> createPower() { |
| 260 | ChargeFromAdcVoltage::Configuration config = { |
| 261 | .adcMultiplier = VOLTAGE_DIVIDER_MULTIPLIER, |
| 262 | .adcRefVoltage = 3.3f, |
| 263 | .adcChannel = VBAT_ADC_CHANNEL, |
| 264 | .adcConfig = { |
| 265 | .unit_id = ADC_UNIT_1, |
| 266 | .clk_src = ADC_RTC_CLK_SRC_DEFAULT, |
| 267 | .ulp_mode = ADC_ULP_MODE_DISABLE, |
| 268 | }, |
| 269 | .adcChannelConfig = { |
| 270 | .atten = ADC_ATTEN_DB_12, |
| 271 | .bitwidth = ADC_BITWIDTH_DEFAULT, |
| 272 | }, |
| 273 | }; |
| 274 | |
| 275 | auto adc = std::make_unique<ChargeFromAdcVoltage>(config, MIN_BATTERY_VOLTAGE, MAX_BATTERY_VOLTAGE); |
| 276 | if (!adc->isInitialized()) { |
| 277 | LOG_E(TAG, "ADC initialization failed; power monitoring unavailable"); |
| 278 | return nullptr; |
| 279 | } |
| 280 | |
| 281 | return std::make_shared<PaperS3Power>(std::move(adc), POWER_OFF_PIN); |
| 282 | } |
no test coverage detected