mos/com/include/cc2420.h

Go to the documentation of this file.
00001 //  This file is part of MOS, the MANTIS Operating System
00002 //  See http://mantis.cs.colorado.edu/
00003 //
00004 //  Copyright (c) 2002 - 2007 University of Colorado, Boulder
00005 //
00006 //   All rights reserved.
00007 //
00008 //   Redistribution and use in source and binary forms, with or without
00009 //   modification, are permitted provided that the following conditions are
00010 //   met:
00011 //
00012 //       * Redistributions of source code must retain the above copyright
00013 //         notice, this list of conditions and the following disclaimer.
00014 //       * Redistributions in binary form must reproduce the above
00015 //         copyright notice, this list of conditions and the following
00016 //         disclaimer in the documentation and/or other materials provided
00017 //         with the distribution. 
00018 //       * Neither the name of the MANTIS Project nor the names of its
00019 //         contributors may be used to endorse or promote products derived
00020 //         from this software without specific prior written permission.
00021 //
00022 //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025 //   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00026 //   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 //   BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 //   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 //   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 //   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 //   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 //   POSSIBILITY OF SUCH DAMAGE.
00034 
00039 #include "mos.h"
00040 #include "com.h"
00041 
00042 #include <stdarg.h>
00043 
00044 //      CC2420 register constants
00045 #define CC2420_SNOP             0x00
00046 #define CC2420_SXOSCON          0x01
00047 #define CC2420_STXCAL           0x02
00048 #define CC2420_SRXON            0x03
00049 #define CC2420_STXON            0x04
00050 #define CC2420_STXONCCA         0x05
00051 #define CC2420_SRFOFF           0x06
00052 #define CC2420_SXOSCOFF         0x07
00053 #define CC2420_SFLUSHRX         0x08
00054 #define CC2420_SFLUSHTX         0x09
00055 #define CC2420_SACK             0x0A
00056 #define CC2420_SACKPEND         0x0B
00057 #define CC2420_SRXDEC           0x0C
00058 #define CC2420_STXENC           0x0D
00059 #define CC2420_SAES             0x0E
00060 
00061 #define CC2420_MAIN             0x10
00062 #define CC2420_MDMCTRL0         0x11
00063 #define CC2420_MDMCTRL1         0x12
00064 #define CC2420_RSSI             0x13
00065 #define CC2420_SYNCWORD         0x14
00066 #define CC2420_TXCTRL           0x15
00067 #define CC2420_RXCTRL0          0x16
00068 #define CC2420_RXCTRL1          0x17
00069 #define CC2420_FSCTRL           0x18
00070 #define CC2420_SECCTRL0         0x19
00071 #define CC2420_SECCTRL1         0x1A
00072 #define CC2420_BATTMON          0x1B
00073 #define CC2420_IOCFG0           0x1C
00074 #define CC2420_IOCFG1           0x1D
00075 #define CC2420_MANFIDL          0x1E
00076 #define CC2420_MANFIDH          0x1F
00077 #define CC2420_FSMTC            0x20
00078 #define CC2420_MANAND           0x21
00079 #define CC2420_MANOR            0x22
00080 #define CC2420_AGCCTRL          0x23
00081 #define CC2420_AGCTST0          0x24
00082 #define CC2420_AGCTST1          0x25
00083 #define CC2420_AGCTST2          0x26
00084 #define CC2420_FSTST0           0x27
00085 #define CC2420_FSTST1           0x28
00086 #define CC2420_FSTST2           0x29
00087 #define CC2420_FSTST3           0x2A
00088 #define CC2420_RXBPFTST         0x2B
00089 #define CC2420_FSMSTATE         0x2C
00090 #define CC2420_ADCTST           0x2D
00091 #define CC2420_DACTST           0x2E
00092 #define CC2420_TOPTST           0x2F
00093 #define CC2420_RESERVED         0x30
00094 
00095 #define CC2420_TXFIFO           0x3E
00096 #define CC2420_RXFIFO           0x3F
00097 
00098 // Memory
00099 // Sizes
00100 #define CC2420_RAM_SIZE                 368
00101 #define CC2420_FIFO_SIZE                128
00102 // Addresses
00103 #define CC2420RAM_TXFIFO                0x000
00104 #define CC2420RAM_RXFIFO                0x080
00105 #define CC2420RAM_KEY0                  0x100
00106 #define CC2420RAM_RXNONCE               0x110
00107 #define CC2420RAM_SABUF                 0x120
00108 #define CC2420RAM_KEY1                  0x130
00109 #define CC2420RAM_TXNONCE               0x140
00110 #define CC2420RAM_CBCSTATE              0x150
00111 #define CC2420RAM_IEEEADDR              0x160
00112 #define CC2420RAM_PANID                 0x168
00113 #define CC2420RAM_SHORTADDR             0x16A
00114 
00115 // Status byte
00116 #define CC2420_XOSC16M_STABLE           6
00117 #define CC2420_TX_UNDERFLOW             5
00118 #define CC2420_ENC_BUSY                 4
00119 #define CC2420_TX_ACTIVE                3
00120 #define CC2420_LOCK                     2
00121 #define CC2420_RSSI_VALID               1
00122 
00123 // SECCTRL0
00124 #define CC2420_SECCTRL0_NO_SECURITY         0x0000
00125 #define CC2420_SECCTRL0_CBC_MAC             0x0001
00126 #define CC2420_SECCTRL0_CTR                 0x0002
00127 #define CC2420_SECCTRL0_CCM                 0x0003
00128 
00129 #define CC2420_SECCTRL0_SEC_M_IDX           2
00130 
00131 #define CC2420_SECCTRL0_RXKEYSEL0           0x0000
00132 #define CC2420_SECCTRL0_RXKEYSEL1           0x0020
00133 
00134 #define CC2420_SECCTRL0_TXKEYSEL0           0x0000
00135 #define CC2420_SECCTRL0_TXKEYSEL1           0x0040
00136 
00137 #define CC2420_SECCTRL0_SEC_CBC_HEAD        0x0100
00138 #define CC2420_SECCTRL0_RXFIFO_PROTECTION   0x0200
00139 
00140 #define CC2420_MODE_TX    0
00141 #define CC2420_MODE_RX    1
00142 #define CC2420_MODE_PD    2
00143 #define CC2420_MODE_SLEEP 3
00144 
00145 // ioctl's
00146 #define CC2420_LOW_POWER_MODE 1
00147 #define CC2420_HIGH_POWER_MODE 2
00148 
00151 #define CC2420_TX_POWER 3
00152 
00153 //generic setting of radio power
00154 #define RADIO_TX_POWER CC2420_TX_POWER
00155 
00156 
00159 
00162 void cc2420_init(void);
00163 
00168 uint16_t cc2420_get_last_rssi();
00169 
00170 #ifdef ENABLE_AUTOACK
00171 uint8_t cc2420_get_last_send_seq();
00172 uint8_t cc2420_get_last_acked_seq();
00173 #ifdef ENABLE_RETRANSMIT
00174 #define MAX_RETRANSMIT_ATTEMPTS  10
00175 uint8_t cc2420_num_suppressed_dup();
00176 #endif
00177 #endif
00178 
00180 void cc2420_wait_for_osc(void);
00181 
00185 void cc2420_set_channel(uint8_t chan);
00187 

Generated on Mon Nov 23 06:25:59 2009 for MANTIS by  doxygen 1.4.6