Merge pull request #9555 from SeeedJP/hal-wio_bg96-9450

Wio BG96: Modified sequence of module startup
pull/9774/head
Martin Kojtal 2019-02-20 09:36:00 +01:00 committed by GitHub
commit 3f46c82136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 17 deletions

View File

@ -25,6 +25,7 @@ using namespace mbed;
ONBOARD_QUECTEL_BG96::ONBOARD_QUECTEL_BG96(FileHandle *fh) : QUECTEL_BG96(fh) ONBOARD_QUECTEL_BG96::ONBOARD_QUECTEL_BG96(FileHandle *fh) : QUECTEL_BG96(fh)
{ {
::onboard_modem_init();
} }
nsapi_error_t ONBOARD_QUECTEL_BG96::hard_power_on() nsapi_error_t ONBOARD_QUECTEL_BG96::hard_power_on()

View File

@ -1,5 +1,5 @@
/* mbed Microcontroller Library /* mbed Microcontroller Library
* Copyright (c) 2018 Arm Limited * Copyright (c) 2017 Arm Limited
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
* *
@ -23,6 +23,8 @@
#include "platform/mbed_wait_api.h" #include "platform/mbed_wait_api.h"
#include "PinNames.h" #include "PinNames.h"
#define WAIT_AFTER_POWR_CHANGED (1000) // [msec.]
#if MODEM_ON_BOARD #if MODEM_ON_BOARD
static void press_power_button(int time_ms) static void press_power_button(int time_ms)
@ -30,7 +32,6 @@ static void press_power_button(int time_ms)
gpio_t gpio; gpio_t gpio;
gpio_init_out_ex(&gpio, PWRKEY, 1); gpio_init_out_ex(&gpio, PWRKEY, 1);
gpio_write(&gpio, 1);
wait_ms(time_ms); wait_ms(time_ms);
gpio_write(&gpio, 0); gpio_write(&gpio, 0);
} }
@ -38,35 +39,46 @@ static void press_power_button(int time_ms)
void onboard_modem_init() void onboard_modem_init()
{ {
gpio_t gpio; gpio_t gpio;
// start with modem disabled
gpio_init_out_ex(&gpio, RESET_MODULE, 0);
gpio_init_in_ex(&gpio, MDMSTAT, PullUp);
gpio_init_out_ex(&gpio, MDMDTR, 0);
gpio_init_out_ex(&gpio, M_POWR, 1);
// gpio_write(&gpio, M_POWR, 1); // Power Supply
wait_ms(500); gpio_init_out_ex(&gpio, M_POWR, 0);
// Turn On/Off
gpio_init_out_ex(&gpio, PWRKEY, 0);
gpio_init_out_ex(&gpio, RESET_MODULE, 0);
// Status Indication
gpio_init_in_ex(&gpio, MDMSTAT, PullUp);
// Main UART Interface
gpio_init_out_ex(&gpio, MDMDTR, 0);
wait_ms(WAIT_AFTER_POWR_CHANGED);
} }
void onboard_modem_deinit() void onboard_modem_deinit()
{ {
// wio3g_mdm_powerOff(); onboard_modem_power_down();
} }
void onboard_modem_power_up() void onboard_modem_power_up()
{ {
/* keep the power line HIGH for 200 milisecond */ gpio_t gpio;
press_power_button(200);
/* give modem a little time to respond */ // Power supply ON
wait_ms(100); gpio_init_out_ex(&gpio, M_POWR, 1);
wait_ms(WAIT_AFTER_POWR_CHANGED);
// Turn on
wait_ms(100);
press_power_button(200);
} }
void onboard_modem_power_down() void onboard_modem_power_down()
{ {
/* keep the power line low for 1 second */ gpio_t gpio;
// press_power_button(1000);
// gpio_write(&mpowr, M_POWR, 0); // Power supply OFF
gpio_init_out_ex(&gpio, M_POWR, 0);
wait_ms(WAIT_AFTER_POWR_CHANGED);
} }
#endif //MODEM_ON_BOARD #endif //MODEM_ON_BOARD
#endif //MBED_CONF_NSAPI_PRESENT #endif //MBED_CONF_NSAPI_PRESENT