1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/include/transceiver.h

198 lines
5.5 KiB
C
Raw Normal View History

/**
* @defgroup sys_transceiver Transceiver
* @ingroup sys
* @brief Transceiver library
*/
#ifndef TRANSCEIVER_H
#define TRANSCEIVER_H
2013-08-14 17:52:27 +02:00
#include "radio/types.h"
/* supported transceivers *
* NOTE: necessary to include here again due to
* https://github.com/RIOT-OS/RIOT/issues/117 */
#ifdef MODULE_CC110X
#include "cc110x.h"
#endif
#ifdef MODULE_CC110X_NG
2013-08-14 17:52:27 +02:00
#include "cc110x_ng.h"
#endif
#ifdef MODULE_CC2420
2013-08-14 17:52:27 +02:00
#include "cc2420.h"
#endif
#ifdef MODULE_MC1322X
2013-08-14 17:52:27 +02:00
#include "mc1322x.h"
#include "maca.h"
#include "maca_packet.h"
#endif
#ifdef MODULE_NATIVENET
#include "nativenet.h"
#include "nativenet_internal.h"
#endif
#ifdef MODULE_AT86RF231
2013-12-16 17:54:58 +01:00
#include "at86rf231.h"
#endif
/* Stack size for transceiver thread */
2013-04-15 20:08:46 +02:00
#ifndef TRANSCEIVER_STACK_SIZE
#define TRANSCEIVER_STACK_SIZE (KERNEL_CONF_STACKSIZE_DEFAULT)
2013-04-15 20:08:46 +02:00
#endif
2013-08-15 13:51:40 +02:00
#ifndef PAYLOAD_SIZE
#define PAYLOAD_SIZE (0)
2013-08-15 13:51:40 +02:00
#endif
#ifdef MODULE_CC110X
#if (CC1100_MAX_DATA_LENGTH > PAYLOAD_SIZE)
#undef PAYLOAD_SIZE
#define PAYLOAD_SIZE (CC1100_MAX_DATA_LENGTH)
#endif
#endif
#ifdef MODULE_CC110X_NG
#if (CC1100_MAX_DATA_LENGTH > PAYLOAD_SIZE)
#undef PAYLOAD_SIZE
#define PAYLOAD_SIZE (CC1100_MAX_DATA_LENGTH)
#endif
#endif
#ifdef MODULE_CC2420
#if (CC2420_MAX_DATA_LENGTH > PAYLOAD_SIZE)
#undef PAYLOAD_SIZE
#define PAYLOAD_SIZE (CC2420_MAX_DATA_LENGTH)
#endif
#endif
#ifdef MODULE_AT86RF231
#if (AT86RF231_MAX_DATA_LENGTH > PAYLOAD_SIZE)
#undef PAYLOAD_SIZE
#define PAYLOAD_SIZE (AT86RF231_MAX_DATA_LENGTH)
#endif
#endif
#ifdef MODULE_MC1322X
#if (MC1322X_MAX_DATA_LENGTH > PAYLOAD_SIZE)
#undef PAYLOAD_SIZE
#define PAYLOAD_SIZE (MC1322X_MAX_DATA_LENGTH)
#endif
#endif
2013-08-08 11:08:33 +02:00
#ifdef MODULE_NATIVENET
#if (NATIVE_MAX_DATA_LENGTH > PAYLOAD_SIZE)
#undef PAYLOAD_SIZE
2013-08-08 11:08:33 +02:00
#define PAYLOAD_SIZE (NATIVE_MAX_DATA_LENGTH)
#endif
#endif
/* The maximum of threads to register */
#define TRANSCEIVER_MAX_REGISTERED (4)
/* The size of the message queue between driver and transceiver (must be power
* of two */
#define TRANSCEIVER_MSG_BUFFER_SIZE (32)
/**
* @brief All supported transceivers
*/
#define TRANSCEIVER_NONE (0x0) ///< Invalid
#define TRANSCEIVER_CC1100 (0x01) ///< CC110X transceivers
#define TRANSCEIVER_CC1020 (0x02) ///< CC1020 transceivers
#define TRANSCEIVER_CC2420 (0x04) ///< CC2420 transceivers
#define TRANSCEIVER_MC1322X (0x08) ///< MC1322X transceivers
#define TRANSCEIVER_NATIVE (0x10) ///< NATIVE transceivers
#define TRANSCEIVER_AT86RF231 (0x20) ///< AT86RF231 transceivers
/**
* @brief Data type for transceiver specification
*/
typedef uint16_t transceiver_type_t;
/**
* @brief Data type to represent the transceiver's EUI-64.
*/
typedef uint64_t transceiver_eui64_t;
/**
* @brief Message types for transceiver interface
*/
enum transceiver_msg_type_t {
/* Message types for driver <-> transceiver communication */
RCV_PKT_CC1020, ///< packet was received by CC1020 transceiver
RCV_PKT_CC1100, ///< packet was received by CC1100 transceiver
RCV_PKT_CC2420, ///< packet was received by CC2420 transceiver
RCV_PKT_MC1322X, ///< packet was received by mc1322x transceiver
RCV_PKT_NATIVE, ///< packet was received by native transceiver
RCV_PKT_AT86RF231, ///< packet was received by AT86RF231 transceiver
/* Message types for transceiver <-> upper layer communication */
PKT_PENDING, ///< packet pending in transceiver buffer
SND_PKT, ///< request for sending a packet
SND_ACK, ///< request for sending an acknowledgement
SWITCH_RX, ///< switch transceiver to RX sate
POWERDOWN, ///< power down transceiver
GET_CHANNEL, ///< Get current channel
SET_CHANNEL, ///< Set a new channel
GET_ADDRESS, ///< Get the radio address
SET_ADDRESS, ///< Set the radio address
GET_LONG_ADDR, ///< Get the long radio address, if existing
SET_LONG_ADDR, ///< Set the long radio address, if supported by hardware
SET_MONITOR, ///< Set transceiver to monitor mode (disable address checking)
GET_PAN, ///< Get current pan
SET_PAN, ///< Set a new pan
/* debug message types */
DBG_IGN, ///< add a physical address to the ignore list
/* Error messages */
ENOBUFFER, ///< No buffer left
/* reserve message types for higher layer notifications */
UPPER_LAYER_1, ///< reserved
UPPER_LAYER_2, ///< reserved
UPPER_LAYER_3, ///< reserved
UPPER_LAYER_4, ///< reserved
UPPER_LAYER_5, ///< reserved
};
/**
* @brief Manage registered threads per transceiver
*/
typedef struct {
transceiver_type_t transceivers; ///< the tranceivers the thread is registered for
int pid; ///< the thread's pid
} registered_t;
typedef struct {
transceiver_type_t transceivers;
void *data;
2013-08-09 10:26:00 +02:00
} transceiver_command_t;
/* The transceiver thread's pid */
extern int transceiver_pid;
/**
* @brief Initializes the transceiver module for certain transceiver types
*
* @param transceivers Specifies all transceivers to init
**/
void transceiver_init(transceiver_type_t transceivers);
/**
* @brief Runs the transceiver thread
2013-08-16 13:12:12 +02:00
*
* @return The transceiver thread's pid
*/
int transceiver_start(void);
/**
* @brief register a thread for events from certain transceivers
*
* @param transceivers The transceiver types to register for
* @param pid The pid of the thread to register
*
2013-08-16 13:12:12 +02:00
* @return 1 on success, 0 otherwise
*/
uint8_t transceiver_register(transceiver_type_t transceivers, int pid);
#endif /* TRANSCEIVER_H */