2010-11-19 20:10:09 +01:00
|
|
|
#ifndef TRANSCEIVER_H
|
|
|
|
#define TRANSCEIVER_H
|
|
|
|
|
2010-11-23 11:37:13 +01:00
|
|
|
#include <radio/types.h>
|
|
|
|
|
2010-11-21 14:00:24 +01:00
|
|
|
/* Stack size for transceiver thread */
|
2013-04-15 20:08:46 +02:00
|
|
|
#ifndef TRANSCEIVER_STACK_SIZE
|
2010-12-10 18:00:31 +01:00
|
|
|
#ifdef ENABLE_DEBUG
|
|
|
|
#define TRANSCEIVER_STACK_SIZE (2048)
|
|
|
|
#else
|
2010-12-03 18:42:03 +01:00
|
|
|
#define TRANSCEIVER_STACK_SIZE (512)
|
2010-12-10 18:00:31 +01:00
|
|
|
#endif
|
2013-04-15 20:08:46 +02:00
|
|
|
#endif
|
2010-11-19 20:10:09 +01:00
|
|
|
|
2013-06-10 12:40:59 +02:00
|
|
|
#ifdef MODULE_CC2420
|
|
|
|
#define PAYLOAD_SIZE (118)
|
|
|
|
#else
|
2011-01-04 10:25:16 +01:00
|
|
|
#define PAYLOAD_SIZE (58)
|
2013-06-10 12:40:59 +02:00
|
|
|
#endif
|
2010-11-21 14:00:24 +01:00
|
|
|
/* The maximum of threads to register */
|
2010-12-03 18:42:03 +01:00
|
|
|
#define TRANSCEIVER_MAX_REGISTERED (4)
|
2010-11-21 14:00:24 +01:00
|
|
|
|
2010-11-27 19:27:05 +01:00
|
|
|
/* The size of the message queue between driver and transceiver (must be power
|
|
|
|
* of two */
|
2010-12-03 18:42:03 +01:00
|
|
|
#define TRANSCEIVER_MSG_BUFFER_SIZE (32)
|
2010-11-27 19:27:05 +01:00
|
|
|
|
2013-06-10 12:40:59 +02:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Data type for transceiver specification
|
|
|
|
*/
|
|
|
|
typedef uint16_t transceiver_type_t;
|
|
|
|
|
2010-11-21 14:00:24 +01:00
|
|
|
/**
|
|
|
|
* @brief Message types for transceiver interface
|
|
|
|
*/
|
2010-11-19 20:10:09 +01:00
|
|
|
enum transceiver_msg_type_t {
|
2012-02-08 17:14:50 +01:00
|
|
|
/* Message types for driver <-> transceiver communication */
|
2010-11-24 11:20:27 +01:00
|
|
|
RCV_PKT_CC1020, ///< packet was received by CC1020 transceiver
|
|
|
|
RCV_PKT_CC1100, ///< packet was received by CC1100 transceiver
|
2013-06-10 12:40:59 +02:00
|
|
|
RCV_PKT_CC2420, ///< packet was received by CC2420 transceiver
|
2010-11-23 11:37:13 +01:00
|
|
|
|
2012-02-08 17:14:50 +01:00
|
|
|
/* Message types for transceiver <-> upper layer communication */
|
2010-11-23 11:37:13 +01:00
|
|
|
PKT_PENDING, ///< packet pending in transceiver buffer
|
2010-11-21 14:00:24 +01:00
|
|
|
SND_PKT, ///< request for sending a packet
|
|
|
|
SND_ACK, ///< request for sending an acknowledgement
|
2010-11-23 11:37:13 +01:00
|
|
|
SWITCH_RX, ///< switch transceiver to RX sate
|
|
|
|
POWERDOWN, ///< power down transceiver
|
2010-11-24 21:45:38 +01:00
|
|
|
GET_CHANNEL, ///< Get current channel
|
|
|
|
SET_CHANNEL, ///< Set a new channel
|
2010-11-26 10:23:46 +01:00
|
|
|
GET_ADDRESS, ///< Get the radio address
|
|
|
|
SET_ADDRESS, ///< Set the radio address
|
2010-11-27 10:50:18 +01:00
|
|
|
SET_MONITOR, ///< Set transceiver to monitor mode (disable address checking)
|
2013-06-10 12:40:59 +02:00
|
|
|
GET_PAN, ///< Get current pan
|
|
|
|
SET_PAN, ///< Set a new pan
|
2010-11-23 11:37:13 +01:00
|
|
|
|
2012-02-08 17:14:50 +01:00
|
|
|
/* debug message types */
|
|
|
|
DBG_IGN, ///< add a physical address to the ignore list
|
|
|
|
|
2010-11-23 11:37:13 +01:00
|
|
|
/* Error messages */
|
2010-11-26 17:06:54 +01:00
|
|
|
ENOBUFFER, ///< No buffer left
|
2010-11-19 20:10:09 +01:00
|
|
|
};
|
|
|
|
|
2010-11-21 14:00:24 +01:00
|
|
|
/**
|
|
|
|
* @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;
|
2010-11-19 20:10:09 +01:00
|
|
|
|
2010-11-21 14:00:24 +01:00
|
|
|
typedef struct {
|
|
|
|
transceiver_type_t transceivers;
|
2010-11-24 21:45:38 +01:00
|
|
|
void *data;
|
|
|
|
} transceiver_command_t;;
|
2010-11-19 20:10:09 +01:00
|
|
|
|
2010-11-27 11:09:42 +01:00
|
|
|
/* The transceiver thread's pid */
|
|
|
|
extern int transceiver_pid;
|
2010-11-19 20:10:09 +01:00
|
|
|
|
2010-11-21 14:00:24 +01:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2010-11-23 11:37:13 +01:00
|
|
|
int transceiver_start(void);
|
2010-11-21 14:00:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
* return 1 on success, 0 otherwise
|
|
|
|
*/
|
|
|
|
uint8_t transceiver_register(transceiver_type_t transceivers, int pid);
|
|
|
|
|
2010-11-19 20:10:09 +01:00
|
|
|
#endif /* TRANSCEIVER_H */
|