Add Telit ME910 driver

pull/10484/head
Chris Trowbridge 2019-04-25 13:59:58 -04:00
parent 489bd10626
commit 841607d029
3 changed files with 188 additions and 0 deletions

View File

@ -0,0 +1,108 @@
/*
* Copyright (c) 2017, Arm Limited and affiliates.
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "TELIT_ME910.h"
#include "AT_CellularNetwork.h"
#include "mbed-trace/mbed_trace.h"
#include "gpio_api.h"
#include "platform/mbed_wait_api.h"
#include "PinNames.h"
#include "mbed.h"
#define TRACE_GROUP "ME91"
using namespace mbed;
using namespace events;
static const intptr_t cellular_properties[AT_CellularBase::PROPERTY_MAX] = {
AT_CellularNetwork::RegistrationModeLAC, // C_EREG
AT_CellularNetwork::RegistrationModeLAC, // C_GREG
AT_CellularNetwork::RegistrationModeLAC, // C_REG
0, // AT_CGSN_WITH_TYPE
0, // AT_CGDATA
1, // AT_CGAUTH
1, // AT_CNMI
1, // AT_CSMP
1, // AT_CMGF
1, // AT_CSDH
1, // PROPERTY_IPV4_STACK
1, // PROPERTY_IPV6_STACK
1, // PROPERTY_IPV4V6_STACK
0, // PROPERTY_NON_IP_PDP_TYPE
1, // PROPERTY_AT_CGEREP
};
TELIT_ME910::TELIT_ME910(FileHandle *fh) : AT_CellularDevice(fh)
{
AT_CellularBase::set_cellular_properties(cellular_properties);
}
uint16_t TELIT_ME910::get_send_delay() const
{
return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
}
nsapi_error_t TELIT_ME910::init()
{
nsapi_error_t err = AT_CellularDevice::init();
if (err != NSAPI_ERROR_OK) {
return err;
}
_at->lock();
#if defined (MBED_CONF_TELIT_ME910_RTS) && defined (MBED_CONF_TELIT_ME910_CTS)
_at->cmd_start("AT&K3;&C1;&D0");
#else
_at->cmd_start("AT&K0;&C1;&D0");
#endif
_at->cmd_stop_read_resp();
return _at->unlock_return_error();
}
#if MBED_CONF_TELIT_ME910_PROVIDE_DEFAULT
#include "UARTSerial.h"
CellularDevice *CellularDevice::get_default_instance()
{
static UARTSerial serial(MBED_CONF_TELIT_ME910_TX, MBED_CONF_TELIT_ME910_RX, MBED_CONF_TELIT_ME910_BAUDRATE);
#if defined (MBED_CONF_TELIT_ME910_RTS) && defined (MBED_CONF_TELIT_ME910_CTS)
tr_debug("TELIT_ME910 flow control: RTS %d CTS %d", MBED_CONF_TELIT_ME910_RTS, MBED_CONF_TELIT_ME910_CTS);
serial.set_flow_control(SerialBase::RTSCTS, MBED_CONF_TELIT_ME910_RTS, MBED_CONF_TELIT_ME910_CTS);
#endif
static TELIT_ME910 device(&serial);
return &device;
}
#endif
nsapi_error_t TELIT_ME910::hard_power_on()
{
return AT_CellularDevice::hard_power_on();
}
nsapi_error_t TELIT_ME910::hard_power_off()
{
return AT_CellularDevice::hard_power_off();
}
nsapi_error_t TELIT_ME910::soft_power_on()
{
return AT_CellularDevice::soft_power_on();
}
nsapi_error_t TELIT_ME910::soft_power_off()
{
return AT_CellularDevice::soft_power_off();
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2017, Arm Limited and affiliates.
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CELLULAR_TARGETS_TELIT_ME910_TELIT_ME910_H_
#define CELLULAR_TARGETS_TELIT_ME910_TELIT_ME910_H_
#ifdef TARGET_FF_ARDUINO
#ifndef MBED_CONF_TELIT_ME910_TX
#define MBED_CONF_TELIT_ME910_TX D1
#endif
#ifndef MBED_CONF_TELIT_ME910_RX
#define MBED_CONF_TELIT_ME910_RX D0
#endif
#endif /* TARGET_FF_ARDUINO */
#include "AT_CellularDevice.h"
//the delay between sending AT commands
#define DEFAULT_DELAY_BETWEEN_AT_COMMANDS 20
namespace mbed {
class TELIT_ME910 : public AT_CellularDevice {
public:
TELIT_ME910(FileHandle *fh);
protected: // AT_CellularDevice
virtual uint16_t get_send_delay() const;
virtual nsapi_error_t init();
virtual nsapi_error_t hard_power_on();
virtual nsapi_error_t hard_power_off();
virtual nsapi_error_t soft_power_on();
virtual nsapi_error_t soft_power_off();
};
} // namespace mbed
#endif /* CELLULAR_TARGETS_TELIT_ME910_TELIT_ME910_H_ */

View File

@ -0,0 +1,30 @@
{
"name": "TELIT_ME910",
"config": {
"tx": {
"help": "TX pin for serial connection. D1 assumed if Arduino Form Factor, needs to be set/overwritten otherwise.",
"value": null
},
"rx": {
"help": "RX pin for serial connection. D0 assumed if Arduino Form Factor, needs to be set/overwritten otherwise.",
"value": null
},
"rts": {
"help": "RTS pin for serial connection",
"value": null
},
"cts": {
"help": "CTS pin for serial connection",
"value": null
},
"baudrate" : {
"help": "Serial connection baud rate",
"value": 115200
},
"provide-default": {
"help": "Provide as default CellularDevice [true/false]",
"value": false
}
}
}