From 5fa067e4838edfb64aa0e03c6a46c4aba9202aa8 Mon Sep 17 00:00:00 2001 From: pennam Date: Wed, 16 Oct 2024 10:56:52 +0200 Subject: [PATCH] GSM: cleanup power on sequence and add comments --- libraries/GSM/src/GSM.cpp | 28 ++++++++++++++++++++++++---- libraries/GSM/src/GSM.h | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/libraries/GSM/src/GSM.cpp b/libraries/GSM/src/GSM.cpp index 18d280747..a576801a5 100644 --- a/libraries/GSM/src/GSM.cpp +++ b/libraries/GSM/src/GSM.cpp @@ -46,10 +46,26 @@ mbed::CellularDevice *mbed::CellularDevice::get_default_instance() int arduino::GSMClass::begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat, uint32_t band, bool restart) { + /* Assume module is powered ON. Uncomment this line is you are using + * Edge Control without Arduino_ConnectionHandler + * #if defined (ARDUINO_EDGE_CONTROL) + * pinMode(ON_MKR2, OUTPUT); + * digitalWrite(ON_MKR2, HIGH); + * #endif + */ + + /* Ensure module is not under reset */ + pinMode(MBED_CONF_GEMALTO_CINTERION_RST, OUTPUT); + digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, LOW); + + /* Reset module if needed */ if (restart || isCmuxEnable()) { reset(); } + /* Create rising edge on pin ON */ + on(); + if (!_context) { _context = mbed::CellularContext::get_default_instance(); } @@ -59,9 +75,10 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern return 0; } - pinMode(MBED_CONF_GEMALTO_CINTERION_ON, INPUT_PULLDOWN); - +#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) + /* This is needed to wakeup module if hw flow control is enabled */ static mbed::DigitalOut rts(MBED_CONF_GEMALTO_CINTERION_RTS, 0); +#endif _device = _context->get_device(); _device->modem_debug_on(_at_debug); @@ -159,10 +176,15 @@ NetworkInterface* arduino::GSMClass::getNetwork() { } void arduino::GSMClass::reset() { + /* Reset logic is inverted */ pinMode(MBED_CONF_GEMALTO_CINTERION_RST, OUTPUT); digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, HIGH); delay(800); digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, LOW); +} + +void arduino::GSMClass::on() { + /* Module needs a rising edge to power on */ pinMode(MBED_CONF_GEMALTO_CINTERION_ON, OUTPUT); digitalWrite(MBED_CONF_GEMALTO_CINTERION_ON, LOW); delay(1); @@ -171,6 +193,4 @@ void arduino::GSMClass::reset() { } - - arduino::GSMClass GSM; diff --git a/libraries/GSM/src/GSM.h b/libraries/GSM/src/GSM.h index fac09e4ea..0d815e120 100644 --- a/libraries/GSM/src/GSM.h +++ b/libraries/GSM/src/GSM.h @@ -158,6 +158,7 @@ class GSMClass : public MbedSocketClass { void onStatusChange(nsapi_event_t ev, intptr_t in); void reset(); + void on(); }; }