static void press_power_button(int time_ms) { gpio_t gpio; gpio_init_out_ex(&gpio, MDMPWRON, 1); gpio_write(&gpio, 0); wait_ms(time_ms); gpio_write(&gpio, 1); }
void onboard_modem_power_down() { gpio_t gpio; gpio_init_out_ex(&gpio, MDMPWRON, 0); /* keep the power line low for more than 10 seconds. * If 3G_ON_OFF pin is kept low for more than a second, a controlled disconnect and shutdown takes * place, Due to the network disconnect, shut-off can take up to 30 seconds. However, we wait for 10 * seconds only */ wait_ms(10 * 1000); }
// called before main void mbed_sdk_init() { gpio_t modemEn, modemRst, modemPwrOn, modemLvlOe, modemILvlOe, modemUsbDet; gpio_t gpsEn, gpsRst, led, modemRts; // start with modem disabled gpio_init_out_ex(&modemEn, MDMEN, 0); gpio_init_out_ex(&modemRst, MDMRST, 1); gpio_init_out_ex(&modemPwrOn, MDMPWRON, 1); gpio_init_out_ex(&modemLvlOe, MDMLVLOE, 1); gpio_init_out_ex(&modemILvlOe, MDMILVLOE, 0); gpio_init_out_ex(&modemUsbDet, MDMUSBDET, 0); gpio_init_out_ex(&modemRts, MDMRTS, 0); // start with gps disabled gpio_init_out_ex(&gpsEn, GPSEN, 0); gpio_init_out_ex(&gpsRst, GPSRST, 1); // led should be off gpio_init_out_ex(&led, LED, 0); wait_ms(50); // when USB cable is inserted the interface chip issues // multiple resets to the target CPU We wait here for a short period to // prevent those resets from propagating to the modem and other // components. }
void ublox_board_init(void) { gpio_t gpio; // Enable power to 3V3 gpio_init_inout(&gpio, PWR3V3, PIN_OUTPUT, OpenDrain, 1); // start with modem disabled gpio_init_out_ex(&gpio, MDMRST, 0); gpio_init_out_ex(&gpio, MDMPWRON, 0); gpio_init_out_ex(&gpio, MDMRTS, 0); gpio_init_in_ex(&gpio, MDMCURRENTSENSE, PullNone); // start with GNSS disabled gpio_init_inout(&gpio, GNSSEN, PIN_OUTPUT, PushPullNoPull, 0); // power on SD card gpio_init_out_ex(&gpio, SDPWRON, 1); // led should be off gpio_init_out_ex(&gpio, LED1, 1); gpio_init_out_ex(&gpio, LED2, 1); gpio_init_out_ex(&gpio, LED3, 1); gpio_init_out_ex(&gpio, LED4, 1); }
void gpio_init_out(gpio_t* gpio, PinName pin) { gpio_init_out_ex(gpio, pin, 0); }