** Function name: _setup_gpio() ** Location: main.cpp ** Description: initial setup for the device ***************************************************************************************/
| 7 | ** Description: initial setup for the device |
| 8 | ***************************************************************************************/ |
| 9 | void _setup_gpio() { |
| 10 | pinMode(UP_BTN, INPUT); // Sets the power btn as an INPUT |
| 11 | pinMode(SEL_BTN, INPUT); |
| 12 | pinMode(DW_BTN, INPUT); |
| 13 | pinMode(4, OUTPUT); // Keeps the Stick alive after take off the USB cable |
| 14 | digitalWrite(4, HIGH); // Keeps the Stick alive after take off the USB cable |
| 15 | gpio_pulldown_dis(GPIO_NUM_36); |
| 16 | gpio_pullup_dis(GPIO_NUM_36); |
| 17 | pinMode(32, OUTPUT); |
| 18 | pinMode(33, OUTPUT); |
| 19 | digitalWrite(32, LOW); |
| 20 | digitalWrite(33, HIGH); |
| 21 | //========================================================================= |
| 22 | // Issue: During startup, the SD card might keep the MISO line at a high level continuously, causing RF |
| 23 | // initialization to fail. Solution:Forcing switch to SD card and sending dummy clocks |
| 24 | //========================================================================= |
| 25 | int pin_shared_ctrl = 33; // Controls CS: HIGH=SD_Select, LOW=RF_Select |
| 26 | int pin_sck = 0; // SCK Pin for M5StickC Plus 2 |
| 27 | pinMode(pin_shared_ctrl, OUTPUT); |
| 28 | pinMode(pin_sck, OUTPUT); |
| 29 | digitalWrite(pin_shared_ctrl, HIGH); // Force Select SD Card |
| 30 | delay(10); |
| 31 | for (int i = 0; i < 80; i++) { |
| 32 | digitalWrite(pin_sck, HIGH); |
| 33 | delayMicroseconds(10); |
| 34 | digitalWrite(pin_sck, LOW); |
| 35 | delayMicroseconds(10); |
| 36 | } // send dummy clocks |
| 37 | digitalWrite(pin_shared_ctrl, HIGH); // Keep the SD card selected. |
| 38 | } |
| 39 | |
| 40 | /********************************************************************* |
| 41 | ** Function: setBrightness |
nothing calls this directly
no outgoing calls
no test coverage detected