Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWRKEY pin #43

Open
blomnik opened this issue Nov 12, 2020 · 2 comments
Open

PWRKEY pin #43

blomnik opened this issue Nov 12, 2020 · 2 comments

Comments

@blomnik
Copy link
Contributor

blomnik commented Nov 12, 2020

Hello!
I have a custom PCB with PWRKEY pin instead of RST. Is it possible utilize it on init with lwGSM or I have to implement some additional code by myself?

Thank you.

@nickfaughey
Copy link

You can implement whatever custom bootup logic you want in your lwgsm_ll_init() function. For example, this is where I wake up my SIM7000 module from sleep mode by pulling its DTR pin low. If you have a board that requires some use of the PWRKEY pin like pulsing it high or low for some time, you could do it here.

@blomnik
Copy link
Contributor Author

blomnik commented Jan 24, 2021

So, my workaround is

/**
 * This function try to init GSM modem and power it on by PWRKEY if init was failed
 */
int gsm_reset(void) {
  if(lwgsm_init(NULL, 1) == lwgsmOK) {
    return 0;
  }

  for (int i = 0; i < 3; ++i) {
    int err;
    LL_GPIO_ResetOutputPin(GSM_PWRKEY_port, GSM_PWRKEY_pin);
    osDelay(1500); // according to 4.2.2.1 of "SIM800 hardware design"
    LL_GPIO_SetOutputPin(GSM_PWRKEY_port, GSM_PWRKEY_pin);
    osDelay(1500);

    err = lwgsm_reset_with_delay(LWGSM_CFG_RESET_DELAY_DEFAULT, NULL, NULL, 1);
    if(err != lwgsmOK) {
      printf("lwGSM error %d", err);
    } else {
      return 0;
    }
  }

  errno = ENODEV;
  return -1;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants