diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_BG96.cpp b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_UG96.cpp similarity index 74% rename from targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_BG96.cpp rename to targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_UG96.cpp index f218a8204e..0dcbcbf344 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_BG96.cpp +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_UG96.cpp @@ -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; } diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_BG96.h b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_UG96.h similarity index 80% rename from targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_BG96.h rename to targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_UG96.h index 1416660ec7..aee3871c76 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_BG96.h +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/ONBOARD_QUECTEL_UG96.h @@ -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_ diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/onboard_modem_api.c b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/onboard_modem_api.c index 23f7fb1985..c103ad0602 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/onboard_modem_api.c +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_WIO_3G/onboard_modem_api.c @@ -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