📄 hal_cc2420db.h
字号:
/*******************************************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON HARDWARE ABSTRACTION LIBRARY FOR THE CC2420 *
* *** + + *** CC2420DB defintion file *
* *** +++ *** *
* *** *** *
* ************ *
* ********** *
* *
*******************************************************************************************************
* The Chipcon Hardware Abstraction Library is a collection of functions, macros and constants, which *
* can be used to ease access to the hardware on the CC2420 and the target microcontroller. *
* *
* This file contains all definitions that are specific for the CC2420DB development platform. *
*******************************************************************************************************
* Compiler: AVR-GCC *
* Target platform: CC2420DB *
*******************************************************************************************************
* Revision history: *
* $Log: hal_cc2420db.h,v $
* Revision 1.11 2004/04/05 14:52:58 jol
* The red and yellow LEDs in the SET_LED_MASK(n) macro have been switched (wrong in the previous version)
*
* Revision 1.10 2004/03/31 11:07:29 oyj
* Added postfix _UART1 to pins CTS and RTS throughout the file
* (error in previous revision)
*
* Revision 1.9 2004/03/30 14:59:03 mbr
* Release for web
*
*
*
*
*******************************************************************************************************/
#ifndef HAL_CC2400DB_H
#define HAL_CC2400DB_H
/*******************************************************************************************************
*******************************************************************************************************
************************** AVR I/O PORTS **************************
*******************************************************************************************************
*******************************************************************************************************/
//Port A
#define RESET_N 6 // PA.6 - Output: RESET_N to CC2420
#define VREG_EN 5 // PA.5 - Output: VREG_EN to CC2420
#define GLED 1 // PB.7 - Output: Green LED
#define RLED 2 // PE.3 - Output: Red LED
#define YLED 0 // PE.4 - Output: Yellow LED
//-------------------------------------------------------------------------------------------------------
// Port B
#define CSN 0 // PB.0 - Output: SPI Chip Select (CS_N)
#define SCK 1 // PB.1 - Output: SPI Serial Clock (SCLK)
#define MOSI 2 // PB.2 - Output: SPI Master out - slave in (MOSI)
#define MISO 3 // PB.3 - Input: SPI Master in - slave out (MISO)
#define OLED 4 // PB.4 - Output: Orange LED
//#define VREG_EN 5 // PB.5 - Output: VREG_EN to CC2420
//#define RESET_N 6 // PB.6 - Output: RESET_N to CC2420
#define FIFO 7 // PB.7 - Output: Green LED
//#define GLED 7 // PB.7 - Output: Green LED
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Port D
//#define FIFOP 0 // PD.0 - Input: FIFOP from CC2420
//#define FIFO 1 // PD.1 - Input: FIFO from CC2420
//#define UART1_RXD 2 // PD.2 - Input: UART1 RXD
//#define UART1_TXD 3 // PD.3 - Output: UART1 TXD
#define SFD 4 // PD.4 - Input: SFD from CC2420
#define UART1_RTS 5 // PD.5 - Output: UART HW handshaking: RTS
#define CCA 6 // PD.6 - Input: CCA from CC2420
#define UART1_CTS 7 // PD.7 - Input: UART HW handshaking: CTS
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Port E
#define UART0_RXD 0 // PE.0 - Input : Joystick up button
#define UART0_TXD 1 // PE.1 - Input : Joystick right
#define FIFOP 6// PE.6 - Input: FIFOP from CC2420
//#define JOYSTICK_UP 0 // PE.0 - Input : Joystick up button
//#define JOYSTICK_RIGHT 1 // PE.1 - Input : Joystick right
#define JOYSTICK_CENTER 2 // PE.2 - Input : Joystick center
//#define RLED 4 // PE.3 - Output: Red LED
//#define YLED 3 // PE.4 - Output: Yellow LED
#define BUTTON 5 // PE.5 - Input : Push button S2
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Port F
#define FIFOP1 1 // PF.1 - Input: Joystick left
//#define JOYSTICK_DOWN 2 // PF.2 - Input: Joystick down
// ADC inputs
#define ADC_INPUT_0_POT_METER 0 // PF.0 - ADC0 with potentiometer
#define ADC_INPUT_1 1 // PF.1 - ADC1
#define ADC_INPUT_2 2 // PF.2 - ADC2
#define ADC_INPUT_3_TEMP_SENSOR 3 // PF.3 - ADC3 with temp sensor
// JTAG interface:
// PF.4 - Input : JTAG TCK serial clock
// PF.5 - Input : JTAG TMS strobe enable
// PF.6 - Output: JTAG TDO serial data output
// PF.7 - Input : JTAG TDI serial data input
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Port G
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// External RAM interface:
// PA and PC - Multiplexed address/data
// PG.0 - Output: Write enable: WR_N
// PG.1 - Output: Read enable: RD_N
// PG.2 - Output: Address Latch Enable: ALE
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Port setup macros
// Port initialization
// Disables pull-up on all inputs!!!
#define PORT_INIT() \
do { \
SFIOR |= BM(PUD); \
DDRA=BM(YLED)|BM(GLED)|BM(RLED) |BM(VREG_EN) |BM(RESET_N); \
PORTA=BM(YLED)|BM(GLED)|BM(RLED) |BM(VREG_EN) |BM(RESET_N);\
DDRB = BM(MOSI) | BM(SCK) | BM(CSN) | BM(OLED) ; \
PORTB = BM(MOSI) | BM(SCK) | BM(CSN); \
DDRD = BM(UART1_RTS); \
PORTD = BM(UART1_RTS) | BM(UART1_CTS);\
DDRE = BM(UART0_RXD) | BM(UART0_TXD); \
PORTE = BM(UART0_RXD) | BM(UART0_TXD) | BM(UART0_TXD)|BM(FIFOP);\
DDRF=0x00;\
} while (0)
// Enables the external SRAM
#define ENABLE_EXT_RAM() (MCUCR |= BM(SRE))
// Enables/disables the SPI interface
#define SPI_ENABLE() (PORTB &= ~BM(CSN))
#define SPI_DISABLE() (PORTB |= BM(CSN))
//-------------------------------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -