00001 /* 00002 * Copyright Droids Corporation (2008) 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 */ 00019 00020 /* 00021 * Author : Julien LE GUEN - jlg@jleguen.info 00022 */ 00023 00024 #ifndef _CC2420_H_ 00025 #define _CC2420_H_ 00026 00027 00028 /* Convenient macro to ckeck status bits */ 00029 #define CC2420_STATUS_CHECK(bit) ((cc2420_get_status() & _BV(bit)) >> (bit)) 00030 00031 00032 00033 /* 00034 * Initialize the CC2420 00035 */ 00036 void cc2420_init(void); 00037 00038 /* 00039 * Get CC2420's status byte 00040 */ 00041 uint8_t cc2420_get_status(void); 00042 00043 /* 00044 * Write to a strobe register 00045 * Returns Status byte 00046 */ 00047 inline uint8_t cc2420_strobe_register(uint8_t reg); 00048 00049 /* Read and Write from/to a register */ 00050 inline uint16_t cc2420_read_register(uint8_t reg); 00051 inline void cc2420_write_register(uint8_t reg, uint16_t value); 00052 00053 /* 00054 * Write the contents of a buffer to TXFIFO 00055 * Returns last read status byte 00056 */ 00057 uint8_t cc2420_write_txfifo(uint8_t *buffer, uint8_t length); 00058 00059 /* 00060 * Write the contents of a buffer to RXFIFO 00061 * Returns last read status byte 00062 */ 00063 uint8_t cc2420_write_rxfifo(uint8_t *buffer, uint8_t length); 00064 00065 /* 00066 * Read the contents of RXFIFO into a buffer 00067 */ 00068 void cc2420_read_rxfifo(uint8_t *buffer, uint8_t length); 00069 00070 /* 00071 * Write to a RAM address one or several byte(s) 00072 * /!\ This is NOT foolproof, you have to be sure of the 00073 * address you write to, and the length of your buffer 00074 */ 00075 void cc2420_write_ram(uint16_t addr, uint8_t *buffer, uint16_t length); 00076 00077 /* 00078 * Read from RAM. Same warning. 00079 */ 00080 void cc2420_read_ram(uint16_t addr, uint8_t *buffer, uint16_t length); 00081 00082 00083 #endif /* _CC2420_H_ */