Skip to content

Commit c41f1c7

Browse files
committed
[Wio 3G] Fix onboard modem initialization
Fix for issue #9450 by adding turning off the modem power at startup, so that modem is sure to be in the initial state. Fix for wrong filename and classname. // WIP
1 parent 1892e2d commit c41f1c7

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_BG96.cpp renamed to targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_UG96.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,37 @@
1616

1717
#if MBED_CONF_NSAPI_PRESENT
1818

19-
#include "ONBOARD_QUECTEL_BG96.h"
19+
#include "ONBOARD_QUECTEL_UG96.h"
2020

2121
#include "cellular/onboard_modem_api.h"
2222
#include "UARTSerial.h"
2323

2424
using namespace mbed;
2525

26-
ONBOARD_QUECTEL_BG96::ONBOARD_QUECTEL_BG96(FileHandle *fh) : QUECTEL_BG96(fh)
26+
ONBOARD_QUECTEL_UG96::ONBOARD_QUECTEL_UG96(FileHandle *fh) : QUECTEL_UG96(fh)
2727
{
28+
::onboard_modem_init();
2829
}
2930

30-
nsapi_error_t ONBOARD_QUECTEL_BG96::hard_power_on()
31+
nsapi_error_t ONBOARD_QUECTEL_UG96::hard_power_on()
3132
{
3233
::onboard_modem_init();
3334
return NSAPI_ERROR_OK;
3435
}
3536

36-
nsapi_error_t ONBOARD_QUECTEL_BG96::hard_power_off()
37+
nsapi_error_t ONBOARD_QUECTEL_UG96::hard_power_off()
3738
{
3839
::onboard_modem_deinit();
3940
return NSAPI_ERROR_OK;
4041
}
4142

42-
nsapi_error_t ONBOARD_QUECTEL_BG96::soft_power_on()
43+
nsapi_error_t ONBOARD_QUECTEL_UG96::soft_power_on()
4344
{
4445
::onboard_modem_power_up();
4546
return NSAPI_ERROR_OK;
4647
}
4748

48-
nsapi_error_t ONBOARD_QUECTEL_BG96::soft_power_off()
49+
nsapi_error_t ONBOARD_QUECTEL_UG96::soft_power_off()
4950
{
5051
::onboard_modem_power_down();
5152
return NSAPI_ERROR_OK;
@@ -54,7 +55,7 @@ nsapi_error_t ONBOARD_QUECTEL_BG96::soft_power_off()
5455
CellularDevice *CellularDevice::get_target_default_instance()
5556
{
5657
static UARTSerial serial(MDMTXD, MDMRXD, 115200);
57-
static ONBOARD_QUECTEL_BG96 device(&serial);
58+
static ONBOARD_QUECTEL_UG96 device(&serial);
5859
return &device;
5960
}
6061

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_BG96.h renamed to targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_UG96.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef ONBOARD_QUECTEL_BG96_
18-
#define ONBOARD_QUECTEL_BG96_
17+
#ifndef ONBOARD_QUECTEL_UG96_
18+
#define ONBOARD_QUECTEL_UG96_
1919

20-
#include "QUECTEL_BG96.h"
20+
#include "QUECTEL_UG96.h"
2121

2222
namespace mbed {
2323

24-
class ONBOARD_QUECTEL_BG96 : public QUECTEL_BG96 {
24+
class ONBOARD_QUECTEL_UG96 : public QUECTEL_UG96 {
2525
public:
26-
ONBOARD_QUECTEL_BG96(FileHandle *fh);
26+
ONBOARD_QUECTEL_UG96(FileHandle *fh);
2727

2828
virtual nsapi_error_t hard_power_on();
2929
virtual nsapi_error_t hard_power_off();
@@ -33,4 +33,4 @@ class ONBOARD_QUECTEL_BG96 : public QUECTEL_BG96 {
3333

3434
} // namespace mbed
3535

36-
#endif // ONBOARD_QUECTEL_BG96_
36+
#endif // ONBOARD_QUECTEL_UG96_
Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2017 ARM Limited
2+
* Copyright (c) 2017 Arm Limited
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
35
*
46
* Licensed under the Apache License, Version 2.0 (the "License");
57
* you may not use this file except in compliance with the License.
@@ -21,50 +23,66 @@
2123
#include "platform/mbed_wait_api.h"
2224
#include "PinNames.h"
2325

26+
#define WAIT_AFTER_POWR_CHANGED (1000) // [msec.]
27+
2428
#if MODEM_ON_BOARD
2529

2630
static void press_power_button(int time_ms)
2731
{
2832
gpio_t gpio;
2933

3034
gpio_init_out_ex(&gpio, PWRKEY, 1);
31-
gpio_write(&gpio, 1);
3235
wait_ms(time_ms);
3336
gpio_write(&gpio, 0);
3437
}
3538

3639
void onboard_modem_init()
3740
{
3841
gpio_t gpio;
39-
// start with modem disabled
42+
43+
// Power Supply
44+
gpio_init_out_ex(&gpio, M_POWR, 0);
45+
// Turn On/Off
46+
gpio_init_out_ex(&gpio, PWRKEY, 0);
4047
gpio_init_out_ex(&gpio, RESET_MODULE, 0);
48+
// Status Indication
4149
gpio_init_in_ex(&gpio, MDMSTAT, PullUp);
42-
gpio_init_out_ex(&gpio, MDMDTR, 0);
43-
gpio_init_out_ex(&gpio, M_POWR, 1);
50+
// Main UART Interface
51+
gpio_init_out_ex(&gpio, MDMDTR, 0);
4452

45-
// gpio_write(&gpio, M_POWR, 1);
46-
wait_ms(500);
53+
wait_ms(WAIT_AFTER_POWR_CHANGED);
4754
}
4855

4956
void onboard_modem_deinit()
5057
{
51-
// wio3g_mdm_powerOff();
58+
gpio_t gpio;
59+
60+
// Power supply OFF
61+
gpio_init_out_ex(&gpio, M_POWR, 0);
62+
wait_ms(WAIT_AFTER_POWR_CHANGED);
5263
}
5364

5465
void onboard_modem_power_up()
5566
{
56-
/* keep the power line HIGH for 200 milisecond */
57-
press_power_button(200);
58-
/* give modem a little time to respond */
67+
gpio_t gpio;
68+
69+
// Power supply ON
70+
gpio_init_out_ex(&gpio, M_POWR, 1);
71+
wait_ms(WAIT_AFTER_POWR_CHANGED);
72+
73+
// Turn on
5974
wait_ms(100);
75+
press_power_button(200);
6076
}
6177

6278
void onboard_modem_power_down()
6379
{
64-
/* keep the power line low for 1 second */
65-
// press_power_button(1000);
80+
gpio_t gpio;
6681

67-
// gpio_write(&mpowr, M_POWR, 0);
82+
// Power supply OFF
83+
gpio_init_out_ex(&gpio, M_POWR, 0);
84+
wait_ms(WAIT_AFTER_POWR_CHANGED);
6885
}
6986
#endif //MODEM_ON_BOARD
87+
7088
#endif //MBED_CONF_NSAPI_PRESENT

0 commit comments

Comments
 (0)