mirror of https://github.com/ARMmbed/mbed-os.git
[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. // WIPpull/9554/head
parent
1892e2dd8e
commit
c41f1c75d7
|
@ -16,36 +16,37 @@
|
|||
|
||||
#if MBED_CONF_NSAPI_PRESENT
|
||||
|
||||
#include "ONBOARD_QUECTEL_BG96.h"
|
||||
#include "ONBOARD_QUECTEL_UG96.h"
|
||||
|
||||
#include "cellular/onboard_modem_api.h"
|
||||
#include "UARTSerial.h"
|
||||
|
||||
using namespace mbed;
|
||||
|
||||
ONBOARD_QUECTEL_BG96::ONBOARD_QUECTEL_BG96(FileHandle *fh) : QUECTEL_BG96(fh)
|
||||
ONBOARD_QUECTEL_UG96::ONBOARD_QUECTEL_UG96(FileHandle *fh) : QUECTEL_UG96(fh)
|
||||
{
|
||||
::onboard_modem_init();
|
||||
}
|
||||
|
||||
nsapi_error_t ONBOARD_QUECTEL_BG96::hard_power_on()
|
||||
nsapi_error_t ONBOARD_QUECTEL_UG96::hard_power_on()
|
||||
{
|
||||
::onboard_modem_init();
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t ONBOARD_QUECTEL_BG96::hard_power_off()
|
||||
nsapi_error_t ONBOARD_QUECTEL_UG96::hard_power_off()
|
||||
{
|
||||
::onboard_modem_deinit();
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t ONBOARD_QUECTEL_BG96::soft_power_on()
|
||||
nsapi_error_t ONBOARD_QUECTEL_UG96::soft_power_on()
|
||||
{
|
||||
::onboard_modem_power_up();
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t ONBOARD_QUECTEL_BG96::soft_power_off()
|
||||
nsapi_error_t ONBOARD_QUECTEL_UG96::soft_power_off()
|
||||
{
|
||||
::onboard_modem_power_down();
|
||||
return NSAPI_ERROR_OK;
|
||||
|
@ -54,7 +55,7 @@ nsapi_error_t ONBOARD_QUECTEL_BG96::soft_power_off()
|
|||
CellularDevice *CellularDevice::get_target_default_instance()
|
||||
{
|
||||
static UARTSerial serial(MDMTXD, MDMRXD, 115200);
|
||||
static ONBOARD_QUECTEL_BG96 device(&serial);
|
||||
static ONBOARD_QUECTEL_UG96 device(&serial);
|
||||
return &device;
|
||||
}
|
||||
|
|
@ -14,16 +14,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ONBOARD_QUECTEL_BG96_
|
||||
#define ONBOARD_QUECTEL_BG96_
|
||||
#ifndef ONBOARD_QUECTEL_UG96_
|
||||
#define ONBOARD_QUECTEL_UG96_
|
||||
|
||||
#include "QUECTEL_BG96.h"
|
||||
#include "QUECTEL_UG96.h"
|
||||
|
||||
namespace mbed {
|
||||
|
||||
class ONBOARD_QUECTEL_BG96 : public QUECTEL_BG96 {
|
||||
class ONBOARD_QUECTEL_UG96 : public QUECTEL_UG96 {
|
||||
public:
|
||||
ONBOARD_QUECTEL_BG96(FileHandle *fh);
|
||||
ONBOARD_QUECTEL_UG96(FileHandle *fh);
|
||||
|
||||
virtual nsapi_error_t hard_power_on();
|
||||
virtual nsapi_error_t hard_power_off();
|
||||
|
@ -33,4 +33,4 @@ public:
|
|||
|
||||
} // namespace mbed
|
||||
|
||||
#endif // ONBOARD_QUECTEL_BG96_
|
||||
#endif // ONBOARD_QUECTEL_UG96_
|
|
@ -1,5 +1,7 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
* Copyright (c) 2017 Arm Limited
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -21,6 +23,8 @@
|
|||
#include "platform/mbed_wait_api.h"
|
||||
#include "PinNames.h"
|
||||
|
||||
#define WAIT_AFTER_POWR_CHANGED (1000) // [msec.]
|
||||
|
||||
#if MODEM_ON_BOARD
|
||||
|
||||
static void press_power_button(int time_ms)
|
||||
|
@ -28,7 +32,6 @@ static void press_power_button(int time_ms)
|
|||
gpio_t gpio;
|
||||
|
||||
gpio_init_out_ex(&gpio, PWRKEY, 1);
|
||||
gpio_write(&gpio, 1);
|
||||
wait_ms(time_ms);
|
||||
gpio_write(&gpio, 0);
|
||||
}
|
||||
|
@ -36,35 +39,50 @@ static void press_power_button(int time_ms)
|
|||
void onboard_modem_init()
|
||||
{
|
||||
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);
|
||||
wait_ms(500);
|
||||
// Power Supply
|
||||
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()
|
||||
{
|
||||
// wio3g_mdm_powerOff();
|
||||
gpio_t gpio;
|
||||
|
||||
// Power supply OFF
|
||||
gpio_init_out_ex(&gpio, M_POWR, 0);
|
||||
wait_ms(WAIT_AFTER_POWR_CHANGED);
|
||||
}
|
||||
|
||||
void onboard_modem_power_up()
|
||||
{
|
||||
/* keep the power line HIGH for 200 milisecond */
|
||||
press_power_button(200);
|
||||
/* give modem a little time to respond */
|
||||
gpio_t gpio;
|
||||
|
||||
// Power supply ON
|
||||
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()
|
||||
{
|
||||
/* keep the power line low for 1 second */
|
||||
// press_power_button(1000);
|
||||
gpio_t gpio;
|
||||
|
||||
// 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 //MBED_CONF_NSAPI_PRESENT
|
||||
|
|
Loading…
Reference in New Issue