MCPcopy Create free account
hub / github.com/BruceDevices/firmware / _setup_gpio

Function _setup_gpio

boards/reaper/interface.cpp:25–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23BQ27220 bq;
24
25void _setup_gpio() {
26
27 pinMode(UP_BTN, INPUT); // Sets the power btn as an INPUT
28 pinMode(SEL_BTN, INPUT);
29 pinMode(DW_BTN, INPUT);
30 pinMode(R_BTN, INPUT);
31 pinMode(L_BTN, INPUT);
32 pinMode(ESC_BTN, INPUT);
33
34 pinMode(CC1101_SS_PIN, OUTPUT);
35 pinMode(NRF24_SS_PIN, OUTPUT);
36 pinMode(SS, OUTPUT); /// NFC PIN
37 digitalWrite(CC1101_SS_PIN, HIGH);
38 digitalWrite(NRF24_SS_PIN, HIGH);
39 digitalWrite(SS, HIGH);
40
41 // Starts SPI instance for CC1101 and NRF24 with CS pins blocking communication at start
42
43 pinMode(TFT_CS, OUTPUT);
44 digitalWrite(TFT_CS, HIGH);
45 pinMode(SDCARD_CS, OUTPUT);
46 digitalWrite(SDCARD_CS, HIGH);
47
48 Wire.setPins(GROVE_SDA, GROVE_SCL);
49 // Wire.begin();
50 // bruceConfig.rfModule = CC1101_SPI_MODULE;
51 // bruceConfig.irRx = RXLED;
52 // bruceConfig.irTx = LED;
53 Wire.begin(GROVE_SDA, GROVE_SCL);
54
55
56 bool pmu_ret = false;
57 pmu_ret = PPM.init(Wire, GROVE_SDA, GROVE_SCL, BQ25896_SLAVE_ADDRESS);
58 if (pmu_ret) {
59
60 PPM.setSysPowerDownVoltage(3300);
61 PPM.setInputCurrentLimit(2000);
62 Serial.printf("getInputCurrentLimit: %d mA\n", PPM.getInputCurrentLimit());
63 PPM.disableCurrentLimitPin();
64 PPM.setChargeTargetVoltage(4208);
65 PPM.setPrechargeCurr(64);
66 PPM.setChargerConstantCurr(832);
67 PPM.getChargerConstantCurr();
68 Serial.printf("getChargerConstantCurr: %d mA\n", PPM.getChargerConstantCurr());
69 PPM.enableMeasure(PowersBQ25896::CONTINUOUS);
70
71 PPM.disableOTG();
72 // PPM.enableInputDetection();
73 PPM.enableCharge();
74 }
75 if (bq.getDesignCap() != BATTERY_DESIGN_CAPACITY) { bq.setDesignCap(BATTERY_DESIGN_CAPACITY); }
76}
77
78/***************************************************************************************
79** Function name: getBattery()

Callers

nothing calls this directly

Calls 6

setPinsMethod · 0.80
getDesignCapMethod · 0.80
setDesignCapMethod · 0.80
beginMethod · 0.45
initMethod · 0.45
printfMethod · 0.45

Tested by

no test coverage detected