#include "mos.h"
#include "mutex.h"
#include <stdarg.h>
Go to the source code of this file.
Data Structures | |
| struct | comBuf_t |
| The standard comBuf data structure is designed to be used across multiple different communication devices. A comBuf contains an array of bytes, the number of bytes, and possibly some other fields, depending on the specific platform. More... | |
Available Interfaces | |
| Each of the following can be used with the com_send(), com_recv(), com_mode(), and com_ioctl() functions. | |
| #define | IFACE_SERIAL 0 |
| the UART0 serial interface. | |
| #define | IFACE_SERIAL2 1 |
| the UART1 serial interface. | |
| #define | IFACE_RADIO 2 |
| the CC2420 or CC1000 radio interface. | |
| #define | IFACE_LOOPBACK 3 |
| the loopback interface. | |
| #define | MAX_IFS 7 |
COM Error Messages | |
| These values can be returned from com layer functions when an error occurs. | |
| #define | SELECT_IFACE_BUSY 150 |
| The requested interface is busy. | |
| #define | IFACE_NOT_REGISTERED 160 |
| The requested interface does not exist. | |
COM Select | |
| com_select can be used to check if there is data available to be read from a specified interface. This function is similar to the berkley socket select() function. | |
| #define | IF_SET(iface, set) (*set |= 1 << iface) |
| Add the specified interface to the IF_SET pointed to by set. | |
| #define | IF_CLEAR(iface, set) (*set &= ~(1 << iface)) |
| Remove the specified interface from the IF_SET pointed to by set. | |
| #define | IF_ZERO(set) (*set = 0) |
| Remove all interfaces from the IF_SET pointed to by set. | |
| #define | IF_ISSET(iface, set) (*set & (1 << iface)) |
| Returns non-zero if the specified interface is set in the IF_SET pointed to by set. | |
| #define | COM_BLOCK -1 |
| pass to com_select() to block until an interface becomes readable | |
| #define | COM_NOBLOCK 0 |
| pass to com_select() to return immediately | |
| typedef uint8_t | IF_SET |
| represents a set of interfaces | |
| uint8_t | com_select (IF_SET *iset, uint32_t msec) |
| Check a set of interfaces for valid data. | |
COM Modes | |
| These values can be passed to the com_mode() function for each com interface. Note that not all interfaces support every mode. | |
| enum | { IF_OFF = 0, IF_STANDBY, IF_IDLE, IF_LISTEN } |
| The possible mode settings for interface devices. More... | |
Defines | |
| #define | CC1000_CSMA |
| #define | GET_RSSI |
| #define | COM_DATA_SIZE 90 |
| #define | NUM_BUFS 5 |
| #define | com_send_IFACE_STDIO com_send_IFACE_SERIAL |
| for cross platform compatibilty, IFACE_STDIO resolves to either IFACE_SERIAL or IFACE_SERIAL2 -- whichever interface will output to the terminal -- depending on the platform. This macro aliases the com_send function. | |
| #define | com_ioctl_IFACE_STDIO com_ioctl_IFACE_SERIAL |
| for cross platform compatibilty, IFACE_STDIO resolves to either IFACE_SERIAL or IFACE_SERIAL2 -- whichever interface will output to the terminal -- depending on the platform. This macro aliases the com_ioctl function. | |
| #define | com_mode_IFACE_STDIO com_mode_IFACE_SERIAL |
| for cross platform compatibilty, IFACE_STDIO resolves to either IFACE_SERIAL or IFACE_SERIAL2 -- whichever interface will output to the terminal -- depending on the platform. This macro aliases the com_mode function. | |
| #define | PREAMBLE 0x53 |
| #define | PREAMBLE_SIZE 2 |
| #define | com_send(iface, buf) com_send_##iface (buf) |
| Send data over specified interface. Blocks until the data has been transmitted. | |
| #define | com_sendto(iface, buf, dest) com_sendto_##iface(buf,dest) |
| #define | com_ioctl(iface, request, args...) com_ioctl_##iface (request, ##args) |
| Pass ioctl flag and data down to the given interface. | |
| #define | com_mode(iface, mode) com_mode_##iface (mode) |
| Pass the mode setting down to the given interface. | |
| #define | ELFPKT_BYTE0 65 |
| #define | ELFPKT_BYTE1 75 |
| #define | ELFPKT_BYTE2 85 |
| #define | ELFPKT_BYTE3 95 |
Typedefs | |
| typedef comBuf_t | comBuf |
| The standard comBuf data structure is designed to be used across multiple different communication devices. A comBuf contains an array of bytes, the number of bytes, and possibly some other fields, depending on the specific platform. | |
Functions | |
| uint8_t | com_send_IFACE_SERIAL (comBuf *buf) |
| transmit the data in buf over UART0. | |
| void | com_mode_IFACE_SERIAL (uint8_t mode) |
change the mode of the UART0 interface. Accepted parameters are:
| |
| void | com_ioctl_IFACE_SERIAL (uint8_t request,...) |
| currently unsupported for the serial interface. | |
| uint8_t | com_send_IFACE_SERIAL2 (comBuf *buf) |
| transmit the data in buf over UART1. | |
| void | com_mode_IFACE_SERIAL2 (uint8_t mode) |
change the mode of the UART1 interface. Accepted parameters are:
| |
| void | com_ioctl_IFACE_SERIAL2 (uint8_t request,...) |
| currently unsupported for the serial interface. | |
| uint8_t | com_send_IFACE_RADIO (comBuf *buf) |
| transmit the contents of buf over the radio. | |
| void | com_mode_IFACE_RADIO (uint8_t mode) |
change the power status of the radio. Valid parameters are:
| |
| void | com_ioctl_IFACE_RADIO (uint8_t request,...) |
send an device-specific IO Control request to the radio. Valid parameters are:
| |
| uint8_t | com_init () |
| void | com_flush (uint8_t iface) |
| Flush the packets on a particular interface. | |
| comBuf * | com_recv (uint8_t iface) |
| Receive data from a specified interface. Blocks until a packet is available. It is important that once the received comBuf has been handled that the application call com_free_buf(buf) to release the buffer back to the system. | |
| comBuf * | com_recv_timed (uint8_t iface, uint32_t msecs) |
| Receive data from a specified interface. If no data is received in the specified amount of time, the call will return. | |
| void | com_free_buf (comBuf *buf) |
| Release a buffer returned by com_recv or com_recv_timed back to the system. If buffers are not released with this method, The system will run out of buffers and not be able to receive data. | |
| void | com_swap_bufs (uint8_t iface, comBuf *buf, comBuf **ret) |
| This is called by a driver when it has a full recv buffer. Also called by a driver to just get another buffer, in which case buf is null. | |
| void | buf_insert16 (uint8_t *p, uint16_t pos, uint16_t word) |
| Insert a uint16_t into an array of bytes in little endian byte order. | |
| void | buf_insert32 (uint8_t *p, uint16_t pos, uint32_t dword) |
| Insert a uint32_t into an array of bytes in little endian byte order. | |
| uint16_t | buf_extract16 (uint8_t *p, uint16_t pos) |
| Extracts a little endian uint16_t from an array of bytes. | |
| uint32_t | buf_extract32 (uint8_t *p, uint16_t pos) |
| Extracts a little endian uint32_t from an array of bytes. | |
| char | is_elf_packet (comBuf *buf) |
Variables | |
| mos_mutex_t | if_send_mutexes [MAX_IFS] |
Definition in file com.h.
1.4.6