📄 cc2420.h
字号:
// This file is part of MANTIS OS, Operating System// See http://mantis.cs.colorado.edu///// Copyright (C) 2003,2004,2005 University of Colorado, Boulder//// This program is free software; you can redistribute it and/or// modify it under the terms of the mos license (see file LICENSE)/** @file cc2420.h * @brief Mac layer for the CC2420 radio */#include "mos.h"#include "com.h"#include <stdarg.h>#ifdef PLATFORM_TELOSB#define CC2420_RESET_PORT 4#define CC2420_RESET_PIN 6#define CC2420_RESET CC2420_RESET_PORT, CC2420_RESET_PIN#define CC2420_VREG_PORT 4#define CC2420_VREG_PIN 5#define CC2420_VREG CC2420_VREG_PORT, CC2420_VREG_PIN#define CC2420_CHIP_SELECT_PORT 4#define CC2420_CHIP_SELECT_PIN 2#define CC2420_CHIP_SELECT CC2420_CHIP_SELECT_PORT, CC2420_CHIP_SELECT_PIN#define CC2420_SPI_CLOCK_PORT 3#define CC2420_SPI_CLOCK_PIN 3#define CC2420_SPI_CLOCK CC2420_SPI_CLOCK_PORT, CC2420_SPI_CLOCK_PIN#define CC2420_MOSI_PORT 3#define CC2420_MOSI_PIN 1#define CC2420_MOSI CC2420_MOSI_PORT, CC2420_MOSI_PIN#define CC2420_MISO_PORT 3#define CC2420_MISO_PIN 2#define CC2420_MISO CC2420_MISO_PORT, CC2420_MISO_PIN#define CC2420_FIFO_PORT 1#define CC2420_FIFO_PIN 3#define CC2420_FIFO CC2420_FIFO_PORT, CC2420_FIFO_PIN#define CC2420_SFD_PORT 4#define CC2420_SFD_PIN 1#define CC2420_SFD CC2420_SFD_PORT, CC2420_SFD_PIN#define CC2420_CCA_PORT 1#define CC2420_CCA_PIN 4#define CC2420_CCA CC2420_CCA_PORT, CC2420_CCA_PIN#define CC2420_FIFOP_PORT 1#define CC2420_FIFOP_PIN 0#define CC2420_FIFOP CC2420_FIFOP_PORT, CC2420_FIFOP_PIN#define CC2420_FIFOP_INTERRUPT() interrupt (PORT1_VECTOR) fifop_int()#else#define CC2420_RESET_PORT A#define CC2420_RESET_PIN 6#define CC2420_RESET CC2420_RESET_PORT, CC2420_RESET_PIN#define CC2420_VREG_PORT A#define CC2420_VREG_PIN 5#define CC2420_VREG CC2420_VREG_PORT, CC2420_VREG_PIN#define CC2420_CHIP_SELECT_PORT B#define CC2420_CHIP_SELECT_PIN 0#define CC2420_CHIP_SELECT CC2420_CHIP_SELECT_PORT, CC2420_CHIP_SELECT_PIN#define CC2420_SPI_CLOCK_PORT B#define CC2420_SPI_CLOCK_PIN 1#define CC2420_SPI_CLOCK CC2420_SPI_CLOCK_PORT, CC2420_SPI_CLOCK_PIN#define CC2420_MOSI_PORT B#define CC2420_MOSI_PIN 2#define CC2420_MOSI CC2420_MOSI_PORT, CC2420_MOSI_PIN#define CC2420_MISO_PORT B#define CC2420_MISO_PIN 3#define CC2420_MISO CC2420_MISO_PORT, CC2420_MISO_PIN#define CC2420_FIFO_PORT B#define CC2420_FIFO_PIN 7#define CC2420_FIFO CC2420_FIFO_PORT, CC2420_FIFO_PIN#define CC2420_SFD_PORT D#define CC2420_SFD_PIN 4#define CC2420_SFD CC2420_SFD_PORT, CC2420_SFD_PIN#define CC2420_CCA_PORT D#define CC2420_CCA_PIN 6#define CC2420_CCA CC2420_CCA_PORT, CC2420_CCA_PIN#define CC2420_FIFOP_PORT E#define CC2420_FIFOP_PIN 6#define CC2420_FIFOP CC2420_FIFOP_PORT, CC2420_FIFOP_PIN#define CC2420_FIFOP_INTERRUPT() SIGNAL(SIG_INTERRUPT6)#endif// CC2420 register constants#define CC2420_SNOP 0x00#define CC2420_SXOSCON 0x01#define CC2420_STXCAL 0x02#define CC2420_SRXON 0x03#define CC2420_STXON 0x04#define CC2420_STXONCCA 0x05#define CC2420_SRFOFF 0x06#define CC2420_SXOSCOFF 0x07#define CC2420_SFLUSHRX 0x08#define CC2420_SFLUSHTX 0x09#define CC2420_SACK 0x0A#define CC2420_SACKPEND 0x0B#define CC2420_SRXDEC 0x0C#define CC2420_STXENC 0x0D#define CC2420_SAES 0x0E#define CC2420_MAIN 0x10#define CC2420_MDMCTRL0 0x11#define CC2420_MDMCTRL1 0x12#define CC2420_RSSI 0x13#define CC2420_SYNCWORD 0x14#define CC2420_TXCTRL 0x15#define CC2420_RXCTRL0 0x16#define CC2420_RXCTRL1 0x17#define CC2420_FSCTRL 0x18#define CC2420_SECCTRL0 0x19#define CC2420_SECCTRL1 0x1A#define CC2420_BATTMON 0x1B#define CC2420_IOCFG0 0x1C#define CC2420_IOCFG1 0x1D#define CC2420_MANFIDL 0x1E#define CC2420_MANFIDH 0x1F#define CC2420_FSMTC 0x20#define CC2420_MANAND 0x21#define CC2420_MANOR 0x22#define CC2420_AGCCTRL 0x23#define CC2420_AGCTST0 0x24#define CC2420_AGCTST1 0x25#define CC2420_AGCTST2 0x26#define CC2420_FSTST0 0x27#define CC2420_FSTST1 0x28#define CC2420_FSTST2 0x29#define CC2420_FSTST3 0x2A#define CC2420_RXBPFTST 0x2B#define CC2420_FSMSTATE 0x2C#define CC2420_ADCTST 0x2D#define CC2420_DACTST 0x2E#define CC2420_TOPTST 0x2F#define CC2420_RESERVED 0x30#define CC2420_TXFIFO 0x3E#define CC2420_RXFIFO 0x3F// Memory// Sizes#define CC2420_RAM_SIZE 368#define CC2420_FIFO_SIZE 128// Addresses#define CC2420RAM_TXFIFO 0x000#define CC2420RAM_RXFIFO 0x080#define CC2420RAM_KEY0 0x100#define CC2420RAM_RXNONCE 0x110#define CC2420RAM_SABUF 0x120#define CC2420RAM_KEY1 0x130#define CC2420RAM_TXNONCE 0x140#define CC2420RAM_CBCSTATE 0x150#define CC2420RAM_IEEEADDR 0x160#define CC2420RAM_PANID 0x168#define CC2420RAM_SHORTADDR 0x16A// Status byte#define CC2420_XOSC16M_STABLE 6#define CC2420_TX_UNDERFLOW 5#define CC2420_ENC_BUSY 4#define CC2420_TX_ACTIVE 3#define CC2420_LOCK 2#define CC2420_RSSI_VALID 1// SECCTRL0#define CC2420_SECCTRL0_NO_SECURITY 0x0000#define CC2420_SECCTRL0_CBC_MAC 0x0001#define CC2420_SECCTRL0_CTR 0x0002#define CC2420_SECCTRL0_CCM 0x0003#define CC2420_SECCTRL0_SEC_M_IDX 2#define CC2420_SECCTRL0_RXKEYSEL0 0x0000#define CC2420_SECCTRL0_RXKEYSEL1 0x0020#define CC2420_SECCTRL0_TXKEYSEL0 0x0000#define CC2420_SECCTRL0_TXKEYSEL1 0x0040#define CC2420_SECCTRL0_SEC_CBC_HEAD 0x0100#define CC2420_SECCTRL0_RXFIFO_PROTECTION 0x0200#define CC2420_MODE_TX 0#define CC2420_MODE_RX 1#define CC2420_MODE_PD 2#define CC2420_MODE_SLEEP 3/** @brief Initialization routine for CC2420 */void cc2420_init(void);void cc2420_wait_for_osc(void);/** @brief Changes the channel which the CC2420 transmits and receives on */void cc2420_set_channel(uint8_t chan);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -