Skip to content

Commit ce1785f

Browse files
author
Chris Trowbridge
authored
Add Telit ME910 driver
1 parent 46603f8 commit ce1785f

File tree

3 files changed

+188
-0
lines changed

3 files changed

+188
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright (c) 2017, Arm Limited and affiliates.
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 "TELIT_ME910.h"
19+
#include "AT_CellularNetwork.h"
20+
#include "mbed-trace/mbed_trace.h"
21+
#include "gpio_api.h"
22+
#include "platform/mbed_wait_api.h"
23+
#include "PinNames.h"
24+
#include "mbed.h"
25+
26+
#define TRACE_GROUP "ME91"
27+
28+
using namespace mbed;
29+
using namespace events;
30+
31+
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
32+
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
33+
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
34+
AT_CellularNetwork::RegistrationModeLAC, // C_REG
35+
0, // AT_CGSN_WITH_TYPE
36+
0, // AT_CGDATA
37+
1, // AT_CGAUTH
38+
1, // AT_CNMI
39+
1, // AT_CSMP
40+
1, // AT_CMGF
41+
1, // AT_CSDH
42+
1, // PROPERTY_IPV4_STACK
43+
1, // PROPERTY_IPV6_STACK
44+
1, // PROPERTY_IPV4V6_STACK
45+
0, // PROPERTY_NON_IP_PDP_TYPE
46+
1, // PROPERTY_AT_CGEREP
47+
};
48+
49+
TELIT_ME910::TELIT_ME910(FileHandle *fh) : AT_CellularDevice(fh)
50+
{
51+
AT_CellularBase::set_cellular_properties(cellular_properties);
52+
}
53+
54+
uint16_t TELIT_ME910::get_send_delay() const
55+
{
56+
return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
57+
}
58+
59+
nsapi_error_t TELIT_ME910::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 defined (MBED_CONF_TELIT_ME910_RTS) && defined (MBED_CONF_TELIT_ME910_CTS)
67+
_at->cmd_start("AT&K3;&C1;&D0");
68+
#else
69+
_at->cmd_start("AT&K0;&C1;&D0");
70+
#endif
71+
_at->cmd_stop_read_resp();
72+
73+
return _at->unlock_return_error();
74+
}
75+
76+
#if MBED_CONF_TELIT_ME910_PROVIDE_DEFAULT
77+
#include "UARTSerial.h"
78+
CellularDevice *CellularDevice::get_default_instance()
79+
{
80+
static UARTSerial serial(MBED_CONF_TELIT_ME910_TX, MBED_CONF_TELIT_ME910_RX, MBED_CONF_TELIT_ME910_BAUDRATE);
81+
#if defined (MBED_CONF_TELIT_ME910_RTS) && defined (MBED_CONF_TELIT_ME910_CTS)
82+
tr_debug("TELIT_ME910 flow control: RTS %d CTS %d", MBED_CONF_TELIT_ME910_RTS, MBED_CONF_TELIT_ME910_CTS);
83+
serial.set_flow_control(SerialBase::RTSCTS, MBED_CONF_TELIT_ME910_RTS, MBED_CONF_TELIT_ME910_CTS);
84+
#endif
85+
static TELIT_ME910 device(&serial);
86+
return &device;
87+
}
88+
#endif
89+
90+
nsapi_error_t TELIT_ME910::hard_power_on()
91+
{
92+
return AT_CellularDevice::hard_power_on();
93+
}
94+
95+
nsapi_error_t TELIT_ME910::hard_power_off()
96+
{
97+
return AT_CellularDevice::hard_power_off();
98+
}
99+
100+
nsapi_error_t TELIT_ME910::soft_power_on()
101+
{
102+
return AT_CellularDevice::soft_power_on();
103+
}
104+
105+
nsapi_error_t TELIT_ME910::soft_power_off()
106+
{
107+
return AT_CellularDevice::soft_power_off();
108+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2017, Arm Limited and affiliates.
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 CELLULAR_TARGETS_TELIT_ME910_TELIT_ME910_H_
19+
#define CELLULAR_TARGETS_TELIT_ME910_TELIT_ME910_H_
20+
21+
#ifdef TARGET_FF_ARDUINO
22+
#ifndef MBED_CONF_TELIT_ME910_TX
23+
#define MBED_CONF_TELIT_ME910_TX D1
24+
#endif
25+
#ifndef MBED_CONF_TELIT_ME910_RX
26+
#define MBED_CONF_TELIT_ME910_RX D0
27+
#endif
28+
#endif /* TARGET_FF_ARDUINO */
29+
30+
#include "AT_CellularDevice.h"
31+
32+
//the delay between sending AT commands
33+
#define DEFAULT_DELAY_BETWEEN_AT_COMMANDS 20
34+
35+
namespace mbed {
36+
37+
class TELIT_ME910 : public AT_CellularDevice {
38+
public:
39+
TELIT_ME910(FileHandle *fh);
40+
41+
protected: // AT_CellularDevice
42+
virtual uint16_t get_send_delay() const;
43+
virtual nsapi_error_t init();
44+
virtual nsapi_error_t hard_power_on();
45+
virtual nsapi_error_t hard_power_off();
46+
virtual nsapi_error_t soft_power_on();
47+
virtual nsapi_error_t soft_power_off();
48+
};
49+
} // namespace mbed
50+
#endif /* CELLULAR_TARGETS_TELIT_ME910_TELIT_ME910_H_ */
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "TELIT_ME910",
3+
"config": {
4+
"tx": {
5+
"help": "TX pin for serial connection. D1 assumed if Arduino Form Factor, needs to be set/overwritten otherwise.",
6+
"value": null
7+
},
8+
"rx": {
9+
"help": "RX pin for serial connection. D0 assumed if Arduino Form Factor, needs to be set/overwritten otherwise.",
10+
"value": null
11+
},
12+
"rts": {
13+
"help": "RTS pin for serial connection",
14+
"value": null
15+
},
16+
"cts": {
17+
"help": "CTS pin for serial connection",
18+
"value": null
19+
},
20+
"baudrate" : {
21+
"help": "Serial connection baud rate",
22+
"value": 115200
23+
},
24+
"provide-default": {
25+
"help": "Provide as default CellularDevice [true/false]",
26+
"value": false
27+
}
28+
}
29+
}
30+

0 commit comments

Comments
 (0)