Skip to content

Commit b8687ab

Browse files
committed
add EP_ATLAS as mbed target
1 parent b1629b7 commit b8687ab

File tree

6 files changed

+671
-0
lines changed

6 files changed

+671
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
//#if MBED_CONF_NSAPI_PRESENT
19+
20+
//#if EP_ATLAS_ENABLE_CELL
21+
22+
#include "gpio_api.h"
23+
#include "platform/mbed_thread.h"
24+
#include "PinNames.h"
25+
//#include "mbed.h"
26+
27+
#include "UARTSerial.h"
28+
#include "ONBOARD_TELIT_ME310.h"
29+
#include "ThisThread.h"
30+
#include "CellularLog.h"
31+
32+
33+
using namespace mbed;
34+
35+
ONBOARD_TELIT_ME310::ONBOARD_TELIT_ME310(FileHandle *fh) : TELIT_ME310(fh, P0_31, true)
36+
{
37+
}
38+
39+
nsapi_error_t ONBOARD_TELIT_ME310::hard_power_on()
40+
{
41+
onboard_modem_init();
42+
return NSAPI_ERROR_OK;
43+
}
44+
45+
nsapi_error_t ONBOARD_TELIT_ME310::hard_power_off()
46+
{
47+
onboard_modem_deinit();
48+
return NSAPI_ERROR_OK;
49+
}
50+
51+
nsapi_error_t ONBOARD_TELIT_ME310::soft_power_on()
52+
{
53+
onboard_modem_power_up();
54+
// From Telit_xE310 Global form factor App note: It is mandatory to avoid sending data to the serial ports during the first 200ms of the module start-up.
55+
rtos::ThisThread::sleep_for(200);
56+
return NSAPI_ERROR_OK;
57+
}
58+
59+
nsapi_error_t ONBOARD_TELIT_ME310::soft_power_off()
60+
{
61+
onboard_modem_power_down();
62+
return NSAPI_ERROR_OK;
63+
}
64+
65+
nsapi_error_t ONBOARD_TELIT_ME310::init()
66+
{
67+
nsapi_error_t err = AT_CellularDevice::init();
68+
if (err != NSAPI_ERROR_OK) {
69+
return err;
70+
}
71+
_at->lock();
72+
#if DEVICE_SERIAL_FC
73+
_at->at_cmd_discard("&K3;&C1;&D0", "");
74+
#else
75+
_at->at_cmd_discard("&K0;&C1;&D0", "");
76+
#endif
77+
78+
// AT#QSS=1
79+
// Enable the Query SIM Status unsolicited indication in the ME. The format of the
80+
// unsolicited indication is the following:
81+
// #QSS: <status>
82+
// The ME informs at
83+
// every SIM status change through the basic unsolicited indication where <status> range is 0...1
84+
// <status> values:
85+
// - 0: SIM not inserted
86+
// - 1: SIM inserted
87+
_at->at_cmd_discard("#QSS", "=1");
88+
89+
// AT#PSNT=1
90+
// Set command enables unsolicited result code for packet service network type (PSNT)
91+
// having the following format:
92+
// #PSNT:<nt>
93+
// <nt> values:
94+
// - 0: GPRS network
95+
// - 4: LTE network
96+
// - 5: unknown or not registered
97+
_at->at_cmd_discard("#PSNT", "=1");
98+
99+
// AT+CMER=2
100+
// Set command enables sending of unsolicited result codes from TA to TE in the case of
101+
// indicator state changes.
102+
// Current setting: buffer +CIEV Unsolicited Result Codes in the TA when TA-TE link is
103+
// reserved (e.g. on-line data mode) and flush them to the TE after
104+
// reservation; otherwise forward them directly to the TE
105+
_at->at_cmd_discard("+CMER", "=2");
106+
107+
// AT+CMEE=2
108+
// Set command disables the use of result code +CME ERROR: <err> as an indication of an
109+
// error relating to the +Cxxx command issued. When enabled, device related errors cause the +CME
110+
// ERROR: <err> final result code instead of the default ERROR final result code. ERROR is returned
111+
// normally when the error message is related to syntax, invalid parameters or DTE functionality.
112+
// Current setting: enable and use verbose <err> values
113+
_at->at_cmd_discard("+CMEE", "=2");
114+
115+
// AT#PORTCFG=0
116+
// Set command allows to connect Service Access Points to the external physical ports giving a great
117+
// flexibility. Examples of Service Access Points: AT Parser Instance #1, #2, #3, etc..
118+
_at->at_cmd_discard("#PORTCFG", "=", "%d", EP_ATLAS_PORT_CONFIGURATION_VARIANT);
119+
120+
// AT&W&P
121+
// - AT&W: Execution command stores on profile <n> the complete configuration of the device. If
122+
// parameter is omitted, the command has the same behavior of AT&W0.
123+
// - AT&P: Execution command defines which full profile will be loaded at startup. If parameter
124+
// is omitted, the command has the same behavior as AT&P0
125+
_at->at_cmd_discard("&W&P", "");
126+
127+
return _at->unlock_return_error();
128+
}
129+
130+
void ONBOARD_TELIT_ME310::press_power_button(int time_ms)
131+
{
132+
gpio_t gpio_CELL_ON_OFF;
133+
//gpio_t gpio_PWR_MON;
134+
// volatile int read_pwr_mon_gpio = 0;
135+
136+
// gpio_init_in(&gpio_PWR_MON, PIN_NAME_CELL_PWRMON);
137+
// read_pwr_mon_gpio = gpio_read(&gpio_PWR_MON);
138+
139+
// if(!(gpio_read(&gpio_PWR_MON)))
140+
// {
141+
// gpio_init_out_ex(&gpio_CELL_ON_OFF, P0_31, 1);
142+
// gpio_write(&gpio_CELL_ON_OFF, 1);
143+
// thread_sleep_for(time_ms);
144+
// gpio_write(&gpio_CELL_ON_OFF, 0);
145+
// }
146+
147+
gpio_init_out_ex(&gpio_CELL_ON_OFF, P0_31, 1);
148+
gpio_write(&gpio_CELL_ON_OFF, 1);
149+
150+
151+
152+
// DigitalIn pwr_mon(PIN_NAME_CELL_PWRMON);
153+
// DigitalInOut cell_on_off(P0_31,PIN_INPUT,PullNone,1);
154+
155+
// if(!pwr_mon.read())
156+
// {
157+
// cell_on_off.output();
158+
// cell_on_off = 0;
159+
// ThisThread::sleep_for(time_ms);
160+
// cell_on_off = 1;
161+
// }
162+
163+
164+
}
165+
166+
void ONBOARD_TELIT_ME310::onboard_modem_init()
167+
{
168+
// gpio_t gpio;
169+
170+
// gpio_init_out_ex(&gpio, PIN_NAME_CELL_POWER_ENABLE, 0);
171+
// gpio_write(&gpio, 1);
172+
}
173+
174+
void ONBOARD_TELIT_ME310::onboard_modem_deinit()
175+
{
176+
// gpio_t gpio;
177+
178+
// gpio_init_out_ex(&gpio, PIN_NAME_CELL_POWER_ENABLE, 1);
179+
// gpio_write(&gpio, 0);
180+
}
181+
182+
void ONBOARD_TELIT_ME310::onboard_modem_power_up()
183+
{
184+
/* keep the power line low for 5 seconds */
185+
press_power_button(6000);
186+
/* give modem a little time to respond */
187+
}
188+
189+
void ONBOARD_TELIT_ME310::onboard_modem_power_down()
190+
{
191+
gpio_t gpio;
192+
193+
gpio_init_out_ex(&gpio, P0_31, 0);
194+
/* keep the power line low for more than 3 seconds.
195+
* If 3G_ON_OFF pin is kept low for more than a second, a controlled disconnect and shutdown takes
196+
* place, Due to the network disconnect, shut-off can take up to 30 seconds. However, we wait for 10
197+
* seconds only */
198+
thread_sleep_for(10 * 1000);
199+
}
200+
201+
CellularDevice *CellularDevice::get_target_default_instance()
202+
{
203+
static UARTSerial serial(P1_2, P1_1, 115200);
204+
#if DEVICE_SERIAL_FC
205+
if (P0_11 != NC && P1_8 != NC) {
206+
tr_debug("Modem flow control: RTS %d CTS %d", P0_11, P1_8);
207+
serial.set_flow_control(SerialBase::RTSCTS, P0_11, P1_8);
208+
}
209+
#endif
210+
static ONBOARD_TELIT_ME310 device(&serial);
211+
return &device;
212+
}
213+
214+
//#endif // EP_ATLAS_ENABLE_CELL
215+
216+
//#endif // MBED_CONF_NSAPI_PRESENT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef ONBOARD_TELIT_ME310_
19+
#define ONBOARD_TELIT_ME310_
20+
21+
#include "TELIT_ME310.h"
22+
23+
namespace mbed {
24+
25+
class ONBOARD_TELIT_ME310 : public TELIT_ME310 {
26+
public:
27+
ONBOARD_TELIT_ME310(FileHandle *fh);
28+
29+
virtual nsapi_error_t init();
30+
virtual nsapi_error_t hard_power_on();
31+
virtual nsapi_error_t hard_power_off();
32+
virtual nsapi_error_t soft_power_on();
33+
virtual nsapi_error_t soft_power_off();
34+
35+
private:
36+
void press_power_button(int time_ms);
37+
38+
void onboard_modem_init();
39+
40+
void onboard_modem_deinit();
41+
42+
void onboard_modem_power_up();
43+
44+
void onboard_modem_power_down();
45+
};
46+
47+
} // namespace mbed
48+
49+
#endif // ONBOARD_TELIT_ME310_

0 commit comments

Comments
 (0)