Skip to content

Commit 205acd7

Browse files
committed
adds modemEmergencyHardReset() for R510
1 parent 62bdfa5 commit 205acd7

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

hal/network/ncp_client/sara/sara_ncp_client.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ int SaraNcpClient::waitReady(bool powerOn) {
10041004
return SYSTEM_ERROR_NONE;
10051005
}
10061006

1007+
static int waitReadyRetries = 0;
10071008
ModemState modemState = ModemState::Unknown;
10081009

10091010
// Just in case make sure that the voltage translator is on
@@ -1048,6 +1049,7 @@ int SaraNcpClient::waitReady(bool powerOn) {
10481049
skipAll(serial_.get());
10491050
parser_.reset();
10501051
parserError_ = 0;
1052+
waitReadyRetries = 0;
10511053
LOG(TRACE, "NCP ready to accept AT commands");
10521054

10531055
auto r = initReady(modemState);
@@ -1065,6 +1067,10 @@ int SaraNcpClient::waitReady(bool powerOn) {
10651067
// Hard reset the modem
10661068
modemHardReset(true);
10671069
ncpState(NcpState::OFF);
1070+
if (++waitReadyRetries >= 10) {
1071+
waitReadyRetries = 10;
1072+
modemEmergencyHardReset();
1073+
}
10681074

10691075
return SYSTEM_ERROR_INVALID_STATE;
10701076
}
@@ -2548,6 +2554,35 @@ int SaraNcpClient::modemHardReset(bool powerOff) {
25482554
return SYSTEM_ERROR_NONE;
25492555
}
25502556

2557+
int SaraNcpClient::modemEmergencyHardReset() {
2558+
if (ncpId() != PLATFORM_NCP_SARA_R510) {
2559+
return SYSTEM_ERROR_NONE;
2560+
}
2561+
2562+
LOG(TRACE, "Emergency hardware shutdown the modem");
2563+
const auto pwrState = modemPowerState();
2564+
// We can only reset the modem in the powered state
2565+
if (!pwrState) {
2566+
LOG(ERROR, "Modem is not powered on!");
2567+
return SYSTEM_ERROR_INVALID_STATE;
2568+
}
2569+
2570+
// Low held on power pin
2571+
HAL_GPIO_Write(UBPWR, 0);
2572+
HAL_Delay_Milliseconds(500);
2573+
// Low held on reset pin
2574+
HAL_GPIO_Write(UBRST, 0);
2575+
// Release power pin after 23s (23.5)
2576+
HAL_Delay_Milliseconds(23000);
2577+
HAL_GPIO_Write(UBPWR, 1);
2578+
// Release reset pin after 1.5s (2s)
2579+
HAL_Delay_Milliseconds(2000);
2580+
HAL_GPIO_Write(UBRST, 1);
2581+
2582+
ncpPowerState(NcpPowerState::TRANSIENT_ON);
2583+
return SYSTEM_ERROR_NONE;
2584+
}
2585+
25512586
bool SaraNcpClient::modemPowerState() const {
25522587
return HAL_GPIO_Read(UBVINT);
25532588
}

hal/network/ncp_client/sara/sara_ncp_client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class SaraNcpClient: public CellularNcpClient {
159159
int modemPowerOff();
160160
int modemSoftPowerOff();
161161
int modemHardReset(bool powerOff = false);
162+
int modemEmergencyHardReset();
162163
bool modemPowerState() const;
163164
int modemSetUartState(bool state) const;
164165
void waitForPowerOff();

0 commit comments

Comments
 (0)