| 14 | #endif |
| 15 | |
| 16 | void _setup_gpio() { |
| 17 | |
| 18 | pinMode(UP_BTN, INPUT); // Sets the power btn as an INPUT |
| 19 | pinMode(SEL_BTN, INPUT); |
| 20 | pinMode(DW_BTN, INPUT); |
| 21 | pinMode(R_BTN, INPUT); |
| 22 | pinMode(L_BTN, INPUT); |
| 23 | |
| 24 | pinMode(CC1101_SS_PIN, OUTPUT); |
| 25 | pinMode(NRF24_SS_PIN, OUTPUT); |
| 26 | |
| 27 | digitalWrite(CC1101_SS_PIN, HIGH); |
| 28 | digitalWrite(NRF24_SS_PIN, HIGH); |
| 29 | // Starts SPI instance for CC1101 and NRF24 with CS pins blocking communication at start |
| 30 | |
| 31 | bruceConfigPins.rfModule = CC1101_SPI_MODULE; |
| 32 | bruceConfigPins.irRx = RXLED; |
| 33 | Wire.setPins(GROVE_SDA, GROVE_SCL); |
| 34 | // Wire.begin(); |
| 35 | bool pmu_ret = false; |
| 36 | Wire.begin(GROVE_SDA, GROVE_SCL); |
| 37 | pmu_ret = PPM.init(Wire, GROVE_SDA, GROVE_SCL, BQ25896_SLAVE_ADDRESS); |
| 38 | if (pmu_ret) { |
| 39 | PPM.setSysPowerDownVoltage(3300); |
| 40 | PPM.setInputCurrentLimit(3250); |
| 41 | Serial.printf("getInputCurrentLimit: %d mA\n", PPM.getInputCurrentLimit()); |
| 42 | PPM.disableCurrentLimitPin(); |
| 43 | PPM.setChargeTargetVoltage(4208); |
| 44 | PPM.setPrechargeCurr(64); |
| 45 | PPM.setChargerConstantCurr(832); |
| 46 | PPM.getChargerConstantCurr(); |
| 47 | Serial.printf("getChargerConstantCurr: %d mA\n", PPM.getChargerConstantCurr()); |
| 48 | PPM.enableMeasure(PowersBQ25896::CONTINUOUS); |
| 49 | PPM.disableOTG(); |
| 50 | PPM.enableCharge(); |
| 51 | } |
| 52 | } |
| 53 | bool isCharging() { |
| 54 | // PPM.disableBatterPowerPath(); |
| 55 | return PPM.isCharging(); |