Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
posix-platform.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Nest Labs, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
35 #ifndef POSIX_PLATFORM_H_
36 #define POSIX_PLATFORM_H_
37 
38 #include <stdint.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <sys/select.h>
42 #include <sys/time.h>
43 
44 #include "openthread/instance.h"
45 #include "ca821x_api.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
55 extern uint32_t NODE_ID;
56 
61 extern uint32_t WELLKNOWN_NODE_ID;
62 
67 int posixPlatformInit(void);
68 
75 
80 void posixPlatformSetOrigArgs(int argc, char *argv[]);
81 
86 void posixPlatformProcessDrivers(otInstance *aInstance);
87 
92 void posixPlatformProcessDriversQuick(otInstance *aInstance);
93 
97 void posixPlatformGetTimeout(otInstance *aInstance, struct timeval *timeout);
98 
103 void posixPlatformSleep(otInstance *aInstance, struct timeval *timeout);
104 
109 void posixPlatformAlarmInit(void);
110 
117 void posixPlatformAlarmUpdateTimeout(struct timeval *tv);
118 
123 void posixPlatformAlarmProcess(otInstance *aInstance);
124 
129 int PlatformRadioInit(void);
130 
137 int PlatformRadioInitWithDev(struct ca821x_dev *pDeviceRef);
138 
143 int PlatformRadioProcess(void);
144 
149 void PlatformRadioStop(void);
150 
156 
161 void posixPlatformRandomInit(void);
162 
171 void platformUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd);
172 
177 void platformUartProcess(void);
178 
179 #ifdef __cplusplus
180 } // extern "C"
181 #endif
182 
183 #endif // POSIX_PLATFORM_H_
The main ca821x-api include file.
int PlatformRadioInitWithDev(struct ca821x_dev *pDeviceRef)
This method initializes the radio service used by OpenThread using a pDeviceRef that has already been...
Definition: radio.c:652
int PlatformRadioInit(void)
This method initializes the radio service used by OpenThread.
Definition: radio.c:668
struct ca821x_dev * PlatformGetDeviceRef()
Get the radio device currently in use by Openthread.
Definition: radio.c:78
void PlatformRadioStop(void)
This method cleanly stops the radio.
Definition: radio.c:599
void posixPlatformAlarmUpdateTimeout(struct timeval *tv)
This method retrieves the time remaining until the alarm fires.
Definition: alarm.c:81
int posixPlatformInit(void)
This method performs all platform-specific initialization.
Definition: platform.c:65
void posixPlatformSetOrigArgs(int argc, char *argv[])
This method stores the original arguments given to the program.
Definition: platform.c:59
int PlatformRadioProcess(void)
This method performs radio driver processing.
Definition: radio.c:744
void posixPlatformAlarmProcess(otInstance *aInstance)
This method performs alarm driver processing.
Definition: alarm.c:112
uint32_t NODE_ID
Unique node ID.
Definition: platform.c:57
void posixPlatformAlarmInit(void)
This method initializes the alarm service used by OpenThread.
Definition: alarm.c:45
void posixPlatformGetTimeout(otInstance *aInstance, struct timeval *timeout)
This method gets the timeout for the sleep function, and places it in the timeout struct.
Definition: platform.c:82
void posixPlatformProcessDriversQuick(otInstance *aInstance)
This method performs all platform-specific processing without sleeping at the end.
Definition: platform.c:103
uint32_t WELLKNOWN_NODE_ID
Well-known Unique ID used by a simulated radio that supports promiscuous mode.
void posixPlatformRandomInit(void)
This method initializes the random number service used by OpenThread.
Definition: entropy.c:51
void posixPlatformSleep(otInstance *aInstance, struct timeval *timeout)
This method sleeps until there is further work to do (allowing the application to access the openthre...
Definition: platform.c:92
void posixPlatformProcessDrivers(otInstance *aInstance)
This method performs all platform-specific processing.
Definition: platform.c:110
void posixPlatformRestoreTerminal(void)
This method restores the terminal to it's pre-openthread state.
Definition: serial.c:74
void platformUartProcess(void)
This method performs radio driver processing.
Definition: serial.c:239
void platformUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd)
This method updates the file descriptor sets with file descriptors used by the serial driver.
Definition: serial.c:213
CA-821x Device reference struct.
Definition: ca821x_api.h:123