Greg Steiert / pegasus_dev

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 /*
switches 0:5c4d7b2438d3 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
switches 0:5c4d7b2438d3 3 * SPDX-License-Identifier: Apache-2.0
switches 0:5c4d7b2438d3 4 * Licensed under the Apache License, Version 2.0 (the License); you may
switches 0:5c4d7b2438d3 5 * not use this file except in compliance with the License.
switches 0:5c4d7b2438d3 6 * You may obtain a copy of the License at
switches 0:5c4d7b2438d3 7 *
switches 0:5c4d7b2438d3 8 * http://www.apache.org/licenses/LICENSE-2.0
switches 0:5c4d7b2438d3 9 *
switches 0:5c4d7b2438d3 10 * Unless required by applicable law or agreed to in writing, software
switches 0:5c4d7b2438d3 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
switches 0:5c4d7b2438d3 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
switches 0:5c4d7b2438d3 13 * See the License for the specific language governing permissions and
switches 0:5c4d7b2438d3 14 * limitations under the License.
switches 0:5c4d7b2438d3 15 */
switches 0:5c4d7b2438d3 16
switches 0:5c4d7b2438d3 17 /*
switches 0:5c4d7b2438d3 18 * Thread network interface.
switches 0:5c4d7b2438d3 19 * Class provides methods for 6LoWPAN (Thread mode) network handling.
switches 0:5c4d7b2438d3 20 */
switches 0:5c4d7b2438d3 21
switches 0:5c4d7b2438d3 22 #include <stdio.h>
switches 0:5c4d7b2438d3 23 #include "mbed.h"
switches 0:5c4d7b2438d3 24 #include "mbed-mesh-api/MeshThread.h"
switches 0:5c4d7b2438d3 25 #include "include/thread_tasklet.h"
switches 0:5c4d7b2438d3 26 #include "include/callback_handler.h"
switches 0:5c4d7b2438d3 27
switches 0:5c4d7b2438d3 28 #define HAVE_DEBUG 1
switches 0:5c4d7b2438d3 29 #include "ns_trace.h"
switches 0:5c4d7b2438d3 30
switches 0:5c4d7b2438d3 31 #define TRACE_GROUP "m6LTh"
switches 0:5c4d7b2438d3 32
switches 0:5c4d7b2438d3 33 MeshThread::MeshThread() : AbstractMesh(MESH_TYPE_THREAD)
switches 0:5c4d7b2438d3 34 {
switches 0:5c4d7b2438d3 35 }
switches 0:5c4d7b2438d3 36
switches 0:5c4d7b2438d3 37 MeshThread::~MeshThread()
switches 0:5c4d7b2438d3 38 {
switches 0:5c4d7b2438d3 39 tr_debug("~MeshThread()");
switches 0:5c4d7b2438d3 40 thread_tasklet_disconnect(false);
switches 0:5c4d7b2438d3 41 }
switches 0:5c4d7b2438d3 42
switches 0:5c4d7b2438d3 43 mesh_error_t MeshThread::init(int8_t registered_device_id, mesh_network_handler_t callbackHandler, uint8_t *eui64, char *pskd)
switches 0:5c4d7b2438d3 44 {
switches 0:5c4d7b2438d3 45
switches 0:5c4d7b2438d3 46 if (eui64 == NULL) {
switches 0:5c4d7b2438d3 47 return MESH_ERROR_PARAM;
switches 0:5c4d7b2438d3 48 }
switches 0:5c4d7b2438d3 49
switches 0:5c4d7b2438d3 50 mesh_error_t status = AbstractMesh::init(registered_device_id, callbackHandler);
switches 0:5c4d7b2438d3 51
switches 0:5c4d7b2438d3 52 if (status == MESH_ERROR_NONE) {
switches 0:5c4d7b2438d3 53 thread_tasklet_device_config_set(eui64, pskd);
switches 0:5c4d7b2438d3 54 }
switches 0:5c4d7b2438d3 55
switches 0:5c4d7b2438d3 56 return status;
switches 0:5c4d7b2438d3 57 }
switches 0:5c4d7b2438d3 58
switches 0:5c4d7b2438d3 59 mesh_error_t MeshThread::init(int8_t registered_device_id, mesh_network_handler_t callbackHandler)
switches 0:5c4d7b2438d3 60 {
switches 0:5c4d7b2438d3 61 // TODO: Use test values for device configuration
switches 0:5c4d7b2438d3 62 return MeshThread::init(registered_device_id, callbackHandler, NULL, NULL);
switches 0:5c4d7b2438d3 63 }
switches 0:5c4d7b2438d3 64
switches 0:5c4d7b2438d3 65 bool MeshThread::getOwnIpAddress(char *address, int8_t len)
switches 0:5c4d7b2438d3 66 {
switches 0:5c4d7b2438d3 67 tr_debug("getOwnIpAddress()");
switches 0:5c4d7b2438d3 68 if (thread_tasklet_get_ip_address(address, len) == 0) {
switches 0:5c4d7b2438d3 69 return true;
switches 0:5c4d7b2438d3 70 }
switches 0:5c4d7b2438d3 71 return false;
switches 0:5c4d7b2438d3 72 }
switches 0:5c4d7b2438d3 73
switches 0:5c4d7b2438d3 74 mesh_error_t MeshThread::data_poll_rate_set(uint32_t pollrate)
switches 0:5c4d7b2438d3 75 {
switches 0:5c4d7b2438d3 76 mesh_error_t status = MESH_ERROR_NONE;
switches 0:5c4d7b2438d3 77 int8_t retval = thread_tasklet_data_poll_rate_set(pollrate);
switches 0:5c4d7b2438d3 78 switch (retval) {
switches 0:5c4d7b2438d3 79 case 0:
switches 0:5c4d7b2438d3 80 status = MESH_ERROR_NONE;
switches 0:5c4d7b2438d3 81 break;
switches 0:5c4d7b2438d3 82 case -2:
switches 0:5c4d7b2438d3 83 status = MESH_ERROR_PARAM;
switches 0:5c4d7b2438d3 84 break;
switches 0:5c4d7b2438d3 85 default:
switches 0:5c4d7b2438d3 86 //case -1:
switches 0:5c4d7b2438d3 87 status = MESH_ERROR_UNKNOWN;
switches 0:5c4d7b2438d3 88 break;
switches 0:5c4d7b2438d3 89 }
switches 0:5c4d7b2438d3 90
switches 0:5c4d7b2438d3 91 return status;
switches 0:5c4d7b2438d3 92 }
switches 0:5c4d7b2438d3 93