⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hal_ccxx00db.h

📁 AVR写的433M无线通信原代码.
💻 H
字号:
/*******************************************************************************************************
 *******************************************************************************************************
 * 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 CCxx00 and the target microcontroller.            *
 *                                                                                                     *
 * This file contains all definitions that are specific for the CCxx00DB development platform.         *
 *******************************************************************************************************
 * Compiler: AVR-GCC                                                                                   *
 * Target platform: CCxx00DB                                                                           *
 * Author:                  珠海元井电子  www.vital-well.com  
 *******************************************************************************************************
 * Revision history:                                                                                   *
 *
 *******************************************************************************************************/
#ifndef _HAL_CCxx00DB_H_
#define _HAL_CCxx00DB_H_


/*******************************************************************************************************
 *******************************************************************************************************
 **************************                   AVR I/O PORTS                   **************************
 *******************************************************************************************************
 *******************************************************************************************************/

//-------------------------------------------------------------------------------------------------------
// Port B

#define PB0_NC          0 // PB.0 - NC; test,output; 24-Sep
#define PB1_NC					1 // PB.1 - NC
#define CSN             2 // PB.2 - Output: SPI Chip Select (CS_N)
#define MOSI            3 // PB.3 - Output: SPI Master out - slave in (MOSI)
#define MISO            4 // PB.4 - Input:  SPI Master in - slave out (MISO)
#define SCK             5 // PB.5 - Output: SPI Serial Clock (SCLK)

#define PB_INIT			DDRB  = BM(MOSI) | BM(SCK) | BM(CSN); \
						PORTB =0x3F;

//-------------------------------------------------------------------------------------------------------
// Port C

#define PC0_NC       0 // PC.0 - :  
#define PC1_NC       1 // PC.1 - ;
#define PC2_NC        2 // PC.2 - NC: 
#define PC3_NC        3 // PC.5 - NC
#define PC4_NC					4	// PC.4 - NC:  
#define PC5_NC					5 // PC.5 - NC:  


#define PC_INIT			DDRC = 0; PORTC=0x3F;

//-------------------------------------------------------------------------------------------------------
// Port D
#define UART1_RXD       0 // PD.0 - Input:  UART1 RXD
#define UART1_TXD       1 // PD.1 - Output: UART1 TXD
#define PD2_NC		      2 // PD.2 - Input:  INT0, 
#define PD3_NC          3 // PD.3 - Input : INT1, 
#define PD4_NC          4 // PD.4 - NC
#define PD5_NC          5 // PD.5 - NC
#define PD6_NC        	6 // PD.6 - NC; 
#define LED_RDY					7 // PD.7 - Output: LED_RDY


#define PD_INIT			DDRD  =( BM(UART1_TXD))|(BM(LED_RDY)) ; \
						PORTD = 0x73;

						
//-------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------
// Port setup macros

// Port initialization


#define PORT_INIT() \
    do { \
		PB_INIT; \
		PC_INIT; \
		PD_INIT; \
	} while (0)



// Enables/disables the SPI interface
#define SPI_ENABLE()                (PORTB &= ~BM(CSN))
#define SPI_DISABLE()               (PORTB |= BM(CSN))
//-------------------------------------------------------------------------------------------------------

// External Interrupt 1 - falling edge trigger (PATTERN),MCUCR=0bxxxx10xx
//#define PATTERN_INT_INIT()		do { MCUCR |= 0x08;  } while (0)

// External Interrupt 1 - Low level trigger
	#define PATTERN_INT_INIT()		do { MCUCR &= 0xF3;  } while (0)


// clear int(); 23/05/06
#define ENABLE_PATTERN_INT()			do {GIFR = 0x80; GICR |= 0x80;  } while (0)
//#define ENABLE_PATTERN_INT()			do { GICR |= 0x80;  } while (0)		//08-07-2006

#define DISABLE_PATTERN_INT()			do {GICR &=0x7F;} while (0)
#define CLEAR_PATTERN_INT()			do {GIFR = 0x80;} while (0)


/*******************************************************************************************************
 *******************************************************************************************************
 **************************                        LEDS                       **************************
 *******************************************************************************************************
 *******************************************************************************************************/


//-------------------------------------------------------------------------------------------------------

//define ready_led
#define SET_LED_RDY()				(PORTD |= BM(LED_RDY))
#define CLR_LED_RDY()				(PORTD &= 0x7F)
#define	TOGGLE_LED_RDY()		(PORTD ^= BM(LED_RDY))

//end test

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -