]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - gps-tracking-using-sub-1ghz/gps-tracking-using-sub-1ghz.git/blob - patches/concentrator.patch
Initial commit
[gps-tracking-using-sub-1ghz/gps-tracking-using-sub-1ghz.git] / patches / concentrator.patch
1 diff -urN board_palna.c concentrator_new/board_palna.c
2 --- board_palna.c       1969-12-31 18:00:00.000000000 -0600
3 +++ concentrator_new/board_palna.c      2017-07-07 13:15:02.843061400 -0500
4 @@ -0,0 +1,99 @@
5 +/******************************************************************************
6 +
7 + @file board_palna.c
8 +
9 + @brief This file contains the interface to the CC1310-CC1190 LP PA/LNA
10 +
11 + Group: WCS LPC
12 + $Target Device: DEVICES $
13 +
14 + ******************************************************************************
15 + $License: BSD3 2016 $
16 + ******************************************************************************
17 + $Release Name: PACKAGE NAME $
18 + $Release Date: PACKAGE RELEASE DATE $
19 + *****************************************************************************/
20 +
21 +/******************************************************************************
22 + Includes
23 + *****************************************************************************/
24 +
25 +#include <xdc/std.h>
26 +
27 +#include <ti/drivers/PIN.h>
28 +#include <ti/drivers/pin/PINCC26XX.h>
29 +
30 +#include "board.h"
31 +#include "board_palna.h"
32 +
33 +/******************************************************************************
34 + Constants
35 + *****************************************************************************/
36 +
37 +#define Board_DIO28_HGM     IOID_28
38 +#define Board_DIO29_LNA     IOID_29
39 +#define Board_DIO30_PA      IOID_30
40 +
41 +/******************************************************************************
42 + Typedefs
43 + *****************************************************************************/
44 +
45 +/******************************************************************************
46 + Local Variables
47 + *****************************************************************************/
48 +
49 +/*
50 + SensorTag LED has exactly the same attributes as that of
51 + BoardGpioInitTable[]. There is no need to create a new one.
52 + */
53 +static PIN_Config palnaPinTable[] =
54 +    {
55 +        Board_DIO28_HGM | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL
56 +            | PIN_DRVSTR_MAX, /* High Gain Mode by Default */
57 +        Board_DIO29_LNA | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL
58 +            | PIN_DRVSTR_MAX, /* LNA Off by Default */
59 +        Board_DIO30_PA  | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL
60 +            | PIN_DRVSTR_MAX, /* PA Off by Default */  
61 +        PIN_TERMINATE /* Terminate list     */
62 +    };
63 +
64 +/* PA/LNA pin state */
65 +static PIN_State palnaPinState;
66 +
67 +/* PA/LNA Pin Handle */
68 +static PIN_Handle palnaPinHandle;
69 +
70 +/******************************************************************************
71 + Local Function Prototypes
72 + *****************************************************************************/
73 +
74 +/******************************************************************************
75 + Public Functions
76 + *****************************************************************************/
77 +
78 +/*!
79 + Initialize PA/LNA
80 +
81 + Public function defined in board_palna.h
82 + */
83 +void Board_Palna_initialize(uint32_t hgm)
84 +{
85 +       if (hgm)
86 +       {
87 +               if (!palnaPinHandle)
88 +               {
89 +                       /* Open PA/LNA PIN driver */
90 +                       palnaPinHandle = PIN_open(&palnaPinState, palnaPinTable);
91 +                       
92 +                       /* Set IO muxing for RFC GPOs */
93 +                       PINCC26XX_setMux(palnaPinHandle, Board_DIO29_LNA, IOC_PORT_RFC_GPO0);
94 +                       PINCC26XX_setMux(palnaPinHandle, Board_DIO30_PA, IOC_PORT_RFC_GPO1);
95 +               }
96 +               
97 +               PIN_setOutputValue(palnaPinHandle, Board_DIO28_HGM, (hgm & 1));
98 +                       
99 +       }
100 +}
104 diff -urN board_palna.h concentrator_new/board_palna.h
105 --- board_palna.h       1969-12-31 18:00:00.000000000 -0600
106 +++ concentrator_new/board_palna.h      2017-07-07 13:15:02.845561400 -0500
107 @@ -0,0 +1,47 @@
108 +/******************************************************************************
110 + @file board_palna.h
112 + @brief This file contains the PA/LNA Service definitions and prototypes.
114 + Group: WCS LPC
115 + $Target Device: DEVICES $
117 + ******************************************************************************
118 + $License: BSD3 2016 $
119 + ******************************************************************************
120 + $Release Name: PACKAGE NAME $
121 + $Release Date: PACKAGE RELEASE DATE $
122 + *****************************************************************************/
123 +#ifndef BOARD_PALNA_H
124 +#define BOARD_PALNA_H
126 +/******************************************************************************
127 + Includes
128 + *****************************************************************************/
130 +#ifdef __cplusplus
131 +extern "C"
132 +{
133 +#endif
135 +/******************************************************************************
136 + Typedefs
137 + *****************************************************************************/
141 +/******************************************************************************
142 + API Functions
143 + *****************************************************************************/
145 +/*!
146 + * @brief   Initialize PA/LNA
147 + */
148 +void Board_Palna_initialize(uint32_t hgm);
150 +#ifdef __cplusplus
151 +}
152 +#endif
154 +#endif /* BOARD_PALNA_H */
155 diff -urN ConcentratorGPS.c concentrator_new/ConcentratorGPS.c
156 --- ConcentratorGPS.c   1969-12-31 18:00:00.000000000 -0600
157 +++ concentrator_new/ConcentratorGPS.c  2017-07-07 13:15:02.850561400 -0500
158 @@ -0,0 +1,146 @@
159 +/*
160 + * Copyright (c) 2015-2016, Texas Instruments Incorporated
161 + * All rights reserved.
162 + *
163 + * Redistribution and use in source and binary forms, with or without
164 + * modification, are permitted provided that the following conditions
165 + * are met:
166 + *
167 + * *  Redistributions of source code must retain the above copyright
168 + *    notice, this list of conditions and the following disclaimer.
169 + *
170 + * *  Redistributions in binary form must reproduce the above copyright
171 + *    notice, this list of conditions and the following disclaimer in the
172 + *    documentation and/or other materials provided with the distribution.
173 + *
174 + * *  Neither the name of Texas Instruments Incorporated nor the names of
175 + *    its contributors may be used to endorse or promote products derived
176 + *    from this software without specific prior written permission.
177 + *
178 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
179 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
180 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
181 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
182 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
183 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
184 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
185 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
186 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
187 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
188 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
189 + */
191 +/***** Includes *****/
193 +#include <xdc/std.h>
194 +#include <xdc/runtime/System.h>
196 +#include <ti/sysbios/BIOS.h>
198 +#include <ti/sysbios/knl/Task.h>
199 +#include <ti/sysbios/knl/Semaphore.h>
200 +#include <ti/sysbios/knl/Event.h>
202 +/* Drivers */
203 +#include <ti/drivers/PIN.h>
204 +#include <ti/display/Display.h>
205 +#include <ti/display/DisplayExt.h>
207 +/* Board Header files */
208 +#include "Board.h"
210 +#include "ConcentratorRadioTask.h"
211 +#include "ConcentratorTask.h"
212 +#include "RadioProtocol.h"
214 +#include <stdlib.h>
215 +#include <ti/drivers/UART.h>
217 +#include "ConcentratorGPS.h"
219 +/***** Variable declarations *****/
220 +UART_Handle uart;
221 +UART_Params uartParams;
223 +void gpsPacketReceive(EasyLink_RxPacket* rxPacket, union ConcentratorPacket* latestPacket);
225 +/***** Function definitions *****/
226 +void gpsUartInit(void)
227 +{
228 +    /* Create a UART with data processing off. */
229 +    UART_Params_init(&uartParams);
230 +    uartParams.writeDataMode = UART_DATA_BINARY;
231 +    uartParams.readDataMode = UART_DATA_BINARY;
232 +    uartParams.readReturnMode = UART_RETURN_FULL;
233 +    uartParams.readEcho = UART_ECHO_OFF;
234 +    uartParams.baudRate = 115200;
236 +    uart = UART_open(Board_UART0, &uartParams);
238 +    if (uart == NULL) {
239 +        /* UART_open() failed */
240 +        while (1);
241 +    }
242 +}
244 +void updateGpsNode(struct gpsSensorNode* node) {
245 +    uint8_t i;
246 +    for (i = 0; i < CONCENTRATOR_MAX_NODES; i++) {
247 +        if (knownGpsSensorNodes[i].address == node->address)
248 +        {
249 +            knownGpsSensorNodes[i].gpsData = node->gpsData;
250 +            knownGpsSensorNodes[i].latestRssi = node->latestRssi;
251 +            break;
252 +        }
253 +    }
254 +}
256 +void addNewGpsNode(struct gpsSensorNode* node) {
257 +    *lastAddedGpsSensorNode = *node;
259 +    /* Increment and wrap */
260 +    lastAddedGpsSensorNode++;
261 +    if (lastAddedGpsSensorNode > &knownGpsSensorNodes[CONCENTRATOR_MAX_NODES-1])
262 +    {
263 +        lastAddedGpsSensorNode = knownGpsSensorNodes;
264 +    }
265 +}
267 +void gpsUpdatePC(struct gpsSensorNode* node)
268 +{
269 +    char s = '$';
270 +    char n = '\n';
271 +    UART_write(uart, &s, 1);
272 +    UART_write(uart, &node->address, 1);
273 +    UART_write(uart, &node->latestRssi, 1);
274 +    UART_write(uart, &node->gpsData.lat.DM, 2);
275 +    UART_write(uart, &node->gpsData.lat.m, 3);
276 +    UART_write(uart, &node->gpsData.lng.DM, 2);
277 +    UART_write(uart, &node->gpsData.lng.m, 3);
278 +    UART_write(uart, &node->gpsData.alt.A, 2);
279 +    UART_write(uart, &node->gpsData.alt.a, 1);
280 +    UART_write(uart, &node->gpsData.time.h, 1);
281 +    UART_write(uart, &node->gpsData.time.m, 1);
282 +    UART_write(uart, &node->gpsData.time.s, 1);
283 +    UART_write(uart, &n, 1);
284 +}
286 +void gpsPacketReceive(EasyLink_RxPacket* rxPacket, union ConcentratorPacket* latestPacket)
287 +{
288 +    /* Save packet */
289 +    latestPacket->header.sourceAddress = rxPacket->payload[0];
290 +    latestPacket->header.packetType = rxPacket->payload[1];
291 +    latestPacket->gpsSensorPacket.gpsData.lat.DM = (rxPacket->payload[2] << 8 | rxPacket->payload[3]);
292 +    latestPacket->gpsSensorPacket.gpsData.lat.m = (rxPacket->payload[4] << 16 |
293 +                                                     rxPacket->payload[5] << 8  |
294 +                                                     rxPacket->payload[6]);
295 +    latestPacket->gpsSensorPacket.gpsData.lng.DM = (rxPacket->payload[7] << 8 | rxPacket->payload[8]);
296 +    latestPacket->gpsSensorPacket.gpsData.lng.m = (rxPacket->payload[9] << 16 |
297 +                                                     rxPacket->payload[10] << 8  |
298 +                                                     rxPacket->payload[11]);
299 +    latestPacket->gpsSensorPacket.gpsData.alt.A = (rxPacket->payload[12] << 8 | rxPacket->payload[13]);
300 +    latestPacket->gpsSensorPacket.gpsData.alt.a = rxPacket->payload[14];
301 +    latestPacket->gpsSensorPacket.gpsData.time.h = rxPacket->payload[15];
302 +    latestPacket->gpsSensorPacket.gpsData.time.m = rxPacket->payload[16];
303 +    latestPacket->gpsSensorPacket.gpsData.time.s = rxPacket->payload[17];
304 +}
305 diff -urN ConcentratorGPS.h concentrator_new/ConcentratorGPS.h
306 --- ConcentratorGPS.h   1969-12-31 18:00:00.000000000 -0600
307 +++ concentrator_new/ConcentratorGPS.h  2017-07-07 13:15:02.853061400 -0500
308 @@ -0,0 +1,137 @@
309 +/*
310 + * Copyright (c) 2015-2016, Texas Instruments Incorporated
311 + * All rights reserved.
312 + *
313 + * Redistribution and use in source and binary forms, with or without
314 + * modification, are permitted provided that the following conditions
315 + * are met:
316 + *
317 + * *  Redistributions of source code must retain the above copyright
318 + *    notice, this list of conditions and the following disclaimer.
319 + *
320 + * *  Redistributions in binary form must reproduce the above copyright
321 + *    notice, this list of conditions and the following disclaimer in the
322 + *    documentation and/or other materials provided with the distribution.
323 + *
324 + * *  Neither the name of Texas Instruments Incorporated nor the names of
325 + *    its contributors may be used to endorse or promote products derived
326 + *    from this software without specific prior written permission.
327 + *
328 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
329 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
330 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
331 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
332 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
333 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
334 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
335 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
336 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
337 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
338 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
339 + */
341 +#ifndef TASKS_CONCENTRATORGPS_H_
342 +#define TASKS_CONCENTRATORGPS_H_
344 +#include "stdint.h"
345 +#include "ConcentratorRadioTask.h"
346 +#include "RadioProtocol.h"
347 +#include "ConcentratorTask.h"
349 +struct gpsDataUART_s {
350 +    struct ulat_s {
351 +        char D[4];
352 +        char M[10];
353 +        char dir;
354 +    } lat;
356 +    struct ulng_s {
357 +        char D[4];
358 +        char M[9];
359 +        char dir;
360 +    } lng;
362 +    struct ualt_s
363 +    {
364 +        char A[8];   // altitude
365 +        char a[4];
366 +    } alt;
368 +    struct utime_s {
369 +        char h[4];
370 +        char m[4];
371 +        char s[4];
372 +    } time;
373 +};
375 +///* GPS Lat/Lng data in Degrees Minutes (DM), where D is signed */
376 +//struct gpsData_s {
377 +//    struct glat_s   // DM = [0][1:3]
378 +//    {
379 +//        int8_t D;
380 +//        uint32_t M;
381 +//    } lat;
382 +//    struct glng_s  // DM = [0:1][2:4]
383 +//    {
384 +//        int16_t D;
385 +//        uint32_t M;
386 +//    } lng;
387 +//    struct time_s  // h.m.s (UTC) = [0].[1].[2]
388 +//    {
389 +//        uint8_t h;
390 +//        uint8_t m;
391 +//        uint8_t s;
392 +//    } time;
393 +//};
395 +/* GPS Lat/Lng data in Degrees Minutes (DM), where D is signed */
396 +struct gpsData_s {
397 +    struct lat_s   // DM.m = [0:1].[2:4]
398 +    {
399 +        int16_t DM;
400 +        uint32_t m;
401 +    } lat;
403 +    struct lng_s  // DM = [0:1].[2:4]
404 +    {
405 +        int16_t DM;
406 +        uint32_t m;
407 +    } lng;
409 +    struct alt_s
410 +    {
411 +        uint16_t A; // altitude: A.a Meters
412 +        uint8_t a;
413 +    } alt;
415 +    struct time_s  // h.m.s (UTC) = [0].[1].[2]
416 +    {
417 +        uint8_t h;
418 +        uint8_t m;
419 +        uint8_t s;
420 +    } time;
421 +};
423 +struct gpsSensorPacket_s {
424 +    struct PacketHeader header;
425 +    struct gpsData_s gpsData;
426 +};
428 +struct gpsSensorNode {
429 +    uint8_t address;
430 +    struct gpsData_s gpsData;
431 +    int8_t latestRssi;
432 +};
434 +extern struct gpsSensorNode latestActiveGpsSensorNode;
435 +extern struct gpsSensorNode knownGpsSensorNodes[];
436 +extern struct gpsSensorNode* lastAddedGpsSensorNode;
438 +void gpsUartInit(void);
439 +void addNewGpsNode(struct gpsSensorNode* node);
440 +void updateGpsNode(struct gpsSensorNode* node);
441 +void gpsUpdatePC(struct gpsSensorNode* node);
443 +#endif /* TASKS_CONCENTRATORGPS_H_ */
446 diff -urN ConcentratorRadioTask.c concentrator_new/ConcentratorRadioTask.c
447 --- ConcentratorRadioTask.c     1969-12-31 18:00:00.000000000 -0600
448 +++ concentrator_new/ConcentratorRadioTask.c    2017-07-07 16:02:31.929194300 -0500
449 @@ -0,0 +1,278 @@
450 +/*
451 + * Copyright (c) 2015-2016, Texas Instruments Incorporated
452 + * All rights reserved.
453 + *
454 + * Redistribution and use in source and binary forms, with or without
455 + * modification, are permitted provided that the following conditions
456 + * are met:
457 + *
458 + * *  Redistributions of source code must retain the above copyright
459 + *    notice, this list of conditions and the following disclaimer.
460 + *
461 + * *  Redistributions in binary form must reproduce the above copyright
462 + *    notice, this list of conditions and the following disclaimer in the
463 + *    documentation and/or other materials provided with the distribution.
464 + *
465 + * *  Neither the name of Texas Instruments Incorporated nor the names of
466 + *    its contributors may be used to endorse or promote products derived
467 + *    from this software without specific prior written permission.
468 + *
469 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
470 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
471 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
472 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
473 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
474 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
475 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
476 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
477 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
478 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
479 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
480 + */
482 +/***** Includes *****/
483 +#include <xdc/std.h>
484 +#include <xdc/runtime/System.h>
486 +#include "ConcentratorRadioTask.h"
488 +#include <ti/sysbios/BIOS.h>
490 +#include <ti/sysbios/knl/Task.h>
491 +#include <ti/sysbios/knl/Semaphore.h>
492 +#include <ti/sysbios/knl/Event.h>
494 +/* Drivers */
495 +#include <ti/drivers/rf/RF.h>
496 +#include <ti/drivers/PIN.h>
498 +/* Board Header files */
499 +#include "Board.h"
501 +#include "easylink/EasyLink.h"
502 +#include "RadioProtocol.h"
504 +#include "ConcentratorGPS.h"
507 +/***** Defines *****/
508 +#define CONCENTRATORRADIO_TASK_STACK_SIZE 1024
509 +#define CONCENTRATORRADIO_TASK_PRIORITY   3
511 +#define RADIO_EVENT_ALL                  0xFFFFFFFF
512 +#define RADIO_EVENT_VALID_PACKET_RECEIVED      (uint32_t)(1 << 0)
513 +#define RADIO_EVENT_INVALID_PACKET_RECEIVED (uint32_t)(1 << 1)
515 +#define CONCENTRATORRADIO_MAX_RETRIES 2
516 +#define NORERADIO_ACK_TIMEOUT_TIME_MS (160)
519 +#define CONCENTRATOR_ACTIVITY_LED Board_PIN_LED0
521 +/***** Type declarations *****/
525 +/***** Variable declarations *****/
526 +static Task_Params concentratorRadioTaskParams;
527 +Task_Struct concentratorRadioTask; /* not static so you can see in ROV */
528 +static uint8_t concentratorRadioTaskStack[CONCENTRATORRADIO_TASK_STACK_SIZE];
529 +Event_Struct radioOperationEvent;  /* not static so you can see in ROV */
530 +static Event_Handle radioOperationEventHandle;
534 +static ConcentratorRadio_PacketReceivedCallback packetReceivedCallback;
535 +static union ConcentratorPacket latestRxPacket;
536 +static EasyLink_TxPacket txPacket;
537 +static struct AckPacket ackPacket;
538 +static uint8_t concentratorAddress;
539 +static int8_t latestRssi;
542 +/***** Prototypes *****/
543 +static void concentratorRadioTaskFunction(UArg arg0, UArg arg1);
544 +static void rxDoneCallback(EasyLink_RxPacket * rxPacket, EasyLink_Status status);
545 +static void notifyPacketReceived(union ConcentratorPacket* latestRxPacket);
546 +static void sendAck(uint8_t latestSourceAddress);
547 +extern void gpsPacketReceive(EasyLink_RxPacket* rxPacket, union ConcentratorPacket* latestPacket);
549 +/* Pin driver handle */
550 +static PIN_Handle ledPinHandle;
551 +static PIN_State ledPinState;
553 +/* Configure LED Pin */
554 +PIN_Config ledPinTable[] = {
555 +        CONCENTRATOR_ACTIVITY_LED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
556 +    PIN_TERMINATE
557 +};
559 +/***** Function definitions *****/
560 +void ConcentratorRadioTask_init(void) {
562 +    /* Open LED pins */
563 +    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
564 +    if (!ledPinHandle)
565 +    {
566 +        System_abort("Error initializing board 3.3V domain pins\n");
567 +    }
569 +    /* Create event used internally for state changes */
570 +    Event_Params eventParam;
571 +    Event_Params_init(&eventParam);
572 +    Event_construct(&radioOperationEvent, &eventParam);
573 +    radioOperationEventHandle = Event_handle(&radioOperationEvent);
575 +    /* Create the concentrator radio protocol task */
576 +    Task_Params_init(&concentratorRadioTaskParams);
577 +    concentratorRadioTaskParams.stackSize = CONCENTRATORRADIO_TASK_STACK_SIZE;
578 +    concentratorRadioTaskParams.priority = CONCENTRATORRADIO_TASK_PRIORITY;
579 +    concentratorRadioTaskParams.stack = &concentratorRadioTaskStack;
580 +    Task_construct(&concentratorRadioTask, concentratorRadioTaskFunction, &concentratorRadioTaskParams, NULL);
581 +}
583 +void ConcentratorRadioTask_registerPacketReceivedCallback(ConcentratorRadio_PacketReceivedCallback callback) {
584 +    packetReceivedCallback = callback;
585 +}
587 +static void concentratorRadioTaskFunction(UArg arg0, UArg arg1)
588 +{
589 +    /* Initialize EasyLink */
590 +    if(EasyLink_init(RADIO_EASYLINK_MODULATION) != EasyLink_Status_Success) {
591 +        System_abort("EasyLink_init failed");
592 +    }
595 +    /* If you wish to use a frequency other than the default use
596 +     * the below API
597 +     * EasyLink_setFrequency(868000000);
598 +     */
599 +    /* Set concentrator address */;
600 +    concentratorAddress = RADIO_CONCENTRATOR_ADDRESS;
601 +    EasyLink_enableRxAddrFilter(&concentratorAddress, 1, 1);
603 +    /* Set up Ack packet */
604 +    ackPacket.header.sourceAddress = concentratorAddress;
605 +    ackPacket.header.packetType = RADIO_PACKET_TYPE_ACK_PACKET;
607 +    /* Enter receive */
608 +    if(EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) {
609 +        System_abort("EasyLink_receiveAsync failed");
610 +    }
612 +    while (1) {
613 +        uint32_t events = Event_pend(radioOperationEventHandle, 0, RADIO_EVENT_ALL, BIOS_WAIT_FOREVER);
615 +        /* If valid packet received */
616 +        if(events & RADIO_EVENT_VALID_PACKET_RECEIVED) {
618 +            /* Send ack packet */
619 +            sendAck(latestRxPacket.header.sourceAddress);
621 +            /* Call packet received callback */
622 +            notifyPacketReceived(&latestRxPacket);
624 +            /* Go back to RX */
625 +            if(EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) {
626 +                System_abort("EasyLink_receiveAsync failed");
627 +            }
629 +            /* toggle Activity LED */
630 +            PIN_setOutputValue(ledPinHandle, CONCENTRATOR_ACTIVITY_LED,
631 +                    !PIN_getOutputValue(CONCENTRATOR_ACTIVITY_LED));
632 +        }
634 +        /* If invalid packet received */
635 +        if(events & RADIO_EVENT_INVALID_PACKET_RECEIVED) {
636 +            /* Go back to RX */
637 +            if(EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) {
638 +                System_abort("EasyLink_receiveAsync failed");
639 +            }
640 +        }
641 +    }
642 +}
644 +static void sendAck(uint8_t latestSourceAddress) {
646 +    /* Set destinationAdress, but use EasyLink layers destination adress capability */
647 +    txPacket.dstAddr[0] = latestSourceAddress;
649 +    /* Copy ACK packet to payload, skipping the destination adress byte.
650 +     * Note that the EasyLink API will implcitily both add the length byte and the destination address byte. */
651 +    memcpy(txPacket.payload, &ackPacket.header, sizeof(ackPacket));
652 +    txPacket.len = sizeof(ackPacket);
654 +    /* Send packet  */
655 +    if (EasyLink_transmit(&txPacket) != EasyLink_Status_Success)
656 +    {
657 +        System_abort("EasyLink_transmit failed");
658 +    }
659 +}
661 +static void notifyPacketReceived(union ConcentratorPacket* latestRxPacket)
662 +{
663 +    if (packetReceivedCallback)
664 +    {
665 +        packetReceivedCallback(latestRxPacket, latestRssi);
666 +    }
667 +}
669 +static void rxDoneCallback(EasyLink_RxPacket * rxPacket, EasyLink_Status status)
670 +{
671 +    union ConcentratorPacket* tmpRxPacket;
673 +    /* If we received a packet successfully */
674 +    if (status == EasyLink_Status_Success)
675 +    {
676 +        /* Save the latest RSSI, which is later sent to the receive callback */
677 +        latestRssi = (int8_t)rxPacket->rssi;
679 +        /* Check that this is a valid packet */
680 +        tmpRxPacket = (union ConcentratorPacket*)(rxPacket->payload);
682 +        /* If this is a known packet */
683 +        if (tmpRxPacket->header.packetType == RADIO_PACKET_TYPE_ADC_SENSOR_PACKET)
684 +        {
685 +            /* Save packet */
686 +            latestRxPacket.header.sourceAddress = rxPacket->payload[0];
687 +            latestRxPacket.header.packetType = rxPacket->payload[1];
688 +            latestRxPacket.adcSensorPacket.adcValue = (rxPacket->payload[2] << 8) | rxPacket->payload[3];
690 +            /* Signal packet received */
691 +            Event_post(radioOperationEventHandle, RADIO_EVENT_VALID_PACKET_RECEIVED);
692 +        }
693 +        else if (tmpRxPacket->header.packetType == RADIO_PACKET_TYPE_DM_SENSOR_PACKET)
694 +        {
695 +            /* Save packet */
696 +            latestRxPacket.header.sourceAddress = rxPacket->payload[0];
697 +            latestRxPacket.header.packetType = rxPacket->payload[1];
698 +            latestRxPacket.dmSensorPacket.adcValue = (rxPacket->payload[2] << 8) | rxPacket->payload[3];
699 +            latestRxPacket.dmSensorPacket.batt = (rxPacket->payload[4] << 8) | rxPacket->payload[5];
700 +            latestRxPacket.dmSensorPacket.time100MiliSec = (rxPacket->payload[6] << 24) |
701 +                                                           (rxPacket->payload[7] << 16) |
702 +                                                           (rxPacket->payload[8] << 8) |
703 +                                                            rxPacket->payload[9];
704 +            latestRxPacket.dmSensorPacket.button = rxPacket->payload[10];
706 +            /* Signal packet received */
707 +            Event_post(radioOperationEventHandle, RADIO_EVENT_VALID_PACKET_RECEIVED);
708 +        }
709 +        else if (tmpRxPacket->header.packetType == RADIO_PACKET_TYPE_GPS_SENSOR_PACKET)
710 +        {
711 +            gpsPacketReceive(rxPacket, &latestRxPacket);
713 +            /* Signal packet received */
714 +            Event_post(radioOperationEventHandle, RADIO_EVENT_VALID_PACKET_RECEIVED);
715 +        }
716 +        else
717 +        {
718 +            /* Signal invalid packet received */
719 +            Event_post(radioOperationEventHandle, RADIO_EVENT_INVALID_PACKET_RECEIVED);
720 +        }
721 +    }
722 +    else
723 +    {
724 +        /* Signal invalid packet received */
725 +        Event_post(radioOperationEventHandle, RADIO_EVENT_INVALID_PACKET_RECEIVED);
726 +    }
727 +}
728 diff -urN ConcentratorRadioTask.h concentrator_new/ConcentratorRadioTask.h
729 --- ConcentratorRadioTask.h     1969-12-31 18:00:00.000000000 -0600
730 +++ concentrator_new/ConcentratorRadioTask.h    2017-07-07 13:15:02.920561400 -0500
731 @@ -0,0 +1,61 @@
732 +/*
733 + * Copyright (c) 2015-2016, Texas Instruments Incorporated
734 + * All rights reserved.
735 + *
736 + * Redistribution and use in source and binary forms, with or without
737 + * modification, are permitted provided that the following conditions
738 + * are met:
739 + *
740 + * *  Redistributions of source code must retain the above copyright
741 + *    notice, this list of conditions and the following disclaimer.
742 + *
743 + * *  Redistributions in binary form must reproduce the above copyright
744 + *    notice, this list of conditions and the following disclaimer in the
745 + *    documentation and/or other materials provided with the distribution.
746 + *
747 + * *  Neither the name of Texas Instruments Incorporated nor the names of
748 + *    its contributors may be used to endorse or promote products derived
749 + *    from this software without specific prior written permission.
750 + *
751 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
752 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
753 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
754 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
755 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
756 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
757 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
758 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
759 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
760 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
761 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
762 + */
764 +#ifndef TASKS_CONCENTRATORRADIOTASKTASK_H_
765 +#define TASKS_CONCENTRATORRADIOTASKTASK_H_
767 +#include "stdint.h"
768 +#include "RadioProtocol.h"
769 +#include "ConcentratorGPS.h"
771 +enum ConcentratorRadioOperationStatus {
772 +    ConcentratorRadioStatus_Success,
773 +    ConcentratorRadioStatus_Failed,
774 +    ConcentratorRadioStatus_FailedNotConnected,
775 +};
777 +union ConcentratorPacket {
778 +    struct PacketHeader header;
779 +    struct gpsSensorPacket_s gpsSensorPacket;
780 +    struct AdcSensorPacket adcSensorPacket;
781 +    struct DualModeSensorPacket dmSensorPacket;
782 +};
784 +typedef void (*ConcentratorRadio_PacketReceivedCallback)(union ConcentratorPacket* packet, int8_t rssi);
786 +/* Create the ConcentratorRadioTask and creates all TI-RTOS objects */
787 +void ConcentratorRadioTask_init(void);
789 +/* Register the packet received callback */
790 +void ConcentratorRadioTask_registerPacketReceivedCallback(ConcentratorRadio_PacketReceivedCallback callback);
792 +#endif /* TASKS_CONCENTRATORRADIOTASKTASK_H_ */
793 diff -urN ConcentratorTask.c concentrator_new/ConcentratorTask.c
794 --- ConcentratorTask.c  1969-12-31 18:00:00.000000000 -0600
795 +++ concentrator_new/ConcentratorTask.c 2017-07-07 13:15:02.950561400 -0500
796 @@ -0,0 +1,298 @@
797 +/*
798 + * Copyright (c) 2015-2016, Texas Instruments Incorporated
799 + * All rights reserved.
800 + *
801 + * Redistribution and use in source and binary forms, with or without
802 + * modification, are permitted provided that the following conditions
803 + * are met:
804 + *
805 + * *  Redistributions of source code must retain the above copyright
806 + *    notice, this list of conditions and the following disclaimer.
807 + *
808 + * *  Redistributions in binary form must reproduce the above copyright
809 + *    notice, this list of conditions and the following disclaimer in the
810 + *    documentation and/or other materials provided with the distribution.
811 + *
812 + * *  Neither the name of Texas Instruments Incorporated nor the names of
813 + *    its contributors may be used to endorse or promote products derived
814 + *    from this software without specific prior written permission.
815 + *
816 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
817 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
818 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
819 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
820 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
821 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
822 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
823 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
824 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
825 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
826 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
827 + */
829 +/***** Includes *****/
831 +#include <xdc/std.h>
832 +#include <xdc/runtime/System.h>
834 +#include <ti/sysbios/BIOS.h>
836 +#include <ti/sysbios/knl/Task.h>
837 +#include <ti/sysbios/knl/Semaphore.h>
838 +#include <ti/sysbios/knl/Event.h>
840 +/* Drivers */
841 +#include <ti/drivers/PIN.h>
842 +#include <ti/display/Display.h>
843 +#include <ti/display/DisplayExt.h>
845 +/* Board Header files */
846 +#include "Board.h"
848 +#include "ConcentratorRadioTask.h"
849 +#include "ConcentratorTask.h"
850 +#include "RadioProtocol.h"
852 +#include "ConcentratorGPS.h"
854 +/***** Defines *****/
855 +#define CONCENTRATOR_TASK_STACK_SIZE 1024
856 +#define CONCENTRATOR_TASK_PRIORITY   3
858 +#define CONCENTRATOR_EVENT_ALL                         0xFFFFFFFF
859 +#define CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE    (uint32_t)(1 << 0)
860 +#define CONCENTRATOR_EVENT_NEW_GPS_SENSOR_VALUE     (uint32_t)(1 << 1)
862 +#define CONCENTRATOR_DISPLAY_LINES 8
864 +/***** Type declarations *****/
865 +struct AdcSensorNode {
866 +    uint8_t address;
867 +    uint16_t latestAdcValue;
868 +    uint8_t button;
869 +    int8_t latestRssi;
870 +};
872 +/***** Variable declarations *****/
873 +static Task_Params concentratorTaskParams;
874 +Task_Struct concentratorTask;    /* not static so you can see in ROV */
875 +static uint8_t concentratorTaskStack[CONCENTRATOR_TASK_STACK_SIZE];
876 +Event_Struct concentratorEvent;  /* not static so you can see in ROV */
877 +static Event_Handle concentratorEventHandle;
878 +static struct AdcSensorNode latestActiveAdcSensorNode;
879 +struct AdcSensorNode knownSensorNodes[CONCENTRATOR_MAX_NODES];
880 +static struct AdcSensorNode* lastAddedSensorNode = knownSensorNodes;
881 +static Display_Handle hDisplayLcd;
882 +static Display_Handle hDisplaySerial;
884 +struct gpsSensorNode latestActiveGpsSensorNode;
885 +struct gpsSensorNode knownGpsSensorNodes[CONCENTRATOR_MAX_NODES];
886 +struct gpsSensorNode* lastAddedGpsSensorNode = knownGpsSensorNodes;
889 +/***** Prototypes *****/
890 +static void concentratorTaskFunction(UArg arg0, UArg arg1);
891 +static void packetReceivedCallback(union ConcentratorPacket* packet, int8_t rssi);
892 +static void updateLcd(void);
893 +static void addNewNode(struct AdcSensorNode* node);
894 +static void updateNode(struct AdcSensorNode* node);
895 +static uint8_t isKnownNodeAddress(uint8_t address);
897 +/***** Function definitions *****/
898 +void ConcentratorTask_init(void) {
900 +    /* Create event used internally for state changes */
901 +    Event_Params eventParam;
902 +    Event_Params_init(&eventParam);
903 +    Event_construct(&concentratorEvent, &eventParam);
904 +    concentratorEventHandle = Event_handle(&concentratorEvent);
906 +    /* Create the concentrator radio protocol task */
907 +    Task_Params_init(&concentratorTaskParams);
908 +    concentratorTaskParams.stackSize = CONCENTRATOR_TASK_STACK_SIZE;
909 +    concentratorTaskParams.priority = CONCENTRATOR_TASK_PRIORITY;
910 +    concentratorTaskParams.stack = &concentratorTaskStack;
911 +    Task_construct(&concentratorTask, concentratorTaskFunction, &concentratorTaskParams, NULL);
913 +    gpsUartInit();
914 +}
916 +static void concentratorTaskFunction(UArg arg0, UArg arg1)
917 +{
918 +    /* Initialize display and try to open both UART and LCD types of display. */
919 +    Display_Params params;
920 +    Display_Params_init(&params);
921 +    params.lineClearMode = DISPLAY_CLEAR_BOTH;
923 +    /* Open both an available LCD display and an UART display.
924 +     * Whether the open call is successful depends on what is present in the
925 +     * Display_config[] array of the board file.
926 +     *
927 +     * Note that for SensorTag evaluation boards combined with the SHARP96x96
928 +     * Watch DevPack, there is a pin conflict with UART such that one must be
929 +     * excluded, and UART is preferred by default. To display on the Watch
930 +     * DevPack, add the precompiler define BOARD_DISPLAY_EXCLUDE_UART.
931 +     */
932 +    hDisplayLcd = Display_open(Display_Type_LCD, &params);
933 +    hDisplaySerial = Display_open(Display_Type_UART, &params);
935 +    /* Check if the selected Display type was found and successfully opened */
936 +    if (hDisplaySerial)
937 +    {
938 +        Display_printf(hDisplaySerial, 0, 0, "Waiting for nodes...");
939 +    }
941 +    /* Check if the selected Display type was found and successfully opened */
942 +    if (hDisplayLcd)
943 +    {
944 +        Display_printf(hDisplayLcd, 0, 0, "Waiting for nodes...");
945 +    }
947 +    /* Register a packet received callback with the radio task */
948 +    ConcentratorRadioTask_registerPacketReceivedCallback(packetReceivedCallback);
950 +    /* Enter main task loop */
951 +    while(1) {
952 +        /* Wait for event */
953 +        uint32_t events = Event_pend(concentratorEventHandle, 0, CONCENTRATOR_EVENT_ALL, BIOS_WAIT_FOREVER);
955 +        /* If we got a new ADC sensor value */
956 +        if(events & CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE) {
957 +            /* If we knew this node from before, update the value */
958 +            if(isKnownNodeAddress(latestActiveAdcSensorNode.address)) {
959 +                updateNode(&latestActiveAdcSensorNode);
960 +            }
961 +            else {
962 +                /* Else add it */
963 +                addNewNode(&latestActiveAdcSensorNode);
964 +            }
966 +            /* Update the values on the LCD */
967 +            updateLcd();
968 +        }
970 +        /* If we got a new ADC sensor value */
971 +        if(events & CONCENTRATOR_EVENT_NEW_GPS_SENSOR_VALUE) {
972 +            /* If we knew this node from before, update the value */
973 +            if(isKnownNodeAddress(latestActiveGpsSensorNode.address)) {
974 +                updateGpsNode(&latestActiveGpsSensorNode);
975 +            }
976 +            else {
977 +                /* Else add it */
978 +                addNewGpsNode(&latestActiveGpsSensorNode);
979 +            }
981 +            /* Update the values on the LCD */
982 +            gpsUpdatePC(&latestActiveGpsSensorNode);
983 +        }
984 +    }
985 +}
987 +static void packetReceivedCallback(union ConcentratorPacket* packet, int8_t rssi)
988 +{
989 +    /* If we recived an ADC sensor packet, for backward compatibility */
990 +    if (packet->header.packetType == RADIO_PACKET_TYPE_ADC_SENSOR_PACKET)
991 +    {
992 +        /* Save the values */
993 +        latestActiveAdcSensorNode.address = packet->header.sourceAddress;
994 +        latestActiveAdcSensorNode.latestAdcValue = packet->adcSensorPacket.adcValue;
995 +        latestActiveAdcSensorNode.button = 0; //no button value in ADC packet
996 +        latestActiveAdcSensorNode.latestRssi = rssi;
998 +        Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE);
999 +    }
1000 +    /* If we recived an DualMode ADC sensor packet*/
1001 +    else if(packet->header.packetType == RADIO_PACKET_TYPE_DM_SENSOR_PACKET)
1002 +    {
1004 +        /* Save the values */
1005 +        latestActiveAdcSensorNode.address = packet->header.sourceAddress;
1006 +        latestActiveAdcSensorNode.latestAdcValue = packet->dmSensorPacket.adcValue;
1007 +        latestActiveAdcSensorNode.button = packet->dmSensorPacket.button;
1008 +        latestActiveAdcSensorNode.latestRssi = rssi;
1010 +        Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_ADC_SENSOR_VALUE);
1011 +    }
1012 +    else if(packet->header.packetType == RADIO_PACKET_TYPE_GPS_SENSOR_PACKET)
1013 +    {
1015 +        /* Save the values */
1016 +        latestActiveGpsSensorNode.address = packet->header.sourceAddress;
1017 +        latestActiveGpsSensorNode.gpsData = packet->gpsSensorPacket.gpsData;
1018 +        latestActiveGpsSensorNode.latestRssi = rssi;
1020 +        Event_post(concentratorEventHandle, CONCENTRATOR_EVENT_NEW_GPS_SENSOR_VALUE);
1021 +    }
1022 +}
1024 +static uint8_t isKnownNodeAddress(uint8_t address) {
1025 +    uint8_t found = 0;
1026 +    uint8_t i;
1027 +    for (i = 0; i < CONCENTRATOR_MAX_NODES; i++)
1028 +    {
1029 +        if (knownSensorNodes[i].address == address)
1030 +        {
1031 +            found = 1;
1032 +            break;
1033 +        }
1034 +    }
1035 +    return found;
1036 +}
1038 +static void updateNode(struct AdcSensorNode* node) {
1039 +    uint8_t i;
1040 +    for (i = 0; i < CONCENTRATOR_MAX_NODES; i++) {
1041 +        if (knownSensorNodes[i].address == node->address)
1042 +        {
1043 +            knownSensorNodes[i].latestAdcValue = node->latestAdcValue;
1044 +            knownSensorNodes[i].latestRssi = node->latestRssi;
1045 +            knownSensorNodes[i].button = node->button;
1046 +            break;
1047 +        }
1048 +    }
1049 +}
1051 +static void addNewNode(struct AdcSensorNode* node) {
1052 +    *lastAddedSensorNode = *node;
1054 +    /* Increment and wrap */
1055 +    lastAddedSensorNode++;
1056 +    if (lastAddedSensorNode > &knownSensorNodes[CONCENTRATOR_MAX_NODES-1])
1057 +    {
1058 +        lastAddedSensorNode = knownSensorNodes;
1059 +    }
1060 +}
1062 +static void updateLcd(void) {
1063 +    struct AdcSensorNode* nodePointer = knownSensorNodes;
1064 +    uint8_t currentLcdLine;
1066 +    /* Clear the display and write header on first line */
1067 +    Display_clear(hDisplayLcd);
1068 +    Display_printf(hDisplayLcd, 0, 0, "Nodes Value SW  RSSI");
1070 +    //clear screen, put cuser to beggining of terminal and print the header
1071 +    Display_printf(hDisplaySerial, 0, 0, "\033[2J \033[0;0HNodes   Value   SW    RSSI");
1073 +    /* Start on the second line */
1074 +    currentLcdLine = 1;
1076 +    /* Write one line per node */
1077 +    while ((nodePointer < &knownSensorNodes[CONCENTRATOR_MAX_NODES]) &&
1078 +          (nodePointer->address != 0) &&
1079 +          (currentLcdLine < CONCENTRATOR_DISPLAY_LINES))
1080 +    {
1081 +        /* print to LCD */
1082 +        Display_printf(hDisplayLcd, currentLcdLine, 0, "0x%02x  %04d  %d   %04d",
1083 +                nodePointer->address, nodePointer->latestAdcValue, nodePointer->button,
1084 +                nodePointer->latestRssi);
1086 +        /* print to UART */
1087 +        Display_printf(hDisplaySerial, 0, 0, "0x%02x    %04d    %d    %04d",
1088 +                nodePointer->address, nodePointer->latestAdcValue, nodePointer->button,
1089 +                nodePointer->latestRssi);
1091 +        nodePointer++;
1092 +        currentLcdLine++;
1093 +    }
1094 +}
1095 diff -urN ConcentratorTask.h concentrator_new/ConcentratorTask.h
1096 --- ConcentratorTask.h  1969-12-31 18:00:00.000000000 -0600
1097 +++ concentrator_new/ConcentratorTask.h 2017-07-07 13:15:02.978061400 -0500
1098 @@ -0,0 +1,41 @@
1099 +/*
1100 + * Copyright (c) 2015, Texas Instruments Incorporated
1101 + * All rights reserved.
1102 + *
1103 + * Redistribution and use in source and binary forms, with or without
1104 + * modification, are permitted provided that the following conditions
1105 + * are met:
1106 + *
1107 + * *  Redistributions of source code must retain the above copyright
1108 + *    notice, this list of conditions and the following disclaimer.
1109 + *
1110 + * *  Redistributions in binary form must reproduce the above copyright
1111 + *    notice, this list of conditions and the following disclaimer in the
1112 + *    documentation and/or other materials provided with the distribution.
1113 + *
1114 + * *  Neither the name of Texas Instruments Incorporated nor the names of
1115 + *    its contributors may be used to endorse or promote products derived
1116 + *    from this software without specific prior written permission.
1117 + *
1118 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1119 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1120 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1121 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1122 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1123 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1124 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
1125 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1126 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
1127 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1128 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1129 + */
1131 +#ifndef TASKS_CONCENTRATORTASK_H_
1132 +#define TASKS_CONCENTRATORTASK_H_
1134 +#define CONCENTRATOR_MAX_NODES 7
1136 +/* Create the ConcentratorRadioTask and creates all TI-RTOS objects */
1137 +void ConcentratorTask_init(void);
1139 +#endif /* TASKS_CONCENTRATORTASK_H_ */
1140 diff -urN easylink/EasyLink.c concentrator_new/easylink/EasyLink.c
1141 --- easylink/EasyLink.c 1969-12-31 18:00:00.000000000 -0600
1142 +++ concentrator_new/easylink/EasyLink.c        2017-07-07 13:13:56.457000000 -0500
1143 @@ -0,0 +1,1116 @@
1144 +/*
1145 + * Copyright (c) 2015-2017, Texas Instruments Incorporated
1146 + * All rights reserved.
1147 + *
1148 + * Redistribution and use in source and binary forms, with or without
1149 + * modification, are permitted provided that the following conditions
1150 + * are met:
1151 + *
1152 + * *  Redistributions of source code must retain the above copyright
1153 + *    notice, this list of conditions and the following disclaimer.
1154 + *
1155 + * *  Redistributions in binary form must reproduce the above copyright
1156 + *    notice, this list of conditions and the following disclaimer in the
1157 + *    documentation and/or other materials provided with the distribution.
1158 + *
1159 + * *  Neither the name of Texas Instruments Incorporated nor the names of
1160 + *    its contributors may be used to endorse or promote products derived
1161 + *    from this software without specific prior written permission.
1162 + *
1163 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1164 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1165 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1166 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1167 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1168 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
1169 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
1170 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1171 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
1172 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
1173 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1174 + */
1176 +/***** Includes *****/
1177 +#include "EasyLink.h"
1179 +/* Drivers */
1180 +#include <ti/drivers/rf/RF.h>
1181 +#include "smartrf_settings/smartrf_settings_predefined.h"
1182 +#include "smartrf_settings/smartrf_settings.h"
1184 +#include <ti/sysbios/knl/Semaphore.h>
1185 +#include <xdc/runtime/Error.h>
1186 +#include <ti/sysbios/BIOS.h>
1187 +#include <ti/sysbios/knl/Task.h>
1189 +#ifdef DEVICE_FAMILY
1190 +    #undef DEVICE_FAMILY_PATH
1191 +    #define DEVICE_FAMILY_PATH(x) <ti/devices/DEVICE_FAMILY/x>
1192 +    #include DEVICE_FAMILY_PATH(driverlib/rf_data_entry.h)
1193 +    #include DEVICE_FAMILY_PATH(driverlib/rf_prop_mailbox.h)
1194 +    #include DEVICE_FAMILY_PATH(driverlib/rf_prop_cmd.h)
1195 +    #include DEVICE_FAMILY_PATH(driverlib/chipinfo.h)
1196 +    #include DEVICE_FAMILY_PATH(inc/hw_ccfg.h)
1197 +    #include DEVICE_FAMILY_PATH(inc/hw_ccfg_simple_struct.h)
1198 +#else
1199 +    #error "You must define DEVICE_FAMILY at the project level as one of cc26x0, cc26x0r2, cc13x0, etc."
1200 +#endif
1202 +#include "Board.h"
1204 +union setupCmd_t{
1205 +    rfc_CMD_PROP_RADIO_DIV_SETUP_t divSetup;
1206 +    rfc_CMD_PROP_RADIO_SETUP_t setup;
1207 +};
1209 +#define EASYLINK_MAX_ADDR_SIZE           8
1210 +#define EASYLINK_MAX_ADDR_FILTERS        3
1212 +//Primary IEEE address location
1213 +#define EASYLINK_PRIMARY_IEEE_ADDR_LOCATION   0x500012F0
1214 +//Secondary IEEE address location
1215 +#define EASYLINK_SECONDARY_IEEE_ADDR_LOCATION 0x0001FFC8
1217 +#define EASYLINK_RF_EVENT_MASK  ( RF_EventLastCmdDone | RF_EventCmdError | \
1218 +             RF_EventCmdAborted | RF_EventCmdStopped | RF_EventCmdCancelled )
1220 +#define EASYLINK_RF_CMD_HANDLE_INVALID -1
1222 +#define RF_MODE_MULTIPLE 0x05
1224 +#define EasyLink_CmdHandle_isValid(handle) (handle >= 0)
1226 +/***** Prototypes *****/
1227 +static EasyLink_TxDoneCb txCb;
1228 +static EasyLink_ReceiveCb rxCb;
1230 +/***** Variable declarations *****/
1232 +static RF_Object rfObject;
1233 +static RF_Handle rfHandle;
1235 +//Rx buffer includes data entry structure, hdr (len=1byte), dst addr (max of 8 bytes) and data
1236 +//which must be aligned to 4B
1237 +#if defined(__TI_COMPILER_VERSION__)
1238 +    #pragma DATA_ALIGN (rxBuffer, 4);
1239 +        static uint8_t rxBuffer[sizeof(rfc_dataEntryGeneral_t) + 1 + EASYLINK_MAX_ADDR_SIZE + EASYLINK_MAX_DATA_LENGTH];
1240 +#elif defined(__IAR_SYSTEMS_ICC__)
1241 +    #pragma data_alignment = 4
1242 +        static uint8_t rxBuffer[sizeof(rfc_dataEntryGeneral_t) + 1 + EASYLINK_MAX_ADDR_SIZE + EASYLINK_MAX_DATA_LENGTH];
1243 +#elif defined(__GNUC__)
1244 +        static uint8_t rxBuffer[sizeof(rfc_dataEntryGeneral_t) + 1 + EASYLINK_MAX_ADDR_SIZE + EASYLINK_MAX_DATA_LENGTH];
1245 +#else
1246 +    #error This compiler is not supported.
1247 +#endif
1249 +static dataQueue_t dataQueue;
1250 +static rfc_propRxOutput_t rxStatistics;
1252 +//Tx buffer includes hdr (len=1byte), dst addr (max of 8 bytes) and data
1253 +static uint8_t txBuffer[1 + EASYLINK_MAX_ADDR_SIZE + EASYLINK_MAX_DATA_LENGTH];
1255 +//Addr size for Filter and Tx/Rx operations
1256 +//Set default to 1 byte addr to work with SmartRF
1257 +//studio default settings
1258 +static uint8_t addrSize = 1;
1260 +//Indicating that the API is initialized
1261 +static uint8_t configured = 0;
1262 +//Indicating that the API suspended
1263 +static uint8_t suspended = 0;
1265 +//RF Params alowing configuration of the inactivity timeout, which is the time
1266 +//it takes for the radio to shut down when there are no commands in the queue
1267 +static RF_Params rfParams;
1268 +static bool rfParamsConfigured = 0;
1270 +//Flag used to indicate the muli client operation is enabled
1271 +static bool rfModeMultiClient = false;
1273 +//Async Rx timeout value
1274 +static uint32_t asyncRxTimeOut = 0;
1276 +//local commands, contents will be defined by modulation type
1277 +static union setupCmd_t EasyLink_cmdPropRadioSetup;
1278 +static rfc_CMD_FS_t EasyLink_cmdFs;
1279 +static RF_Mode EasyLink_RF_prop;
1280 +static rfc_CMD_PROP_TX_t EasyLink_cmdPropTx;
1281 +static rfc_CMD_PROP_RX_ADV_t EasyLink_cmdPropRxAdv;
1283 +// The table for setting the Rx Address Filters
1284 +static uint8_t addrFilterTable[EASYLINK_MAX_ADDR_FILTERS * EASYLINK_MAX_ADDR_SIZE] = {0xaa};
1286 +//Mutex for locking the RF driver resource
1287 +static Semaphore_Handle busyMutex;
1289 +//Handle for last Async command, which is needed by EasyLink_abort
1290 +static RF_CmdHandle asyncCmdHndl = EASYLINK_RF_CMD_HANDLE_INVALID;
1292 +//Callback for Async Tx complete
1293 +static void txDoneCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
1294 +{
1295 +    EasyLink_Status status;
1297 +    //Release now so user callback can call EasyLink API's
1298 +    Semaphore_post(busyMutex);
1299 +    asyncCmdHndl = EASYLINK_RF_CMD_HANDLE_INVALID;
1301 +    if (e & RF_EventLastCmdDone)
1302 +    {
1303 +        status = EasyLink_Status_Success;
1304 +    }
1305 +    else if ( (e & RF_EventCmdAborted) || (e & RF_EventCmdCancelled ) )
1306 +    {
1307 +        status = EasyLink_Status_Aborted;
1308 +    }
1309 +    else
1310 +    {
1311 +        status = EasyLink_Status_Tx_Error;
1312 +    }
1314 +    if (txCb != NULL)
1315 +    {
1316 +        txCb(status);
1317 +    }
1318 +}
1320 +//Callback for Async Rx complete
1321 +static void rxDoneCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
1322 +{
1323 +    EasyLink_Status status = EasyLink_Status_Rx_Error;
1324 +    //create rxPacket as a static so that the large payload buffer it is not
1325 +    //allocated from the stack
1326 +    static EasyLink_RxPacket rxPacket;
1327 +    rfc_dataEntryGeneral_t *pDataEntry;
1328 +    pDataEntry = (rfc_dataEntryGeneral_t*) rxBuffer;
1330 +    //Release now so user callback can call EasyLink API's
1331 +    Semaphore_post(busyMutex);
1332 +    asyncCmdHndl = EASYLINK_RF_CMD_HANDLE_INVALID;
1334 +    if (e & RF_EventLastCmdDone)
1335 +    {
1336 +        //Check command status
1337 +        if (EasyLink_cmdPropRxAdv.status == PROP_DONE_OK)
1338 +        {
1339 +            //Check that data entry status indicates it is finished with
1340 +            if (pDataEntry->status != DATA_ENTRY_FINISHED)
1341 +            {
1342 +                status = EasyLink_Status_Rx_Error;
1343 +            }
1344 +            else if ( (rxStatistics.nRxOk == 1) ||
1345 +                     //or filer disabled and ignore due to addr mistmatch
1346 +                     ((EasyLink_cmdPropRxAdv.pktConf.filterOp == 1) &&
1347 +                      (rxStatistics.nRxIgnored == 1)) )
1348 +            {
1349 +                //copy length from pDataEntry
1350 +                rxPacket.len = *(uint8_t*)(&pDataEntry->data) - addrSize;
1351 +                //copy address from packet payload (as it is not in hdr)
1352 +                memcpy(&rxPacket.dstAddr, (&pDataEntry->data + 1), addrSize);
1353 +                //copy payload
1354 +                memcpy(&rxPacket.payload, (&pDataEntry->data + 1 + addrSize), rxPacket.len);
1355 +                rxPacket.rssi = rxStatistics.lastRssi;
1356 +                rxPacket.absTime = rxStatistics.timeStamp;
1358 +                status = EasyLink_Status_Success;
1359 +            }
1360 +            else if ( rxStatistics.nRxBufFull == 1)
1361 +            {
1362 +                status = EasyLink_Status_Rx_Buffer_Error;
1363 +            }
1364 +            else if ( rxStatistics.nRxStopped == 1)
1365 +            {
1366 +                status = EasyLink_Status_Aborted;
1367 +            }
1368 +            else
1369 +            {
1370 +                status = EasyLink_Status_Rx_Error;
1371 +            }
1372 +        }
1373 +        else if ( EasyLink_cmdPropRxAdv.status == PROP_DONE_RXTIMEOUT)
1374 +        {
1375 +            status = EasyLink_Status_Rx_Timeout;
1376 +        }
1377 +        else
1378 +        {
1379 +            status = EasyLink_Status_Rx_Error;
1380 +        }
1381 +    }
1382 +    else if ( (e == RF_EventCmdAborted) || e == RF_EventCmdStopped )
1383 +    {
1384 +        status = EasyLink_Status_Aborted;
1385 +    }
1387 +    if (rxCb != NULL)
1388 +    {
1389 +        rxCb(&rxPacket, status);
1390 +    }
1391 +}
1393 +//Callback for Async TX Test mode
1394 +static void asyncCmdCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
1395 +{
1396 +    Semaphore_post(busyMutex);
1397 +    asyncCmdHndl = EASYLINK_RF_CMD_HANDLE_INVALID;
1398 +}
1400 +static EasyLink_Status enableTestMode(EasyLink_CtrlOption mode)
1401 +{
1402 +    EasyLink_Status status = EasyLink_Status_Cmd_Error;
1403 +    //This needs to be static as it is used by the RF driver and Modem after
1404 +    //this function exits
1405 +    static rfc_CMD_TX_TEST_t txTestCmd = {0};
1407 +    if ( (!configured) || suspended)
1408 +    {
1409 +        return EasyLink_Status_Config_Error;
1410 +    }
1411 +    if ( (mode != EasyLink_Ctrl_Test_Tone) &&
1412 +        (mode != EasyLink_Ctrl_Test_Signal) )
1413 +    {
1414 +        return EasyLink_Status_Param_Error;
1415 +    }
1416 +    //Check and take the busyMutex
1417 +    if ( (Semaphore_pend(busyMutex, 0) == FALSE) || (EasyLink_CmdHandle_isValid(asyncCmdHndl)) )
1418 +    {
1419 +        return EasyLink_Status_Busy_Error;
1420 +    }
1422 +    txTestCmd.commandNo = CMD_TX_TEST;
1423 +    txTestCmd.startTrigger.triggerType = TRIG_NOW;
1424 +    txTestCmd.startTrigger.pastTrig = 1;
1425 +    txTestCmd.startTime = 0;
1427 +    txTestCmd.config.bFsOff = 1;
1428 +    txTestCmd.syncWord = EasyLink_cmdPropTx.syncWord;
1429 +    txTestCmd.config.whitenMode = EasyLink_cmdPropRadioSetup.setup.formatConf.whitenMode;
1431 +    //set tone (unmodulated) or signal (modulated)
1432 +    if (mode == EasyLink_Ctrl_Test_Tone)
1433 +    {
1434 +        txTestCmd.config.bUseCw = 1;
1435 +    }
1436 +    else
1437 +    {
1438 +        txTestCmd.config.bUseCw = 0;
1439 +    }
1441 +    //generate continuous test signal
1442 +    txTestCmd.endTrigger.triggerType = TRIG_NEVER;
1444 +    /* Post command and store Cmd Handle for future abort */
1445 +    asyncCmdHndl = RF_postCmd(rfHandle, (RF_Op*)&txTestCmd, RF_PriorityNormal,
1446 +            asyncCmdCallback, EASYLINK_RF_EVENT_MASK);
1448 +    /* Has command completed? */
1449 +    uint16_t count = 0;
1450 +    while (txTestCmd.status != ACTIVE)
1451 +    {
1452 +        //The command did not complete as fast as expected, sleep for 10ms
1453 +        Task_sleep(10000 / Clock_tickPeriod);
1455 +        if (count++ > 500)
1456 +        {
1457 +            //Should not get here, if we did Something went wrong with the
1458 +            //the RF Driver, get out of here and return an error.
1459 +            //The next command will likely lock up.
1460 +            break;
1461 +        }
1462 +    }
1464 +    if (txTestCmd.status == ACTIVE)
1465 +    {
1466 +        status = EasyLink_Status_Success;
1467 +    }
1469 +    return status;
1470 +}
1472 +EasyLink_Status EasyLink_init(EasyLink_PhyType ui32ModType)
1473 +{
1474 +    if (configured)
1475 +    {
1476 +        //Already configure, check and take the busyMutex
1477 +        if (Semaphore_pend(busyMutex, 0) == FALSE)
1478 +        {
1479 +            return EasyLink_Status_Busy_Error;
1480 +        }
1481 +        RF_close(rfHandle);
1482 +    }
1484 +    if (!rfParamsConfigured)
1485 +    {
1486 +        RF_Params_init(&rfParams);
1487 +        //set default InactivityTimeout to 1000us
1488 +        rfParams.nInactivityTimeout = EasyLink_ms_To_RadioTime(1);
1489 +        rfParamsConfigured = 1;
1490 +    }
1492 +    if (ui32ModType == EasyLink_Phy_Custom)
1493 +    {
1494 +        if(ChipInfo_GetChipType() == CHIP_TYPE_CC2650)
1495 +        {
1496 +            memcpy(&EasyLink_cmdPropRadioSetup.setup, &RF_cmdPropRadioDivSetup, sizeof(rfc_CMD_PROP_RADIO_SETUP_t));
1497 +        }
1498 +        else
1499 +        {
1500 +            memcpy(&EasyLink_cmdPropRadioSetup.divSetup, &RF_cmdPropRadioDivSetup, sizeof(rfc_CMD_PROP_RADIO_DIV_SETUP_t));
1501 +        }
1502 +        memcpy(&EasyLink_cmdFs, &RF_cmdFs, sizeof(rfc_CMD_FS_t));
1503 +        memcpy(&EasyLink_RF_prop, &RF_prop, sizeof(RF_Mode));
1504 +        memcpy(&EasyLink_cmdPropRxAdv, RF_pCmdPropRxAdv_preDef, sizeof(rfc_CMD_PROP_RX_ADV_t));
1505 +        memcpy(&EasyLink_cmdPropTx, &RF_cmdPropTx, sizeof(rfc_CMD_PROP_TX_t));
1506 +    }
1507 +    else if ( (ui32ModType == EasyLink_Phy_50kbps2gfsk) && (ChipInfo_GetChipType() != CHIP_TYPE_CC2650) )
1508 +    {
1509 +        memcpy(&EasyLink_cmdPropRadioSetup.divSetup,
1510 +                RF_pCmdPropRadioDivSetup_fsk,
1511 +                sizeof(rfc_CMD_PROP_RADIO_DIV_SETUP_t));
1512 +        memcpy(&EasyLink_cmdFs, RF_pCmdFs_preDef, sizeof(rfc_CMD_FS_t));
1513 +        memcpy(&EasyLink_RF_prop, RF_pProp_fsk, sizeof(RF_Mode));
1514 +        memcpy(&EasyLink_cmdPropRxAdv, RF_pCmdPropRxAdv_preDef, sizeof(rfc_CMD_PROP_RX_ADV_t));
1515 +        memcpy(&EasyLink_cmdPropTx, RF_pCmdPropTx_preDef, sizeof(rfc_CMD_PROP_TX_t));
1516 +    }
1517 +    else if ( (ui32ModType == EasyLink_Phy_625bpsLrm) && (ChipInfo_GetChipType() != CHIP_TYPE_CC2650) )
1518 +    {
1519 +        memcpy(&EasyLink_cmdPropRadioSetup.divSetup,
1520 +                RF_pCmdPropRadioDivSetup_lrm,
1521 +                sizeof(rfc_CMD_PROP_RADIO_DIV_SETUP_t));
1522 +        memcpy(&EasyLink_cmdFs, RF_pCmdFs_preDef, sizeof(rfc_CMD_FS_t));
1523 +        memcpy(&EasyLink_RF_prop, RF_pProp_lrm, sizeof(RF_Mode));
1524 +        memcpy(&EasyLink_cmdPropRxAdv, RF_pCmdPropRxAdv_preDef, sizeof(rfc_CMD_PROP_RX_ADV_t));
1525 +        memcpy(&EasyLink_cmdPropTx, RF_pCmdPropTx_preDef, sizeof(rfc_CMD_PROP_TX_t));
1526 +    }
1527 +    else if ( (ui32ModType == EasyLink_Phy_2_4_200kbps2gfsk) && (ChipInfo_GetChipType() == CHIP_TYPE_CC2650) )
1528 +    {
1529 +        memcpy(&EasyLink_cmdPropRadioSetup.setup,
1530 +                RF_pCmdPropRadioSetup_2_4G_fsk,
1531 +                sizeof(rfc_CMD_PROP_RADIO_SETUP_t));
1532 +        memcpy(&EasyLink_cmdFs, RF_pCmdFs_preDef, sizeof(rfc_CMD_FS_t));
1533 +        memcpy(&EasyLink_RF_prop, RF_pProp_2_4G_fsk, sizeof(RF_Mode));
1534 +        memcpy(&EasyLink_cmdPropRxAdv, RF_pCmdPropRxAdv_preDef, sizeof(rfc_CMD_PROP_RX_ADV_t));
1535 +        memcpy(&EasyLink_cmdPropTx, RF_pCmdPropTx_preDef, sizeof(rfc_CMD_PROP_TX_t));
1536 +    }
1538 +    else if ( (ui32ModType == EasyLink_Phy_5kbpsSlLr) && (ChipInfo_GetChipType() != CHIP_TYPE_CC2650) )
1539 +    {
1540 +        memcpy(&EasyLink_cmdPropRadioSetup.setup,
1541 +                RF_pCmdPropRadioDivSetup_sl_lr,
1542 +                sizeof(rfc_CMD_PROP_RADIO_DIV_SETUP_t));
1543 +        memcpy(&EasyLink_cmdFs, RF_pCmdFs_preDef, sizeof(rfc_CMD_FS_t));
1544 +        memcpy(&EasyLink_RF_prop, RF_pProp_sl_lr, sizeof(RF_Mode));
1545 +        memcpy(&EasyLink_cmdPropRxAdv, RF_pCmdPropRxAdv_preDef, sizeof(rfc_CMD_PROP_RX_ADV_t));
1546 +        memcpy(&EasyLink_cmdPropTx, RF_pCmdPropTx_preDef, sizeof(rfc_CMD_PROP_TX_t));
1547 +    }
1548 +    else
1549 +    {
1550 +        if (busyMutex != NULL)
1551 +        {
1552 +            Semaphore_post(busyMutex);
1553 +        }
1554 +        return EasyLink_Status_Param_Error;
1555 +    }
1557 +    if (rfModeMultiClient)
1558 +    {
1559 +        EasyLink_RF_prop.rfMode = RF_MODE_MULTIPLE;
1560 +    }
1562 +    /* Request access to the radio */
1563 +    rfHandle = RF_open(&rfObject, &EasyLink_RF_prop,
1564 +            (RF_RadioSetup*)&EasyLink_cmdPropRadioSetup.setup, &rfParams);
1566 +    //Set Rx packet size, taking into account addr which is not in the hdr
1567 +    //(only length can be)
1568 +    EasyLink_cmdPropRxAdv.maxPktLen = EASYLINK_MAX_DATA_LENGTH +
1569 +            EASYLINK_MAX_ADDR_SIZE;
1570 +    EasyLink_cmdPropRxAdv.pAddr = addrFilterTable;
1571 +    addrSize = 1;
1572 +    EasyLink_cmdPropRxAdv.addrConf.addrSize = addrSize; //Set addr size to the
1573 +                                                        //default
1574 +    EasyLink_cmdPropRxAdv.pktConf.filterOp = 1;  // Disable Addr filter by
1575 +                                                 //default
1576 +    EasyLink_cmdPropRxAdv.pQueue = &dataQueue;   // Set the Data Entity queue
1577 +                                                 // for received data
1578 +    EasyLink_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
1580 +    //Set the frequency
1581 +    RF_runCmd(rfHandle, (RF_Op*)&EasyLink_cmdFs, RF_PriorityNormal, 0, //asyncCmdCallback,
1582 +            EASYLINK_RF_EVENT_MASK);
1584 +    //set default asyncRxTimeOut to 0
1585 +    asyncRxTimeOut = 0;
1587 +    //Create a semaphore for blocking commands
1588 +    Semaphore_Params params;
1589 +    Error_Block eb;
1591 +    // init params
1592 +    Semaphore_Params_init(&params);
1593 +    Error_init(&eb);
1595 +    // create semaphore instance if not already created
1596 +    if (busyMutex == NULL)
1597 +    {
1598 +        busyMutex = Semaphore_create(0, &params, &eb);
1599 +        if (busyMutex == NULL)
1600 +        {
1601 +            return EasyLink_Status_Mem_Error;
1602 +        }
1604 +        Semaphore_post(busyMutex);
1605 +    }
1606 +    else
1607 +    {
1608 +        //already configured and taken busyMutex, so release it
1609 +        Semaphore_post(busyMutex);
1610 +    }
1612 +    configured = 1;
1614 +    return EasyLink_Status_Success;
1615 +}
1617 +EasyLink_Status EasyLink_setFrequency(uint32_t ui32Freq)
1618 +{
1619 +    EasyLink_Status status = EasyLink_Status_Cmd_Error;
1620 +    //uint64_t ui64FractFreq;
1622 +    if ( (!configured) || suspended)
1623 +    {
1624 +        return EasyLink_Status_Config_Error;
1625 +    }
1626 +    //Check and take the busyMutex
1627 +    if (Semaphore_pend(busyMutex, 0) == FALSE)
1628 +    {
1629 +        return EasyLink_Status_Busy_Error;
1630 +    }
1632 +    /* Set the frequency */
1633 +    EasyLink_cmdFs.frequency = (uint16_t)(ui32Freq / 1000000);
1634 +    EasyLink_cmdFs.fractFreq = (uint16_t) (((uint64_t)ui32Freq -
1635 +            ((uint64_t)EasyLink_cmdFs.frequency * 1000000)) * 65536 / 1000000);
1637 +    /* Run command */
1638 +    RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&EasyLink_cmdFs,
1639 +            RF_PriorityNormal, 0, EASYLINK_RF_EVENT_MASK);
1641 +    if (result & RF_EventLastCmdDone)
1642 +    {
1643 +        status = EasyLink_Status_Success;
1644 +    }
1646 +    Semaphore_post(busyMutex);
1648 +    return status;
1649 +}
1651 +uint32_t EasyLink_getFrequency(void)
1652 +{
1653 +    uint32_t freq_khz;
1655 +    if ( (!configured) || suspended)
1656 +    {
1657 +        return EasyLink_Status_Config_Error;
1658 +    }
1660 +    freq_khz = EasyLink_cmdFs.frequency * 1000000;
1661 +    freq_khz += ((((uint64_t)EasyLink_cmdFs.fractFreq * 1000000)) / 65536);
1663 +    return freq_khz;
1664 +}
1666 +EasyLink_Status EasyLink_setRfPwr(int8_t i8txPowerdBm)
1667 +{
1668 +    EasyLink_Status status = EasyLink_Status_Cmd_Error;
1669 +    rfc_CMD_SCH_IMM_t immOpCmd = {0};
1670 +    rfc_CMD_SET_TX_POWER_t cmdSetPower = {0};
1671 +    uint8_t txPowerIdx;
1673 +    if ( (!configured) || suspended)
1674 +    {
1675 +        return EasyLink_Status_Config_Error;
1676 +    }
1677 +    //Check and take the busyMutex
1678 +    if (Semaphore_pend(busyMutex, 0) == FALSE)
1679 +    {
1680 +        return EasyLink_Status_Busy_Error;
1681 +    }
1683 +    immOpCmd.commandNo = CMD_SCH_IMM;
1684 +    immOpCmd.startTrigger.triggerType = TRIG_NOW;
1685 +    immOpCmd.startTrigger.pastTrig = 1;
1686 +    immOpCmd.startTime = 0;
1688 +    cmdSetPower.commandNo = CMD_SET_TX_POWER;
1690 +    if (i8txPowerdBm < rfPowerTable[0].dbm)
1691 +    {
1692 +        i8txPowerdBm = rfPowerTable[0].dbm;
1693 +    }
1694 +    else if (i8txPowerdBm > rfPowerTable[rfPowerTableSize-1].dbm )
1695 +    {
1696 +        i8txPowerdBm = rfPowerTable[rfPowerTableSize-1].dbm;
1697 +    }
1699 +    //if max power is requested then the CCFG_FORCE_VDDR_HH must be set in
1700 +    //the ccfg
1701 +#if (CCFG_FORCE_VDDR_HH != 0x1)
1702 +    if (i8txPowerdBm == rfPowerTable[rfPowerTableSize-1].dbm)
1703 +    {
1704 +        //Release the busyMutex
1705 +        Semaphore_post(busyMutex);
1706 +        return EasyLink_Status_Config_Error;
1707 +    }
1708 +#endif
1710 +    for (txPowerIdx = 0;
1711 +            txPowerIdx < rfPowerTableSize;
1712 +            txPowerIdx++)
1713 +    {
1714 +        if (i8txPowerdBm >= rfPowerTable[txPowerIdx].dbm)
1715 +        {
1716 +            cmdSetPower.txPower = rfPowerTable[txPowerIdx].txPower;
1717 +            EasyLink_cmdPropRadioSetup.setup.txPower = rfPowerTable[txPowerIdx].txPower;
1718 +        }
1719 +    }
1721 +    //point the Operational Command to the immediate set power command
1722 +    immOpCmd.cmdrVal = (uint32_t) &cmdSetPower;
1724 +    // Send command
1725 +    RF_CmdHandle cmd = RF_postCmd(rfHandle, (RF_Op*)&immOpCmd,
1726 +            RF_PriorityNormal, 0, EASYLINK_RF_EVENT_MASK);
1728 +    RF_EventMask result = RF_pendCmd(rfHandle, cmd,  (RF_EventLastCmdDone |
1729 +            RF_EventCmdError));
1731 +    if (result & RF_EventLastCmdDone)
1732 +    {
1733 +        status = EasyLink_Status_Success;
1734 +    }
1736 +    //Release the busyMutex
1737 +    Semaphore_post(busyMutex);
1739 +    return status;
1740 +}
1742 +int8_t EasyLink_getRfPwr(void)
1743 +{
1744 +    uint8_t txPowerIdx;
1745 +    int8_t txPowerdBm = 0xff;
1747 +    if ( (!configured) || suspended)
1748 +    {
1749 +        return EasyLink_Status_Config_Error;
1750 +    }
1752 +    for (txPowerIdx = 0;
1753 +            txPowerIdx < rfPowerTableSize;
1754 +            txPowerIdx++)
1755 +    {
1756 +        if (rfPowerTable[txPowerIdx].txPower == EasyLink_cmdPropRadioSetup.setup.txPower)
1757 +        {
1758 +            txPowerdBm = rfPowerTable[txPowerIdx].dbm;
1759 +            continue;
1760 +        }
1761 +    }
1763 +    //if CCFG_FORCE_VDDR_HH is not set max power cannot be achieved
1764 +#if (CCFG_FORCE_VDDR_HH != 0x1)
1765 +    if (txPowerdBm == rfPowerTable[rfPowerTableSize-1].dbm)
1766 +    {
1767 +        txPowerdBm = rfPowerTable[rfPowerTableSize-2].dbm;
1768 +    }
1769 +#endif
1771 +    return txPowerdBm;
1772 +}
1774 +uint32_t EasyLink_getAbsTime(void)
1775 +{
1776 +    if ( (!configured) || suspended)
1777 +    {
1778 +        return EasyLink_Status_Config_Error;
1779 +    }
1781 +    return RF_getCurrentTime();
1782 +}
1784 +EasyLink_Status EasyLink_transmit(EasyLink_TxPacket *txPacket)
1785 +{
1786 +    EasyLink_Status status = EasyLink_Status_Tx_Error;
1788 +    if ( (!configured) || suspended)
1789 +    {
1790 +        return EasyLink_Status_Config_Error;
1791 +    }
1792 +    //Check and take the busyMutex
1793 +    if (Semaphore_pend(busyMutex, 0) == FALSE)
1794 +    {
1795 +        return EasyLink_Status_Busy_Error;
1796 +    }
1797 +    if (txPacket->len > EASYLINK_MAX_DATA_LENGTH)
1798 +    {
1799 +        return EasyLink_Status_Param_Error;
1800 +    }
1802 +    memcpy(txBuffer, txPacket->dstAddr, addrSize);
1803 +    memcpy(txBuffer + addrSize, txPacket->payload, txPacket->len);
1805 +    //packet length to Tx includes address
1806 +    EasyLink_cmdPropTx.pktLen = txPacket->len + addrSize;
1807 +    EasyLink_cmdPropTx.pPkt = txBuffer;
1809 +    if (txPacket->absTime != 0)
1810 +    {
1811 +        EasyLink_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
1812 +        EasyLink_cmdPropTx.startTrigger.pastTrig = 1;
1813 +        EasyLink_cmdPropTx.startTime = txPacket->absTime;
1814 +    }
1815 +    else
1816 +    {
1817 +        EasyLink_cmdPropTx.startTrigger.triggerType = TRIG_NOW;
1818 +        EasyLink_cmdPropTx.startTrigger.pastTrig = 1;
1819 +        EasyLink_cmdPropTx.startTime = 0;
1820 +    }
1822 +    // Send packet
1823 +    RF_CmdHandle cmdHdl = RF_postCmd(rfHandle, (RF_Op*)&EasyLink_cmdPropTx,
1824 +            RF_PriorityNormal, 0, EASYLINK_RF_EVENT_MASK);
1826 +    // Wait for Command to complete
1827 +    RF_EventMask result = RF_pendCmd(rfHandle, cmdHdl,  (RF_EventLastCmdDone |
1828 +            RF_EventCmdError));
1831 +    if (result & RF_EventLastCmdDone)
1832 +    {
1833 +        status = EasyLink_Status_Success;
1834 +    }
1836 +    //Release the busyMutex
1837 +    Semaphore_post(busyMutex);
1840 +    return status;
1841 +}
1843 +EasyLink_Status EasyLink_transmitAsync(EasyLink_TxPacket *txPacket, EasyLink_TxDoneCb cb)
1844 +{
1845 +    EasyLink_Status status = EasyLink_Status_Tx_Error;
1847 +    //Check if not configure or already an Async command being performed
1848 +    if ( (!configured) || suspended)
1849 +    {
1850 +        return EasyLink_Status_Config_Error;
1851 +    }
1852 +    //Check and take the busyMutex
1853 +    if ( (Semaphore_pend(busyMutex, 0) == FALSE) || (EasyLink_CmdHandle_isValid(asyncCmdHndl)) )
1854 +    {
1855 +        return EasyLink_Status_Busy_Error;
1856 +    }
1857 +    if (txPacket->len > EASYLINK_MAX_DATA_LENGTH)
1858 +    {
1859 +        return EasyLink_Status_Param_Error;
1860 +    }
1862 +    //store application callback
1863 +    txCb = cb;
1865 +    memcpy(txBuffer, txPacket->dstAddr, addrSize);
1866 +    memcpy(txBuffer + addrSize, txPacket->payload, txPacket->len);
1868 +    //packet length to Tx includes address
1869 +    EasyLink_cmdPropTx.pktLen = txPacket->len + addrSize;
1870 +    EasyLink_cmdPropTx.pPkt = txBuffer;
1872 +    if (txPacket->absTime != 0)
1873 +    {
1874 +        EasyLink_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
1875 +        EasyLink_cmdPropTx.startTrigger.pastTrig = 1;
1876 +        EasyLink_cmdPropTx.startTime = txPacket->absTime;
1877 +    }
1878 +    else
1879 +    {
1880 +        EasyLink_cmdPropTx.startTrigger.triggerType = TRIG_NOW;
1881 +        EasyLink_cmdPropTx.startTrigger.pastTrig = 1;
1882 +        EasyLink_cmdPropTx.startTime = 0;
1883 +    }
1885 +    /* Send packet */
1886 +    asyncCmdHndl = RF_postCmd(rfHandle, (RF_Op*)&EasyLink_cmdPropTx,
1887 +            RF_PriorityNormal, txDoneCallback, EASYLINK_RF_EVENT_MASK);
1889 +    if (EasyLink_CmdHandle_isValid(asyncCmdHndl))
1890 +    {
1891 +        status = EasyLink_Status_Success;
1892 +    }
1894 +    //busyMutex will be released by the callback
1896 +    return status;
1897 +}
1899 +EasyLink_Status EasyLink_receive(EasyLink_RxPacket *rxPacket)
1900 +{
1901 +    EasyLink_Status status = EasyLink_Status_Rx_Error;
1902 +    RF_EventMask result;
1903 +    rfc_dataEntryGeneral_t *pDataEntry;
1905 +    if ( (!configured) || suspended)
1906 +    {
1907 +        return EasyLink_Status_Config_Error;
1908 +    }
1909 +    //Check and take the busyMutex
1910 +    if (Semaphore_pend(busyMutex, 0) == FALSE)
1911 +    {
1912 +        return EasyLink_Status_Busy_Error;
1913 +    }
1915 +    pDataEntry = (rfc_dataEntryGeneral_t*) rxBuffer;
1916 +    //data entry rx buffer includes hdr (len-1Byte), addr (max 8Bytes) and data
1917 +    pDataEntry->length = 1 + EASYLINK_MAX_ADDR_SIZE + EASYLINK_MAX_DATA_LENGTH;
1918 +    pDataEntry->status = 0;
1919 +    dataQueue.pCurrEntry = (uint8_t*) pDataEntry;
1920 +    dataQueue.pLastEntry = NULL;
1921 +    EasyLink_cmdPropRxAdv.pQueue = &dataQueue;               /* Set the Data Entity queue for received data */
1922 +    EasyLink_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
1924 +    if (rxPacket->absTime != 0)
1925 +    {
1926 +        EasyLink_cmdPropRxAdv.startTrigger.triggerType = TRIG_ABSTIME;
1927 +        EasyLink_cmdPropRxAdv.startTrigger.pastTrig = 1;
1928 +        EasyLink_cmdPropRxAdv.startTime = rxPacket->absTime;
1929 +    }
1930 +    else
1931 +    {
1932 +        EasyLink_cmdPropRxAdv.startTrigger.triggerType = TRIG_NOW;
1933 +        EasyLink_cmdPropRxAdv.startTrigger.pastTrig = 1;
1934 +        EasyLink_cmdPropRxAdv.startTime = 0;
1935 +    }
1937 +    if (rxPacket->rxTimeout != 0)
1938 +    {
1939 +        EasyLink_cmdPropRxAdv.endTrigger.triggerType = TRIG_ABSTIME;
1940 +        EasyLink_cmdPropRxAdv.endTime = RF_getCurrentTime() + rxPacket->rxTimeout;
1941 +    }
1942 +    else
1943 +    {
1944 +        EasyLink_cmdPropRxAdv.endTrigger.triggerType = TRIG_NEVER;
1945 +        EasyLink_cmdPropRxAdv.endTime = 0;
1946 +    }
1948 +    //Clear the Rx statistics structure
1949 +    memset(&rxStatistics, 0, sizeof(rfc_propRxOutput_t));
1951 +    RF_CmdHandle rx_cmd = RF_postCmd(rfHandle, (RF_Op*)&EasyLink_cmdPropRxAdv,
1952 +            RF_PriorityNormal, 0, EASYLINK_RF_EVENT_MASK);
1954 +    /* Wait for Command to complete */
1955 +    result = RF_pendCmd(rfHandle, rx_cmd, (RF_EventLastCmdDone | RF_EventCmdError));
1957 +    if (result & RF_EventLastCmdDone)
1958 +    {
1959 +        //Check command status
1960 +        if (EasyLink_cmdPropRxAdv.status == PROP_DONE_OK)
1961 +        {
1962 +            //Check that data entry status indicates it is finished with
1963 +            if (pDataEntry->status != DATA_ENTRY_FINISHED)
1964 +            {
1965 +                status = EasyLink_Status_Rx_Error;
1966 +            }
1967 +            //check Rx Statistics
1968 +            else if ( (rxStatistics.nRxOk == 1) ||
1969 +                     //or  filer disabled and ignore due to addr mistmatch
1970 +                     ((EasyLink_cmdPropRxAdv.pktConf.filterOp == 1) &&
1971 +                      (rxStatistics.nRxIgnored == 1)) )
1972 +            {
1973 +                //copy length from pDataEntry (- addrSize)
1974 +                rxPacket->len = *(uint8_t*)(&pDataEntry->data) - addrSize;
1975 +                //copy address
1976 +                memcpy(rxPacket->dstAddr, (&pDataEntry->data + 1), addrSize);
1977 +                //copy payload
1978 +                memcpy(&rxPacket->payload, (&pDataEntry->data + 1 + addrSize), (rxPacket->len));
1979 +                rxPacket->rssi = rxStatistics.lastRssi;
1981 +                status = EasyLink_Status_Success;
1982 +                rxPacket->absTime = rxStatistics.timeStamp;
1983 +            }
1984 +            else if ( rxStatistics.nRxBufFull == 1)
1985 +            {
1986 +                status = EasyLink_Status_Rx_Buffer_Error;
1987 +            }
1988 +            else if ( rxStatistics.nRxStopped == 1)
1989 +            {
1990 +                status = EasyLink_Status_Aborted;
1991 +            }
1992 +            else
1993 +            {
1994 +                status = EasyLink_Status_Rx_Error;
1995 +            }
1996 +        }
1997 +        else if ( EasyLink_cmdPropRxAdv.status == PROP_DONE_RXTIMEOUT)
1998 +        {
1999 +            status = EasyLink_Status_Rx_Timeout;
2000 +        }
2001 +        else
2002 +        {
2003 +            status = EasyLink_Status_Rx_Error;
2004 +        }
2005 +    }
2007 +    //Release the busyMutex
2008 +    Semaphore_post(busyMutex);
2010 +    return status;
2011 +}
2013 +EasyLink_Status EasyLink_receiveAsync(EasyLink_ReceiveCb cb, uint32_t absTime)
2014 +{
2015 +    EasyLink_Status status = EasyLink_Status_Rx_Error;
2016 +    rfc_dataEntryGeneral_t *pDataEntry;
2018 +    //Check if not configure of already an Async command being performed
2019 +    if ( (!configured) || suspended)
2020 +    {
2021 +        return EasyLink_Status_Config_Error;
2022 +    }
2023 +    //Check and take the busyMutex
2024 +    if ( (Semaphore_pend(busyMutex, 0) == FALSE) || (EasyLink_CmdHandle_isValid(asyncCmdHndl)) )
2025 +    {
2026 +        return EasyLink_Status_Busy_Error;
2027 +    }
2029 +    rxCb = cb;
2031 +    pDataEntry = (rfc_dataEntryGeneral_t*) rxBuffer;
2032 +    //data entry rx buffer includes hdr (len-1Byte), addr (max 8Bytes) and data
2033 +    pDataEntry->length = 1 + EASYLINK_MAX_ADDR_SIZE + EASYLINK_MAX_DATA_LENGTH;
2034 +    pDataEntry->status = 0;
2035 +    dataQueue.pCurrEntry = (uint8_t*) pDataEntry;
2036 +    dataQueue.pLastEntry = NULL;
2037 +    EasyLink_cmdPropRxAdv.pQueue = &dataQueue;               /* Set the Data Entity queue for received data */
2038 +    EasyLink_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
2040 +    if (absTime != 0)
2041 +    {
2042 +        EasyLink_cmdPropRxAdv.startTrigger.triggerType = TRIG_ABSTIME;
2043 +        EasyLink_cmdPropRxAdv.startTrigger.pastTrig = 1;
2044 +        EasyLink_cmdPropRxAdv.startTime = absTime;
2045 +    }
2046 +    else
2047 +    {
2048 +        EasyLink_cmdPropRxAdv.startTrigger.triggerType = TRIG_NOW;
2049 +        EasyLink_cmdPropRxAdv.startTrigger.pastTrig = 1;
2050 +        EasyLink_cmdPropRxAdv.startTime = 0;
2051 +    }
2053 +    if (asyncRxTimeOut != 0)
2054 +    {
2055 +        EasyLink_cmdPropRxAdv.endTrigger.triggerType = TRIG_ABSTIME;
2056 +        EasyLink_cmdPropRxAdv.endTime = RF_getCurrentTime() + asyncRxTimeOut;
2057 +    }
2058 +    else
2059 +    {
2060 +        EasyLink_cmdPropRxAdv.endTrigger.triggerType = TRIG_NEVER;
2061 +        EasyLink_cmdPropRxAdv.endTime = 0;
2062 +    }
2064 +    //Clear the Rx statistics structure
2065 +    memset(&rxStatistics, 0, sizeof(rfc_propRxOutput_t));
2067 +    asyncCmdHndl = RF_postCmd(rfHandle, (RF_Op*)&EasyLink_cmdPropRxAdv,
2068 +            RF_PriorityNormal, rxDoneCallback, EASYLINK_RF_EVENT_MASK);
2070 +    if (EasyLink_CmdHandle_isValid(asyncCmdHndl))
2071 +    {
2072 +        status = EasyLink_Status_Success;
2073 +    }
2075 +    //busyMutex will be released in callback
2077 +    return status;
2078 +}
2080 +EasyLink_Status EasyLink_abort(void)
2081 +{
2082 +    EasyLink_Status status = EasyLink_Status_Cmd_Error;
2084 +    if ( (!configured) || suspended)
2085 +    {
2086 +        return EasyLink_Status_Config_Error;
2087 +    }
2088 +    //check an Async command is running, if not return success
2089 +    if (!EasyLink_CmdHandle_isValid(asyncCmdHndl))
2090 +    {
2091 +        return EasyLink_Status_Aborted;
2092 +    }
2094 +    //force abort (gracefull param set to 0)
2095 +    if (RF_cancelCmd(rfHandle, asyncCmdHndl, 0) == RF_StatSuccess)
2096 +    {
2097 +       /* Wait for Command to complete */
2098 +       RF_EventMask result = RF_pendCmd(rfHandle, asyncCmdHndl, (RF_EventLastCmdDone | RF_EventCmdError |
2099 +               RF_EventCmdAborted | RF_EventCmdCancelled | RF_EventCmdStopped));
2101 +       if (result & RF_EventLastCmdDone)
2102 +       {
2103 +           status = EasyLink_Status_Success;
2104 +       }
2105 +    }
2106 +    else
2107 +    {
2108 +       status = EasyLink_Status_Cmd_Error;
2109 +    }
2111 +    return status;
2112 +}
2114 +EasyLink_Status EasyLink_enableRxAddrFilter(uint8_t* pui8AddrFilterTable, uint8_t ui8AddrSize, uint8_t ui8NumAddrs)
2115 +{
2116 +    EasyLink_Status status = EasyLink_Status_Param_Error;
2118 +    if ( (!configured) || suspended)
2119 +    {
2120 +        return EasyLink_Status_Config_Error;
2121 +    }
2122 +    if ( Semaphore_pend(busyMutex, 0) == FALSE )
2123 +    {
2124 +        return EasyLink_Status_Busy_Error;
2125 +    }
2127 +    if ( (pui8AddrFilterTable != NULL) &&
2128 +            (ui8AddrSize != 0) && (ui8NumAddrs != 0) &&
2129 +            (ui8AddrSize == addrSize) &&
2130 +            (ui8NumAddrs <= EASYLINK_MAX_ADDR_FILTERS) )
2131 +    {
2132 +        memcpy(addrFilterTable, pui8AddrFilterTable, EASYLINK_MAX_ADDR_SIZE * EASYLINK_MAX_ADDR_FILTERS);
2133 +        EasyLink_cmdPropRxAdv.addrConf.addrSize = ui8AddrSize;
2134 +        EasyLink_cmdPropRxAdv.addrConf.numAddr = ui8NumAddrs;
2135 +        EasyLink_cmdPropRxAdv.pktConf.filterOp = 0;
2137 +        status = EasyLink_Status_Success;
2138 +    }
2139 +    else if (pui8AddrFilterTable == NULL)
2140 +    {
2141 +        //disable filter
2142 +        EasyLink_cmdPropRxAdv.pktConf.filterOp = 1;
2144 +        status = EasyLink_Status_Success;
2145 +    }
2147 +    //Release the busyMutex
2148 +    Semaphore_post(busyMutex);
2150 +    return status;
2151 +}
2153 +EasyLink_Status EasyLink_setCtrl(EasyLink_CtrlOption Ctrl, uint32_t ui32Value)
2154 +{
2155 +    EasyLink_Status status = EasyLink_Status_Param_Error;
2156 +    switch(Ctrl)
2157 +    {
2158 +        case EasyLink_Ctrl_AddSize:
2159 +            if (ui32Value <= EASYLINK_MAX_ADDR_SIZE)
2160 +            {
2161 +                addrSize = (uint8_t) ui32Value;
2162 +                EasyLink_cmdPropRxAdv.addrConf.addrSize = addrSize;
2163 +                status = EasyLink_Status_Success;
2164 +            }
2165 +            break;
2166 +        case EasyLink_Ctrl_Idle_TimeOut:
2167 +            rfParams.nInactivityTimeout = ui32Value;
2168 +            rfParamsConfigured = 1;
2169 +            status = EasyLink_Status_Success;
2170 +            break;
2171 +        case EasyLink_Ctrl_MultiClient_Mode:
2172 +            rfModeMultiClient = (bool) ui32Value;
2173 +            status = EasyLink_Status_Success;
2174 +            break;
2175 +        case EasyLink_Ctrl_AsyncRx_TimeOut:
2176 +            asyncRxTimeOut = ui32Value;
2177 +            status = EasyLink_Status_Success;
2178 +            break;
2179 +        case EasyLink_Ctrl_Test_Tone:
2180 +            status = enableTestMode(EasyLink_Ctrl_Test_Tone);
2181 +            break;
2182 +        case EasyLink_Ctrl_Test_Signal:
2183 +            status = enableTestMode(EasyLink_Ctrl_Test_Signal);
2184 +            break;
2185 +    }
2187 +    return status;
2188 +}
2190 +EasyLink_Status EasyLink_getCtrl(EasyLink_CtrlOption Ctrl, uint32_t* pui32Value)
2191 +{
2192 +    EasyLink_Status status = EasyLink_Status_Cmd_Error;
2194 +    switch(Ctrl)
2195 +    {
2196 +        case EasyLink_Ctrl_AddSize:
2197 +            *pui32Value = addrSize;
2198 +            status = EasyLink_Status_Success;
2199 +            break;
2200 +        case EasyLink_Ctrl_Idle_TimeOut:
2201 +            *pui32Value = rfParams.nInactivityTimeout;
2202 +            status = EasyLink_Status_Success;
2203 +            break;
2204 +        case EasyLink_Ctrl_MultiClient_Mode:
2205 +            *pui32Value = (uint32_t) rfModeMultiClient;
2206 +            status = EasyLink_Status_Success;
2207 +            break;
2208 +        case EasyLink_Ctrl_AsyncRx_TimeOut:
2209 +            *pui32Value = asyncRxTimeOut;
2210 +            status = EasyLink_Status_Success;
2211 +            break;
2212 +        case EasyLink_Ctrl_Test_Tone:
2213 +        case EasyLink_Ctrl_Test_Signal:
2214 +            *pui32Value = 0;
2215 +            status = EasyLink_Status_Success;
2216 +            break;
2217 +    }
2219 +    return status;
2220 +}
2222 +EasyLink_Status EasyLink_getIeeeAddr(uint8_t *ieeeAddr)
2223 +{
2224 +    EasyLink_Status status = EasyLink_Status_Param_Error;
2226 +    if (ieeeAddr != NULL)
2227 +    {
2228 +        int i;
2230 +        //Reading from primary IEEE location...
2231 +        uint8_t *location = (uint8_t *)EASYLINK_PRIMARY_IEEE_ADDR_LOCATION;
2233 +        /*
2234 +         * ...unless we can find a byte != 0xFF in secondary
2235 +         *
2236 +         * Intentionally checking all 8 bytes here instead of len, because we
2237 +         * are checking validity of the entire IEEE address irrespective of the
2238 +         * actual number of bytes the caller wants to copy over.
2239 +         */
2240 +        for (i = 0; i < 8; i++) {
2241 +            if (((uint8_t *)EASYLINK_SECONDARY_IEEE_ADDR_LOCATION)[i] != 0xFF) {
2242 +                //A byte in the secondary location is not 0xFF. Use the
2243 +                //secondary
2244 +                location = (uint8_t *)EASYLINK_SECONDARY_IEEE_ADDR_LOCATION;
2245 +                break;
2246 +            }
2247 +        }
2249 +        //inverting byte order
2250 +       for (i = 0; i < 8; i++) {
2251 +           ieeeAddr[i] = location[8 - 1 - i];
2252 +       }
2255 +        status = EasyLink_Status_Success;
2256 +    }
2258 +    return status;
2259 +}
2260 diff -urN easylink/EasyLink.h concentrator_new/easylink/EasyLink.h
2261 --- easylink/EasyLink.h 1969-12-31 18:00:00.000000000 -0600
2262 +++ concentrator_new/easylink/EasyLink.h        2017-07-07 13:15:02.990561400 -0500
2263 @@ -0,0 +1,497 @@
2264 +/*
2265 + * Copyright (c) 2015-2017, Texas Instruments Incorporated
2266 + * All rights reserved.
2267 + *
2268 + * Redistribution and use in source and binary forms, with or without
2269 + * modification, are permitted provided that the following conditions
2270 + * are met:
2271 + *
2272 + * *  Redistributions of source code must retain the above copyright
2273 + *    notice, this list of conditions and the following disclaimer.
2274 + *
2275 + * *  Redistributions in binary form must reproduce the above copyright
2276 + *    notice, this list of conditions and the following disclaimer in the
2277 + *    documentation and/or other materials provided with the distribution.
2278 + *
2279 + * *  Neither the name of Texas Instruments Incorporated nor the names of
2280 + *    its contributors may be used to endorse or promote products derived
2281 + *    from this software without specific prior written permission.
2282 + *
2283 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2284 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2285 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2286 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
2287 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2288 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2289 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2290 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2291 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2292 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2293 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2294 + */
2296 +//!
2297 +//! \defgroup EasyLink
2299 +//!
2300 +//! \ingroup EasyLink
2301 +//@{
2303 +//*****************************************************************************
2304 +//  @file       EasyLink.h
2305 +//
2306 +//  @brief      EasyLink RF API for CC13xx/CC26xx family
2307 +//
2308 +// # Overview #
2309 +// The EasyLink API should be used in application code. The EasyLink API is
2310 +// intended to abstract the RF Driver in order to give a simple API for
2311 +// customers to use as is or extend to suit their application[Use Cases]
2312 +// (@ref USE_CASES).
2313 +//
2314 +// # General Behavior #
2315 +// Before using the EasyLink API:
2316 +//   - The EasyLink Layer is initialized by calling EasyLink_init(). This
2317 +//     initialises and opens the RF driver and configuring a modulation scheme
2318 +//     passed to EasyLink_init.
2319 +//   - The RX and TX can operate independently of each other.
2320 +//   .
2321 +// The following is true for receive operation:
2322 +//   - RX is enabled by calling EasyLink_receive() or EasyLink_receiveAsync().
2323 +//   - Entering RX can be immediate or scheduled.
2324 +//   - EasyLink_receive() is blocking and EasyLink_receiveAsync() is nonblocking.
2325 +//   - the EasyLink API does not queue messages so calling another API function
2326 +//     while in EasyLink_receiveAsync() will return EasyLink_Status_Busy_Error
2327 +//   - an Async operation can be cancelled with EasyLink_abort()
2328 +//   .
2329 +// The following apply for transmit operation:
2330 +//   - TX is enabled by calling EasyLink_transmit() or EasyLink_transmitAsync().
2331 +//   - TX can be immediate or scheduled.
2332 +//   - EasyLink_transmit() is blocking and EasyLink_transmitAsync() is nonblocking
2333 +//   - EasyLink_transmit() for a scheduled command, or if TX can not start
2334 +//   - the EasyLink API does not queue messages so calling another API function
2335 +//     while in EasyLink_transmitAsync() will return EasyLink_Status_Busy_Error
2336 +//   - an Async operation can be cancelled with EasyLink_abort()
2337 +//
2338 +// # Error handling #
2339 +//    The EasyLink API will return EasyLink_Status containing success or error
2340 +//    code. The EasyLink_Status code are:
2341 +//    EasyLink_Status_Success
2342 +//    EasyLink_Status_Config_Error
2343 +//    EasyLink_Status_Param_Error
2344 +//    EasyLink_Status_Mem_Error
2345 +//    EasyLink_Status_Cmd_Error
2346 +//    EasyLink_Status_Tx_Error
2347 +//    EasyLink_Status_Rx_Error
2348 +//    EasyLink_Status_Rx_Timeout
2349 +//    EasyLink_Status_Busy_Error
2350 +//    EasyLink_Status_Aborted
2351 +//   .
2352 +//
2353 +// # Power Management #
2354 +// The TI-RTOS power management framework will try to put the device into the most
2355 +// power efficient mode whenever possible. Please see the technical reference
2356 +// manual for further details on each power mode.
2357 +//
2358 +// The EasyLink Layer uses the power management offered by the RF driver Refer to the RF
2359 +// drive documentation for more details.
2360 +//
2361 +// # Supported Functions #
2362 +// | Generic API function          | Description                                       |
2363 +// |-------------------------------|---------------------------------------------------|
2364 +// | EasyLink_init()               | Init's and opens the RF driver and configures the |
2365 +// |                               | specified modulation                              |
2366 +// | EasyLink_transmit()           | Blocking Transmit                                 |
2367 +// | EasyLink_transmitAsync()      | Nonblocking Transmit                              |
2368 +// | EasyLink_receive()            | Blocking Receive                                  |
2369 +// | EasyLink_receiveAsync()       | Nonblocking Receive                               |
2370 +// | EasyLink_abort()              | Aborts a non blocking call                        |
2371 +// | EasyLink_EnableRxAddrFilter() | Enables/Disables RX filtering on the Addr         |
2372 +// | EasyLink_GetIeeeAddr()        | Gets the IEEE Address                             |
2373 +// | EasyLink_SetFreq()            | Sets the frequency                                |
2374 +// | EasyLink_GetFreq()            | Gets the frequency                                |
2375 +// | EasyLink_SetRfPwr()           | Sets the Tx Power                                 |
2376 +// | EasyLink_GetRfPwr()           | Gets the Tx Power                                 |
2377 +//
2378 +// # Frame Structure #
2379 +// The EasyLink implements a basic header for transmitting and receiving data. This header supports
2380 +// addressing for a star or point-to-point network with acknowledgements.
2381 +//
2382 +// Packet structure:
2383 +//     _________________________________________________________
2384 +//    |           |                   |                         |
2385 +//    | 1B Length | 1-64b Dst Address |         Payload         |
2386 +//    |___________|___________________|_________________________|
2387 +//
2388 +//
2389 +//
2390 +//  # Not Supported Functionality #
2391 +//
2392 +//
2393 +//*****************************************************************************
2394 +#ifndef Easylink__include
2395 +#define Easylink__include
2397 +//*****************************************************************************
2398 +//
2399 +// If building with a C++ compiler, make all of the definitions in this header
2400 +// have a C binding.
2401 +//
2402 +//*****************************************************************************
2403 +#ifdef __cplusplus
2404 +extern "C"
2405 +{
2406 +#endif
2408 +#include <stdbool.h>
2409 +#include <stdint.h>
2411 +#define EASYLINK_API_VERSION "EasyLink-v2.10.00"
2413 +/// \brief defines the largest Tx/Rx payload that the interface can support
2414 +#define EASYLINK_MAX_DATA_LENGTH        128
2416 +/// \brief defines the Tx/Rx Max Address Size
2417 +#define EASYLINK_MAX_ADDR_SIZE        8
2419 +/// \brief defines the Max number of Rx Address filters
2420 +#define EASYLINK_MAX_ADDR_FILTERS     3
2422 +/// \brief macro to convert from Radio Time Ticks to ms
2423 +#define EasyLink_RadioTime_To_ms(radioTime) ((1000 * radioTime) / 4000000)
2425 +/// \brief macro to convert from ms to Radio Time Ticks
2426 +#define EasyLink_ms_To_RadioTime(ms) (ms*(4000000/1000))
2428 +#define CC1190_PA_EN            IOID_30
2429 +#define CC1190_LNA_EN           IOID_29
2430 +#define CC1190_HGM              IOID_28
2432 +/// \brief EasyLink Status and error codes
2433 +typedef enum
2434 +{
2435 +    EasyLink_Status_Success         = 0, ///Success
2436 +    EasyLink_Status_Config_Error    = 1, ///Configuration error
2437 +    EasyLink_Status_Param_Error     = 2, ///Param error
2438 +    EasyLink_Status_Mem_Error       = 3, ///Memory Error
2439 +    EasyLink_Status_Cmd_Error       = 4, ///Memory Error
2440 +    EasyLink_Status_Tx_Error        = 5, ///Tx Error
2441 +    EasyLink_Status_Rx_Error        = 6, ///Rx Error
2442 +    EasyLink_Status_Rx_Timeout      = 7, ///Rx Error
2443 +    EasyLink_Status_Rx_Buffer_Error = 8, ///Rx Buffer Error
2444 +    EasyLink_Status_Busy_Error      = 9, ///Busy Error
2445 +    EasyLink_Status_Aborted         = 10 ///Cmd stopped or aborted
2446 +} EasyLink_Status;
2449 +/// \brief Phy Type passed to EasyLink_init
2450 +typedef enum
2451 +{
2452 +    EasyLink_Phy_Custom = 0, ///Customer Phy specific settings exported from SmartRF Studio
2453 +    EasyLink_Phy_50kbps2gfsk = 1, ///Phy settings for Sub1G 50kbps data rate, IEEE 802.15.4g GFSK.
2454 +    EasyLink_Phy_625bpsLrm = 2, ///Phy settings for Sub1G 625bps data rate, Long Range Mode.
2455 +    EasyLink_Phy_2_4_200kbps2gfsk = 3, ///Phy settings for 2.4Ghz 200kbps data rate, IEEE 802.15.4g GFSK.
2456 +    EasyLink_Phy_5kbpsSlLr = 4, // SimpleLink Long Range (5 kbps)
2457 +} EasyLink_PhyType;
2459 +/// \brief Advance configuration options
2460 +typedef enum
2461 +{
2462 +    EasyLink_Ctrl_AddSize = 0, ///Set the number of bytes in Addr for both Addr
2463 +    ///Filter and Tx/Rx operations
2464 +    EasyLink_Ctrl_Idle_TimeOut = 1, ///Set the time for Radio to return to
2465 +                                    ///idle after. Must be set before calling
2466 +                                    //EasyLink_init.
2467 +    EasyLink_Ctrl_MultiClient_Mode = 2, ///Set Multiclient mode for application
2468 +                                        ///that will use multiple RF clients.
2469 +                                        ///Must be set before calling
2470 +                                        ///EasyLink_init.
2471 +    EasyLink_Ctrl_AsyncRx_TimeOut = 3,  ///Relative time in ticks from Async
2472 +                                        ///Rx start to TimeOut. A value of
2473 +                                        ///0 means no timeout
2474 +    EasyLink_Ctrl_Test_Tone = 4, ///Enable/Disable Test mode for Tone
2475 +    EasyLink_Ctrl_Test_Signal = 5, ///Enable/Disable Test mode for Signal
2476 +} EasyLink_CtrlOption;
2478 +/// \brief Structure for the TX Packet
2479 +typedef struct
2480 +{
2481 +        uint8_t dstAddr[8];     /// Dst Address
2482 +        uint32_t absTime;        ///Absolute time to Tx packet (0 for immediate)
2483 +        ///Layer will use last SeqNum used + 1
2484 +        uint8_t len;             ///Payload Length
2485 +        uint8_t payload[EASYLINK_MAX_DATA_LENGTH];       ///Payload
2486 +} EasyLink_TxPacket;
2488 +/// \brief Structure for the RX'ed Packet
2489 +typedef struct
2490 +{
2491 +        uint8_t dstAddr[8];      ///Dst Address of RX'ed packet
2492 +        int8_t rssi;             ///rssi of RX'ed packet
2493 +        uint32_t absTime;        ///Absolute time to turn on Rx when passed
2494 +                                 ///(0 for immediate), Or Absolute time that packet was Rx
2495 +                                 ///when returned.
2496 +        uint32_t rxTimeout;      ///Relative time in ticks from Rx start to Rx TimeOut
2497 +                                 ///a value of 0 means no timeout
2498 +        uint8_t len;             ///length of RX'ed packet
2499 +        uint8_t payload[EASYLINK_MAX_DATA_LENGTH]; ///payload of RX'ed packet
2500 +} EasyLink_RxPacket;
2502 +/** \brief EasyLink Callback function type for Received packet, registered
2503 + *   with EasyLink_ReceiveAsync
2504 + */
2505 +typedef void (*EasyLink_ReceiveCb)(EasyLink_RxPacket * rxPacket,
2506 +        EasyLink_Status status);
2508 +/** \brief EasyLink Callback function type for Tx Done registered with
2509 + *  EasyLink_TransmitAsync
2510 + */
2511 +typedef void (*EasyLink_TxDoneCb)(EasyLink_Status status);
2513 +//*****************************************************************************
2514 +//
2515 +//! \brief Initializes the radio with specified Phy settings
2516 +//!
2517 +//! This function configures the radio phy settings. If the ui32ModType
2518 +//! is EasyLink_Phy_Custom then the configuration is taken from srf_settings.h.
2519 +//! If a specific phy configuration is required (and not supported by any of
2520 +//! the defined Phy types in EasyLink_PhyType then you can cut and past the
2521 +//! RF setting from the SmartRF Studio code export tool. This will copy and use
2522 +//! the RF_prop, RF_cmdPropRadioDivSetup and RF_cmdFs commands, as well as the
2523 +//! Synchword from the RF_cmdPropTx and RF_cmdPropRx commands.
2524 +//!
2525 +//! \param ui32ModType is a set to:
2526 +//! - \ref EasyLink_Phy_50kbps2gfsk
2527 +//! - \ref EasyLink_Phy_625bpsLrm
2528 +//! - \ref EasyLink_Phy_Custom
2529 +//!
2530 +//! \return EasyLink_Status
2531 +//
2532 +//*****************************************************************************
2533 +extern EasyLink_Status EasyLink_init(EasyLink_PhyType ui32ModType);
2535 +//*****************************************************************************
2536 +//
2537 +//! \brief Gets the absolute radio time
2538 +//!
2539 +//! This function returns the absolute radio time and can be used for
2540 +//! monitoring or Tx/Rx events using the EasyLink_TxPacket_t and
2541 +//! EasyLink_RxPacket_t absTime field.
2542 +//!
2543 +//!
2544 +//! \return absolute time
2545 +//
2546 +//*****************************************************************************
2547 +extern uint32_t EasyLink_getAbsTime(void);
2549 +//*****************************************************************************
2550 +//
2551 +//! \brief Sends a Packet with blocking call.
2552 +//!
2553 +//! This function is a blocking call to send a packet. If the Tx is
2554 +//! successfully scheduled then the function will block until the Tx is
2555 +//! complete.
2556 +//!
2557 +//! \param txPacket - The descriptor for the packet to be Tx'ed.
2558 +//!
2559 +//! \return EasyLink_Status
2560 +//
2561 +//*****************************************************************************
2562 +extern EasyLink_Status EasyLink_transmit(EasyLink_TxPacket *txPacket);
2564 +//*****************************************************************************
2565 +//
2566 +//! \brief Sends a Packet with non blocking call.
2567 +//!
2568 +//! This function is a non blocking call to send a packet. If the Tx is
2569 +//! successfully scheduled then the callback will be call once the Tx is
2570 +//! complete. The Tx will timeout if EasyLink_Ctrl_AsyncTx_TimeOut
2571 +//! ctrl message is used to set the timeout to something other than 0.
2572 +//!
2573 +//! \param txPacket - The descriptor for the packet to be Tx'ed.
2574 +//! \param cb     - The tx done function pointer.
2575 +//!
2576 +//! \return EasyLink_Status
2577 +//
2578 +//*****************************************************************************
2579 +extern EasyLink_Status EasyLink_transmitAsync(EasyLink_TxPacket *txPacket,
2580 +        EasyLink_TxDoneCb cb);
2582 +//*****************************************************************************
2583 +//
2584 +//! \brief Blocking call that waits for an Rx Packet.
2585 +//!
2586 +//! This function is a blocking call to wait for an Rx packet.
2587 +//!
2588 +//! \param rxPacket - The descriptor for the packet to be Rx'ed.
2589 +//!
2590 +//! \return EasyLink_Status
2591 +//
2592 +//*****************************************************************************
2593 +extern EasyLink_Status EasyLink_receive(EasyLink_RxPacket *rxPacket);
2595 +//*****************************************************************************
2596 +//
2597 +//! \brief Enables Asynchronous Packet Rx with non blocking call.
2598 +//!
2599 +//! This function is a non blocking call to Rx a packet. The Rx is turned on
2600 +//! and the Callback is called once a packet is received. The Rx will timeout
2601 +//! if EasyLink_Ctrl_AsyncRx_TimeOut ctrl message is used to set the timeout
2602 +//! to something other than 0.
2603 +//!
2604 +//! \param cb        - The rx function pointer.
2605 +//! \param absTime   - Start time of Rx (0: now !0: absolute radio time to
2606 +//!                    start Rx)
2607 +//!
2608 +//! \return EasyLink_Status
2609 +//
2610 +//*****************************************************************************
2611 +extern EasyLink_Status EasyLink_receiveAsync(EasyLink_ReceiveCb cb, uint32_t absTime);
2613 +//*****************************************************************************
2614 +//
2615 +//! \brief Abort a previously call Async Tx/Rx.
2616 +//!
2617 +//! This function is a blocking call to abort a previous Async Tx/Rx
2618 +//!
2619 +//! \return EasyLink_Status
2620 +//
2621 +//*****************************************************************************
2622 +extern EasyLink_Status EasyLink_abort(void);
2625 +//*****************************************************************************
2626 +//
2627 +//! \brief Sets the Frequency
2628 +//!
2629 +//! This function set the radio to the specified frequency. Note that this will
2630 +//! be rounded to the nearest frequency supported by the Frequency Synthesizer.
2631 +//!
2632 +//! \param ui16Freq Frequency in units of kHz
2633 +//!
2634 +//! \return EasyLink_Status
2635 +//
2636 +//*****************************************************************************
2637 +extern EasyLink_Status EasyLink_setFrequency(uint32_t ui16Freq);
2639 +//*****************************************************************************
2640 +//
2641 +//! \brief Gets the Frequency
2642 +//!
2643 +//! This function gets Frequency in units of kHz. This function will return the
2644 +//! value set in the Frequency Synthesizer, and may not be the same as set
2645 +//! using easyLink_setFrequency API. Note that this value does not include any
2646 +//! offsets for deviations due to factors such as temperature and hence this API
2647 +//! should not be used to get an accurate measure of frequency.
2649 +//!
2650 +//! \return Frequency in units of kHz
2651 +//
2652 +//*****************************************************************************
2653 +extern uint32_t EasyLink_getFrequency(void);
2655 +//*****************************************************************************
2656 +//
2657 +//! \brief Enables the address filter
2658 +//!
2659 +//! This function enables the address filter to filter out address that are not
2660 +//! in the address table provided.
2661 +//!
2662 +//! \param pui8AddrFilterTable A uint8 pointer to a variable size 2d array
2663 +//!  containing the addresses to filter on.
2664 +//! \param ui8AddrSize The size of the address elements
2665 +//! \param ui8NumAddrs The number of address elements
2666 +//!
2667 +//! \return EasyLink_Status
2668 +//
2669 +//*****************************************************************************
2670 +extern EasyLink_Status EasyLink_enableRxAddrFilter(uint8_t* pui8AddrFilterTable,
2671 +        uint8_t ui8AddrSize, uint8_t ui8NumAddrs);
2673 +//*****************************************************************************
2674 +//
2675 +//! \brief Gets the IEEE address
2676 +//!
2677 +//! This function gets the IEEE address
2678 +//!
2679 +//! \param ieeeAddr pointer to an 8 element byte array to write the IEEE
2680 +//! address to.
2681 +//!
2682 +//! \return EasyLink_Status
2683 +//
2684 +//*****************************************************************************
2685 +extern EasyLink_Status EasyLink_getIeeeAddr(uint8_t *ieeeAddr);
2687 +//*****************************************************************************
2688 +//
2689 +//! \brief Sets the TX Power
2690 +//!
2691 +//! This function sets the Tx Power
2692 +//!
2693 +//! \param i8Power the tx power in dBm's to be set. integers of -10 and between
2694 +//!        0-14 dBm are accepted. Values above 14 are rounded to 14 and below 0
2695 +//!        are rounded to -10
2696 +//!
2697 +//! \return EasyLink_Status
2698 +//
2699 +//*****************************************************************************
2700 +extern EasyLink_Status EasyLink_setRfPwr(int8_t i8Power);
2702 +//*****************************************************************************
2703 +//
2704 +//! \brief Gets the TX Power
2705 +//!
2706 +//! This function gets the Tx Power in dBm, values ranging from -10 to 14 dBm
2707 +//! should be expect
2708 +//!
2709 +//! \return power in dBm
2710 +//
2711 +//*****************************************************************************
2712 +extern int8_t EasyLink_getRfPwr(void);
2714 +//*****************************************************************************
2715 +//
2716 +//! \brief Sets advanced configuration options
2717 +//!
2718 +//! This function allows setting some of the advanced configuration options
2719 +//!
2720 +//! \param Ctrl - The control option to be set
2721 +//! \param ui32Value - The value to set the control option to
2722 +//
2723 +//! \return EasyLink_Status
2724 +//!
2725 +//*****************************************************************************
2726 +extern EasyLink_Status EasyLink_setCtrl(EasyLink_CtrlOption Ctrl,
2727 +        uint32_t ui32Value);
2729 +//*****************************************************************************
2730 +//
2731 +//! \brief Gets advanced configuration options
2732 +//!
2733 +//! This function allows getting some of the advanced configuration options
2734 +//!
2735 +//! \param Ctrl - The control option to get
2736 +//! \param pui32Value - Pointer to return the control option value
2737 +//!
2738 +//! \return EasyLink_Status
2739 +//!
2740 +//*****************************************************************************
2741 +extern EasyLink_Status EasyLink_getCtrl(EasyLink_CtrlOption Ctrl,
2742 +        uint32_t* pui32Value);
2744 +//*****************************************************************************
2745 +//
2746 +// Mark the end of the C bindings section for C++ compilers.
2747 +//
2748 +//*****************************************************************************
2749 +#ifdef __cplusplus
2750 +}
2751 +#endif
2753 +#endif // Easylink__include
2755 +//*****************************************************************************
2756 +//
2757 +//! Close the Doxygen group.
2758 +//! @}
2759 +//
2760 +//*****************************************************************************
2761 diff -urN RadioProtocol.h concentrator_new/RadioProtocol.h
2762 --- RadioProtocol.h     1969-12-31 18:00:00.000000000 -0600
2763 +++ concentrator_new/RadioProtocol.h    2017-07-07 13:15:03.020561400 -0500
2764 @@ -0,0 +1,69 @@
2765 +/*
2766 + * Copyright (c) 2015-2016, Texas Instruments Incorporated
2767 + * All rights reserved.
2768 + *
2769 + * Redistribution and use in source and binary forms, with or without
2770 + * modification, are permitted provided that the following conditions
2771 + * are met:
2772 + *
2773 + * *  Redistributions of source code must retain the above copyright
2774 + *    notice, this list of conditions and the following disclaimer.
2775 + *
2776 + * *  Redistributions in binary form must reproduce the above copyright
2777 + *    notice, this list of conditions and the following disclaimer in the
2778 + *    documentation and/or other materials provided with the distribution.
2779 + *
2780 + * *  Neither the name of Texas Instruments Incorporated nor the names of
2781 + *    its contributors may be used to endorse or promote products derived
2782 + *    from this software without specific prior written permission.
2783 + *
2784 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2785 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2786 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2787 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
2788 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2789 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2790 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2791 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2792 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2793 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2794 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2795 + */
2797 +#ifndef RADIOPROTOCOL_H_
2798 +#define RADIOPROTOCOL_H_
2800 +#include "stdint.h"
2801 +#include "easylink/EasyLink.h"
2803 +#define RADIO_CONCENTRATOR_ADDRESS     0x00
2804 +#define RADIO_EASYLINK_MODULATION     EasyLink_Phy_5kbpsSlLr
2806 +#define RADIO_PACKET_TYPE_ACK_PACKET             0
2807 +#define RADIO_PACKET_TYPE_ADC_SENSOR_PACKET      1
2808 +#define RADIO_PACKET_TYPE_DM_SENSOR_PACKET       2
2809 +#define RADIO_PACKET_TYPE_GPS_SENSOR_PACKET      4
2811 +struct PacketHeader {
2812 +    uint8_t sourceAddress;
2813 +    uint8_t packetType;
2814 +};
2816 +struct AdcSensorPacket {
2817 +    struct PacketHeader header;
2818 +    uint16_t adcValue;
2819 +};
2821 +struct DualModeSensorPacket {
2822 +    struct PacketHeader header;
2823 +    uint16_t adcValue;
2824 +    uint16_t batt;
2825 +    uint32_t time100MiliSec;
2826 +    uint8_t button;
2827 +};
2829 +struct AckPacket {
2830 +    struct PacketHeader header;
2831 +};
2833 +#endif /* RADIOPROTOCOL_H_ */
2834 diff -urN rfWsnConcentrator.c concentrator_new/rfWsnConcentrator.c
2835 --- rfWsnConcentrator.c 1969-12-31 18:00:00.000000000 -0600
2836 +++ concentrator_new/rfWsnConcentrator.c        2017-07-07 13:15:03.028061400 -0500
2837 @@ -0,0 +1,84 @@
2838 +/*
2839 + * Copyright (c) 2015-2016, Texas Instruments Incorporated
2840 + * All rights reserved.
2841 + *
2842 + * Redistribution and use in source and binary forms, with or without
2843 + * modification, are permitted provided that the following conditions
2844 + * are met:
2845 + *
2846 + * *  Redistributions of source code must retain the above copyright
2847 + *    notice, this list of conditions and the following disclaimer.
2848 + *
2849 + * *  Redistributions in binary form must reproduce the above copyright
2850 + *    notice, this list of conditions and the following disclaimer in the
2851 + *    documentation and/or other materials provided with the distribution.
2852 + *
2853 + * *  Neither the name of Texas Instruments Incorporated nor the names of
2854 + *    its contributors may be used to endorse or promote products derived
2855 + *    from this software without specific prior written permission.
2856 + *
2857 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2858 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2859 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2860 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
2861 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2862 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2863 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2864 + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2865 + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2866 + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2867 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2868 + */
2870 +/*
2871 + *  ======== empty_min.c ========
2872 + */
2873 +/* XDCtools Header files */
2874 +#include <xdc/std.h>
2875 +#include <xdc/runtime/System.h>
2877 +/* BIOS Header files */
2878 +#include <ti/sysbios/BIOS.h>
2879 +#include <ti/drivers/Power.h>
2880 +#include <ti/drivers/power/PowerCC26XX.h>
2882 +/* TI-RTOS Header files */
2883 +#include <ti/display/Display.h>
2884 +#include <ti/drivers/PIN.h>
2885 +#include <ti/drivers/UART.h>
2886 +#include <ti/drivers/SPI.h>
2888 +/* Board Header files */
2889 +#include "Board.h"
2891 +#include "ConcentratorRadioTask.h"
2892 +#include "ConcentratorTask.h"
2894 +#include "board_palna.h"
2896 +/*
2897 + *  ======== main ========
2898 + */
2899 +int main(void)
2900 +{
2901 +    /* Call driver init functions. */
2902 +    Board_initGeneral();
2904 +    /* Initialise the UART and SPI for the display driver. */
2905 +    Display_init();
2906 +    UART_init();
2907 +    SPI_init();
2909 +#ifdef CC1310_CC1190_LP
2910 +    Board_Palna_initialize(1);
2911 +#endif
2913 +    /* Initialize concentrator tasks */
2914 +    ConcentratorRadioTask_init();
2915 +    ConcentratorTask_init();
2917 +    /* Start BIOS */
2918 +    BIOS_start();
2920 +    return (0);
2921 +}