48 #include "dev/cc2420_const.h"
50 int cc2420_init(
void);
52 #define CC2420_MAX_PACKET_LEN 127
54 int cc2420_set_channel(
int channel);
55 int cc2420_get_channel(
void);
57 void cc2420_set_pan_addr(
unsigned pan,
59 const uint8_t *ieee_addr);
61 extern signed char cc2420_last_rssi;
62 extern uint8_t cc2420_last_correlation;
64 int cc2420_rssi(
void);
71 void cc2420_set_txpower(uint8_t power);
72 int cc2420_get_txpower(
void);
73 #define CC2420_TXPOWER_MAX 31
74 #define CC2420_TXPOWER_MIN 0
80 int cc2420_interrupt(
void);
83 extern rtimer_clock_t cc2420_time_of_arrival,
84 cc2420_time_of_departure;
85 extern int cc2420_authority_level_of_sender;
90 void cc2420_set_cca_threshold(
int value);
96 #define CC2420_STROBE(s) \
98 CC2420_SPI_ENABLE(); \
100 CC2420_SPI_DISABLE(); \
106 #define CC2420_WRITE_REG(adr,data) \
108 CC2420_SPI_ENABLE(); \
109 SPI_WRITE_FAST(adr); \
110 SPI_WRITE_FAST((uint8_t)((data) >> 8)); \
111 SPI_WRITE_FAST((uint8_t)(data & 0xff)); \
112 SPI_WAITFORTx_ENDED(); \
114 CC2420_SPI_DISABLE(); \
118 #define CC2420_READ_REG(adr,data) \
120 CC2420_SPI_ENABLE(); \
121 SPI_WRITE(adr | 0x40); \
122 data = (uint8_t)SPI_RXBUF; \
125 data = SPI_RXBUF << 8; \
129 CC2420_SPI_DISABLE(); \
132 #define CC2420_READ_FIFO_BYTE(data) \
134 CC2420_SPI_ENABLE(); \
135 SPI_WRITE(CC2420_RXFIFO | 0x40); \
139 CC2420_SPI_DISABLE(); \
142 #define CC2420_READ_FIFO_BUF(buffer,count) \
145 CC2420_SPI_ENABLE(); \
146 SPI_WRITE(CC2420_RXFIFO | 0x40); \
148 for(i = 0; i < (count); i++) { \
149 SPI_READ(((uint8_t *)(buffer))[i]); \
152 CC2420_SPI_DISABLE(); \
155 #define CC2420_WRITE_FIFO_BUF(buffer,count) \
158 CC2420_SPI_ENABLE(); \
159 SPI_WRITE_FAST(CC2420_TXFIFO); \
160 for(i = 0; i < (count); i++) { \
161 SPI_WRITE_FAST(((uint8_t *)(buffer))[i]); \
163 SPI_WAITFORTx_ENDED(); \
164 CC2420_SPI_DISABLE(); \
168 #define CC2420_WRITE_RAM(buffer,adr,count) \
171 CC2420_SPI_ENABLE(); \
172 SPI_WRITE_FAST(0x80 | ((adr) & 0x7f)); \
173 SPI_WRITE_FAST(((adr) >> 1) & 0xc0); \
174 for(i = 0; i < (count); i++) { \
175 SPI_WRITE_FAST(((uint8_t*)(buffer))[i]); \
177 SPI_WAITFORTx_ENDED(); \
178 CC2420_SPI_DISABLE(); \
182 #define CC2420_READ_RAM(buffer,adr,count) \
185 CC2420_SPI_ENABLE(); \
186 SPI_WRITE(0x80 | ((adr) & 0x7f)); \
187 SPI_WRITE((((adr) >> 1) & 0xc0) | 0x20); \
189 for(i = 0; i < (count); i++) { \
190 SPI_READ(((uint8_t*)(buffer))[i]); \
192 CC2420_SPI_DISABLE(); \
196 #define CC2420_GET_STATUS(s) \
198 CC2420_SPI_ENABLE(); \
199 SPI_WRITE(CC2420_SNOP); \
201 CC2420_SPI_DISABLE(); \