Skip to content

Commit 0f34456

Browse files
Added UBLOX modem api for power up modem UBLOX_C027
1 parent 6677249 commit 0f34456

File tree

4 files changed

+119
-32
lines changed

4 files changed

+119
-32
lines changed

targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ONBOARD_UBLOX_PPP.cpp

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@
1717
#if MBED_CONF_NSAPI_PRESENT
1818

1919
#include "ONBOARD_UBLOX_PPP.h"
20-
21-
#include "ublox_low_level_api.h"
22-
#include "gpio_api.h"
23-
#include "platform/mbed_thread.h"
24-
#include "PinNames.h"
25-
20+
#include "UBLOX_onboard_modem_api.h"
2621
#include "drivers/BufferedSerial.h"
2722
#include "CellularLog.h"
2823

@@ -34,47 +29,28 @@ ONBOARD_UBLOX_PPP::ONBOARD_UBLOX_PPP(FileHandle *fh) : UBLOX_PPP(fh)
3429

3530
nsapi_error_t ONBOARD_UBLOX_PPP::hard_power_on()
3631
{
37-
//currently USB is not supported, so pass 0 to disable USB
38-
//This call does everything except actually pressing the power button
39-
ublox_mdm_powerOn(0);
40-
32+
::onboard_modem_init();
4133
return NSAPI_ERROR_OK;
4234
}
4335

4436
nsapi_error_t ONBOARD_UBLOX_PPP::hard_power_off()
4537
{
46-
ublox_mdm_powerOff();
47-
38+
::onboard_modem_deinit();
4839
return NSAPI_ERROR_OK;
4940
}
5041

5142
nsapi_error_t ONBOARD_UBLOX_PPP::soft_power_on()
5243
{
53-
/* keep the power line low for 150 milisecond */
54-
press_power_button(150);
55-
/* give modem a little time to respond */
56-
thread_sleep_for(100);
57-
44+
::onboard_modem_power_up();
5845
return NSAPI_ERROR_OK;
5946
}
6047

6148
nsapi_error_t ONBOARD_UBLOX_PPP::soft_power_off()
6249
{
63-
/* keep the power line low for 1 second */
64-
press_power_button(1000);
65-
50+
::onboard_modem_power_down();
6651
return NSAPI_ERROR_OK;
6752
}
6853

69-
void ONBOARD_UBLOX_PPP::press_power_button(int time_ms)
70-
{
71-
gpio_t gpio;
72-
73-
gpio_init_out_ex(&gpio, MDMPWRON, 0);
74-
thread_sleep_for(time_ms);
75-
gpio_write(&gpio, 1);
76-
}
77-
7854
CellularDevice *CellularDevice::get_target_default_instance()
7955
{
8056
static BufferedSerial serial(MDMTXD, MDMRXD, 115200);

targets/TARGET_NXP/TARGET_LPC176X/TARGET_UBLOX_C027/ONBOARD_UBLOX_PPP.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ class ONBOARD_UBLOX_PPP : public UBLOX_PPP {
2929
virtual nsapi_error_t hard_power_off();
3030
virtual nsapi_error_t soft_power_on();
3131
virtual nsapi_error_t soft_power_off();
32-
33-
private:
34-
void press_power_button(int time_ms);
3532
};
3633

3734
} // namespace mbed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2020 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#if MBED_CONF_NSAPI_PRESENT
18+
19+
#include "UBLOX_onboard_modem_api.h"
20+
#include "gpio_api.h"
21+
#include "platform/mbed_wait_api.h"
22+
#include "platform/mbed_thread.h"
23+
#include "PinNames.h"
24+
25+
static void press_power_button(time_ms)
26+
{
27+
gpio_t gpio;
28+
29+
gpio_init_out_ex(&gpio, MDMPWRON, 0);
30+
thread_sleep_for(time_ms);
31+
gpio_write(&gpio, 1);
32+
}
33+
34+
void onboard_modem_init()
35+
{
36+
//currently USB is not supported, so pass 0 to disable USB
37+
//This call does everything except actually pressing the power button
38+
ublox_mdm_powerOn(0);
39+
}
40+
41+
void onboard_modem_deinit()
42+
{
43+
ublox_mdm_powerOff();
44+
}
45+
46+
void onboard_modem_power_up()
47+
{
48+
/* keep the power line low for 150 microseconds */
49+
press_power_button(150);
50+
51+
/* give modem a little time to respond */
52+
thread_sleep_for(100);
53+
}
54+
55+
void onboard_modem_power_down()
56+
{
57+
/* keep the power line low for 1 seconds */
58+
press_power_button(1000);
59+
}
60+
61+
#endif //MBED_CONF_NSAPI_PRESENT
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2020 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef UBLOX_ONBOARD_MODEM_API_H_
18+
#define UBLOX_ONBOARD_MODEM_API_H_
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
/** Sets the modem up for powering on
25+
* modem_init() will be equivalent to plugging in the device, i.e.,
26+
* attaching power and serial port.
27+
*/
28+
void onboard_modem_init(void);
29+
30+
/** Sets the modem in unplugged state
31+
* modem_deinit() will be equivalent to pulling the plug off of the device, i.e.,
32+
* detaching power and serial port.
33+
* This puts the modem in lowest power state.
34+
*/
35+
void onboard_modem_deinit(void);
36+
37+
/** Powers up the modem
38+
* modem_power_up() will be equivalent to pressing the soft power button.
39+
* The driver may repeat this if the modem is not responsive to AT commands.
40+
41+
*/
42+
void onboard_modem_power_up(void);
43+
44+
/** Powers down the modem
45+
* modem_power_down() will be equivalent to turning off the modem by button press.
46+
*/
47+
void onboard_modem_power_down(void);
48+
49+
#ifdef __cplusplus
50+
}
51+
#endif
52+
53+
#endif /* UBLOX_ONBOARD_MODEM_API_H_ */

0 commit comments

Comments
 (0)