Skip to content

Commit 6646e8e

Browse files
authored
Merge pull request #13128 from farrenv/add-EP-ATLAS
Add support for Embedded Planet target Atlas
2 parents 32a032b + 70b0aca commit 6646e8e

File tree

6 files changed

+588
-0
lines changed

6 files changed

+588
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
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+
#include "gpio_api.h"
19+
#include "platform/mbed_thread.h"
20+
#include "PinNames.h"
21+
#include "BufferedSerial.h"
22+
#include "ONBOARD_TELIT_ME310.h"
23+
#include "ThisThread.h"
24+
#include "CellularLog.h"
25+
26+
27+
using namespace mbed;
28+
29+
ONBOARD_TELIT_ME310::ONBOARD_TELIT_ME310(FileHandle *fh) : TELIT_ME310(fh, P0_31, true)
30+
{
31+
}
32+
33+
nsapi_error_t ONBOARD_TELIT_ME310::hard_power_on()
34+
{
35+
onboard_modem_init();
36+
return NSAPI_ERROR_OK;
37+
}
38+
39+
nsapi_error_t ONBOARD_TELIT_ME310::hard_power_off()
40+
{
41+
onboard_modem_deinit();
42+
return NSAPI_ERROR_OK;
43+
}
44+
45+
nsapi_error_t ONBOARD_TELIT_ME310::soft_power_on()
46+
{
47+
onboard_modem_power_up();
48+
// 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.
49+
rtos::ThisThread::sleep_for(200);
50+
return NSAPI_ERROR_OK;
51+
}
52+
53+
nsapi_error_t ONBOARD_TELIT_ME310::soft_power_off()
54+
{
55+
onboard_modem_power_down();
56+
return NSAPI_ERROR_OK;
57+
}
58+
59+
nsapi_error_t ONBOARD_TELIT_ME310::init()
60+
{
61+
nsapi_error_t err = AT_CellularDevice::init();
62+
if (err != NSAPI_ERROR_OK) {
63+
return err;
64+
}
65+
_at.lock();
66+
#if DEVICE_SERIAL_FC
67+
_at.at_cmd_discard("&K3;&C1;&D0", "");
68+
#else
69+
_at.at_cmd_discard("&K0;&C1;&D0", "");
70+
#endif
71+
72+
// AT#QSS=1
73+
// Enable the Query SIM Status unsolicited indication in the ME. The format of the
74+
// unsolicited indication is the following:
75+
// #QSS: <status>
76+
// The ME informs at
77+
// every SIM status change through the basic unsolicited indication where <status> range is 0...1
78+
// <status> values:
79+
// - 0: SIM not inserted
80+
// - 1: SIM inserted
81+
_at.at_cmd_discard("#QSS", "=1");
82+
83+
// AT#PSNT=1
84+
// Set command enables unsolicited result code for packet service network type (PSNT)
85+
// having the following format:
86+
// #PSNT:<nt>
87+
// <nt> values:
88+
// - 0: GPRS network
89+
// - 4: LTE network
90+
// - 5: unknown or not registered
91+
_at.at_cmd_discard("#PSNT", "=1");
92+
93+
// AT+CMER=2
94+
// Set command enables sending of unsolicited result codes from TA to TE in the case of
95+
// indicator state changes.
96+
// Current setting: buffer +CIEV Unsolicited Result Codes in the TA when TA-TE link is
97+
// reserved (e.g. on-line data mode) and flush them to the TE after
98+
// reservation; otherwise forward them directly to the TE
99+
_at.at_cmd_discard("+CMER", "=2");
100+
101+
// AT+CMEE=2
102+
// Set command disables the use of result code +CME ERROR: <err> as an indication of an
103+
// error relating to the +Cxxx command issued. When enabled, device related errors cause the +CME
104+
// ERROR: <err> final result code instead of the default ERROR final result code. ERROR is returned
105+
// normally when the error message is related to syntax, invalid parameters or DTE functionality.
106+
// Current setting: enable and use verbose <err> values
107+
_at.at_cmd_discard("+CMEE", "=2");
108+
109+
// AT#PORTCFG=0
110+
// Set command allows to connect Service Access Points to the external physical ports giving a great
111+
// flexibility. Examples of Service Access Points: AT Parser Instance #1, #2, #3, etc..
112+
_at.at_cmd_discard("#PORTCFG", "=", "%d", EP_ATLAS_PORT_CONFIGURATION_VARIANT);
113+
114+
// AT&W&P
115+
// - AT&W: Execution command stores on profile <n> the complete configuration of the device. If
116+
// parameter is omitted, the command has the same behavior of AT&W0.
117+
// - AT&P: Execution command defines which full profile will be loaded at startup. If parameter
118+
// is omitted, the command has the same behavior as AT&P0
119+
_at.at_cmd_discard("&W&P", "");
120+
121+
return _at.unlock_return_error();
122+
}
123+
124+
void ONBOARD_TELIT_ME310::press_power_button(int time_ms)
125+
{
126+
gpio_t gpio_CELL_ON_OFF;
127+
gpio_init_out_ex(&gpio_CELL_ON_OFF, P0_31, 1);
128+
gpio_write(&gpio_CELL_ON_OFF, 1);
129+
}
130+
131+
void ONBOARD_TELIT_ME310::onboard_modem_init()
132+
{
133+
}
134+
135+
void ONBOARD_TELIT_ME310::onboard_modem_deinit()
136+
{
137+
}
138+
139+
void ONBOARD_TELIT_ME310::onboard_modem_power_up()
140+
{
141+
/* keep the power line low for 5 seconds */
142+
press_power_button(6000);
143+
/* give modem a little time to respond */
144+
}
145+
146+
void ONBOARD_TELIT_ME310::onboard_modem_power_down()
147+
{
148+
gpio_t gpio;
149+
150+
gpio_init_out_ex(&gpio, P0_31, 0);
151+
/* keep the power line low for more than 3 seconds.
152+
* If 3G_ON_OFF pin is kept low for more than a second, a controlled disconnect and shutdown takes
153+
* place, Due to the network disconnect, shut-off can take up to 30 seconds. However, we wait for 10
154+
* seconds only */
155+
thread_sleep_for(10 * 1000);
156+
}
157+
158+
CellularDevice *CellularDevice::get_target_default_instance()
159+
{
160+
static BufferedSerial serial(P1_2, P1_1, 115200);
161+
#if DEVICE_SERIAL_FC
162+
if (P0_11 != NC && P1_8 != NC) {
163+
tr_debug("Modem flow control: RTS %d CTS %d", P0_11, P1_8);
164+
serial.set_flow_control(SerialBase::RTSCTS, P0_11, P1_8);
165+
}
166+
#endif
167+
static ONBOARD_TELIT_ME310 device(&serial);
168+
return &device;
169+
}
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)