test serpi
[aversive.git] / modules / devices / radio / cc2420 / cc2420.h
1 /*  
2  *  Copyright Droids Corporation (2008)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  */
19
20 /*
21  * Author : Julien LE GUEN - jlg@jleguen.info
22  */
23
24 #ifndef _CC2420_H_
25 #define _CC2420_H_
26
27
28 /* Convenient macro to ckeck status bits */
29 #define CC2420_STATUS_CHECK(bit)        ((cc2420_get_status() & _BV(bit)) >> (bit))
30
31
32
33 /*
34  *      Initialize the CC2420
35  */
36 void cc2420_init(void);
37
38 /*
39  *      Get CC2420's status byte
40  */
41 uint8_t cc2420_get_status(void);
42
43 /*
44  * Write to a strobe register
45  * Returns Status byte
46  */
47 inline uint8_t cc2420_strobe_register(uint8_t reg);
48
49 /* Read and Write from/to a register */
50 inline uint16_t cc2420_read_register(uint8_t reg);
51 inline void cc2420_write_register(uint8_t reg, uint16_t value);
52
53 /*
54  * Write the contents of a buffer to TXFIFO
55  * Returns last read status byte
56  */
57 uint8_t cc2420_write_txfifo(uint8_t *buffer, uint8_t length);
58
59 /*
60  * Write the contents of a buffer to RXFIFO
61  * Returns last read status byte
62  */
63 uint8_t cc2420_write_rxfifo(uint8_t *buffer, uint8_t length);
64
65 /*
66  * Read the contents of RXFIFO into a buffer
67  */
68 void cc2420_read_rxfifo(uint8_t *buffer, uint8_t length);
69
70 /*
71  *      Write to a RAM address one or several byte(s)
72  *      /!\ This is NOT foolproof, you have to be sure of the
73  *      address you write to, and the length of your buffer
74  */
75 void cc2420_write_ram(uint16_t addr, uint8_t *buffer, uint16_t length);
76
77 /*
78  *      Read from RAM. Same warning.
79  */
80 void cc2420_read_ram(uint16_t addr, uint8_t *buffer, uint16_t length);
81
82
83 #endif /* _CC2420_H_ */