Skip to content

Commit 3f46c82

Browse files
authored
Merge pull request #9555 from SeeedJP/hal-wio_bg96-9450
Wio BG96: Modified sequence of module startup
2 parents ad2cb91 + 89bb25e commit 3f46c82

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_BG96/ONBOARD_QUECTEL_BG96.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ using namespace mbed;
2525

2626
ONBOARD_QUECTEL_BG96::ONBOARD_QUECTEL_BG96(FileHandle *fh) : QUECTEL_BG96(fh)
2727
{
28+
::onboard_modem_init();
2829
}
2930

3031
nsapi_error_t ONBOARD_QUECTEL_BG96::hard_power_on()

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_BG96/onboard_modem_api.c

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018 Arm Limited
2+
* Copyright (c) 2017 Arm Limited
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -23,50 +23,62 @@
2323
#include "platform/mbed_wait_api.h"
2424
#include "PinNames.h"
2525

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

2830
static void press_power_button(int time_ms)
2931
{
3032
gpio_t gpio;
3133

3234
gpio_init_out_ex(&gpio, PWRKEY, 1);
33-
gpio_write(&gpio, 1);
3435
wait_ms(time_ms);
3536
gpio_write(&gpio, 0);
3637
}
3738

3839
void onboard_modem_init()
3940
{
4041
gpio_t gpio;
41-
// 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);
4247
gpio_init_out_ex(&gpio, RESET_MODULE, 0);
48+
// Status Indication
4349
gpio_init_in_ex(&gpio, MDMSTAT, PullUp);
44-
gpio_init_out_ex(&gpio, MDMDTR, 0);
45-
gpio_init_out_ex(&gpio, M_POWR, 1);
50+
// Main UART Interface
51+
gpio_init_out_ex(&gpio, MDMDTR, 0);
4652

47-
// gpio_write(&gpio, M_POWR, 1);
48-
wait_ms(500);
53+
wait_ms(WAIT_AFTER_POWR_CHANGED);
4954
}
5055

5156
void onboard_modem_deinit()
5257
{
53-
// wio3g_mdm_powerOff();
58+
onboard_modem_power_down();
5459
}
5560

5661
void onboard_modem_power_up()
5762
{
58-
/* keep the power line HIGH for 200 milisecond */
59-
press_power_button(200);
60-
/* give modem a little time to respond */
61-
wait_ms(100);
63+
gpio_t gpio;
64+
65+
// Power supply ON
66+
gpio_init_out_ex(&gpio, M_POWR, 1);
67+
wait_ms(WAIT_AFTER_POWR_CHANGED);
68+
69+
// Turn on
70+
wait_ms(100);
71+
press_power_button(200);
6272
}
6373

6474
void onboard_modem_power_down()
6575
{
66-
/* keep the power line low for 1 second */
67-
// press_power_button(1000);
76+
gpio_t gpio;
6877

69-
// gpio_write(&mpowr, M_POWR, 0);
78+
// Power supply OFF
79+
gpio_init_out_ex(&gpio, M_POWR, 0);
80+
wait_ms(WAIT_AFTER_POWR_CHANGED);
7081
}
7182
#endif //MODEM_ON_BOARD
83+
7284
#endif //MBED_CONF_NSAPI_PRESENT

0 commit comments

Comments
 (0)