hardwareprofile.h

来自「本附件为嵌入式Web的相关资料」· C头文件 代码 · 共 1,384 行 · 第 1/4 页

H
1,384
字号
	#define ENC_CS_IO			(LATB3)
	#define ENC_SCK_TRIS		(TRISC3)
	#define ENC_SDI_TRIS		(TRISC4)
	#define ENC_SDO_TRIS		(TRISC5)
	#define ENC_SPI_IF			(SSP1IF)
	#define ENC_SSPBUF			(SSP1BUF)
	#define ENC_SPISTAT			(SSP1STAT)
	#define ENC_SPISTATbits		(*((SSPSTATbits*)&SSP1STAT))
	#define ENC_SPICON1			(SSP1CON1)
	#define ENC_SPICON1bits		(*((SSPCON1bits*)&SSP1CON))
	#define ENC_SPICON2			(SSP1CON2)

	// 25LC256 I/O pins
	#define EEPROM_CS_TRIS		(TRISB4)
	#define EEPROM_CS_IO		(LATB4)
	#define EEPROM_SCK_TRIS		(TRISC3)
	#define EEPROM_SDI_TRIS		(TRISC4)
	#define EEPROM_SDO_TRIS		(TRISC5)
	#define EEPROM_SPI_IF		(SSP1IF)
	#define EEPROM_SSPBUF		(SSP1BUF)
	#define EEPROM_SPICON1		(SSP1CON1)
	#define EEPROM_SPICON1bits	(*((SSPCON1bits*)&SSP1CON))
	#define EEPROM_SPICON2		(SSP1CON2)
	#define EEPROM_SPISTAT		(SSP1STAT)
	#define EEPROM_SPISTATbits	(*((SSPSTATbits*)&SSP1STAT))

	#define INTCONbits			(*((INTCONbits*)&INTCON))
	#define INTCON2bits			(*((INTCON2bits*)&INTCON2))
	#define ADCON0bits			(*((ADCON0bits*)&ADCON0))
	#define ADCON2bits			(*((ADCON2bits*)&ADCON2))
	#define PIR1bits			(*((PIR1bits*)&PIR1))
	#define PIE1bits			(*((PIE1bits*)&PIE1))
	#define T0CONbits			(*((T0CONbits*)&T0CON))
	#define TXSTAbits			(*((TXSTAbits*)&TXSTA1))
	#define RCSTAbits			(*((RCSTAbits*)&RCSTA1))

#elif defined(PICDEMZ) && !defined(HI_TECH_C)
// PICDEM Z + Ethernet PICtail
	// I/O pins
	#define LED0_TRIS			(TRISAbits.TRISA1)
	#define LED0_IO				(PORTAbits.RA1)
	#define LED1_TRIS			(TRISAbits.TRISA0)
	#define LED1_IO				(PORTAbits.RA0)
	#define LED2_TRIS			(TRISAbits.TRISA1)
	#define LED2_IO				(PORTAbits.RA1)
	#define LED3_TRIS			(TRISAbits.TRISA0)
	#define LED3_IO				(PORTAbits.RA0)
	#define LED4_TRIS			(TRISAbits.TRISA1)
	#define LED4_IO				(PORTAbits.RA1)
	#define LED5_TRIS			(TRISAbits.TRISA0)
	#define LED5_IO				(PORTAbits.RA0)
	#define LED6_TRIS			(TRISAbits.TRISA1)
	#define LED6_IO				(PORTAbits.RA1)
	#define LED7_TRIS			(TRISAbits.TRISA0)
	#define LED7_IO				(PORTAbits.RA0)

	#define BUTTON0_TRIS		(TRISBbits.TRISB5)  // Button0 is connected to EEPROM_CS on this board, remap to Button1
	#define	BUTTON0_IO			(PORTBbits.RB5)
	#define BUTTON1_TRIS		(TRISBbits.TRISB5)
	#define	BUTTON1_IO			(PORTBbits.RB5)
	#define BUTTON2_TRIS		(TRISBbits.TRISB5)	// No Button2 on this board, remap to Button1
	#define	BUTTON2_IO			(PORTBbits.RB5)
	#define BUTTON3_TRIS		(TRISBbits.TRISB5)	// No Button3 on this board, remap to Button1
	#define	BUTTON3_IO			(PORTBbits.RB5)

	// ENC28J60 I/O pins
	#define ENC_CS_TRIS			(TRISBbits.TRISB3)
	#define ENC_CS_IO			(LATBbits.LATB3)
	#define ENC_SCK_TRIS		(TRISCbits.TRISC3)
	#define ENC_SDI_TRIS		(TRISCbits.TRISC4)
	#define ENC_SDO_TRIS		(TRISCbits.TRISC5)
	#define ENC_SPI_IF			(PIR1bits.SSPIF)
	#define ENC_SSPBUF			(SSPBUF)
	#define ENC_SPISTAT			(SSPSTAT)
	#define ENC_SPISTATbits		(SSPSTATbits)
	#define ENC_SPICON1			(SSPCON1)
	#define ENC_SPICON1bits		(SSPCON1bits)
	#define ENC_SPICON2			(SSPCON2)

	// 25LC256 I/O pins
	#define EEPROM_CS_TRIS		(TRISBbits.TRISB4)
	#define EEPROM_CS_IO		(LATBbits.LATB4)
	#define EEPROM_SCK_TRIS		(TRISCbits.TRISC3)
	#define EEPROM_SDI_TRIS		(TRISCbits.TRISC4)
	#define EEPROM_SDO_TRIS		(TRISCbits.TRISC5)
	#define EEPROM_SPI_IF		(PIR1bits.SSPIF)
	#define EEPROM_SSPBUF		(SSPBUF)
	#define EEPROM_SPICON1		(SSPCON1)
	#define EEPROM_SPICON1bits	(SSPCON1bits)
	#define EEPROM_SPICON2		(SSPCON2)
	#define EEPROM_SPISTAT		(SSPSTAT)
	#define EEPROM_SPISTATbits	(SSPSTATbits)

#elif defined(FS_USB) && !defined(HI_TECH_C)
// NOTE: THIS IS A WORK IN PROGRESS
// PICDEM FS USB demo board support still needs more work
// PICDEM FS USB + Ethernet PICtail
// To use the PICDEM FS USB board, you must :
// 1. On Ethernet PICtail, cut the traces under J5, J6, and J7, install jumper headers, and place jumper shunts on pins 2-3, 2-3, and 2-3.
// 2. On PICDEM FS USB, cut trace under JP3 to prevent SDO and MAX232 RX output bus contention
// 3. Remove all UART code in the stack.  The SPI and UART share the same PIC18F4550 pins, so you must disable the UART and not use it.
// 4. RAM and ROM are tight on the PIC18F4550.  Need to unprotect several USB RAM banks and enable all C18 compiler optimizations (especially procedural abstraction), or remove a bunch of stack modules.

	// I/O pins
	#define LED0_TRIS			(TRISDbits.TRISD3)
	#define LED0_IO				(PORTDbits.RD3)
	#define LED1_TRIS			(TRISDbits.TRISD2)
	#define LED1_IO				(PORTDbits.RD2)
	#define LED2_TRIS			(TRISDbits.TRISD1)
	#define LED2_IO				(PORTDbits.RD1)
	#define LED3_TRIS			(TRISDbits.TRISD0)
	#define LED3_IO				(PORTDbits.RD0)
	#define LED4_TRIS			(TRISDbits.TRISD3)	// No LED remap to LED0
	#define LED4_IO				(PORTDbits.RD3)
	#define LED5_TRIS			(TRISDbits.TRISD2)	// No LED remap to LED1
	#define LED5_IO				(PORTDbits.RD2)
	#define LED6_TRIS			(TRISDbits.TRISD1)	// No LED remap to LED2
	#define LED6_IO				(PORTDbits.RD1)
	#define LED7_TRIS			(TRISDbits.TRISD0)	// No LED remap to LED3
	#define LED7_IO				(PORTDbits.RD0)


	#define BUTTON0_TRIS		(TRISBbits.TRISB5)
	#define	BUTTON0_IO			(PORTBbits.RB5)
	#define BUTTON1_TRIS		(TRISBbits.TRISB4)
	#define	BUTTON1_IO			(PORTBbits.RB4)
	#define BUTTON2_TRIS		(TRISBbits.TRISB5)	// No Button2 on this board, remap to Button0
	#define	BUTTON2_IO			(PORTBbits.RB5)
	#define BUTTON3_TRIS		(TRISBbits.TRISB4)	// No Button3 on this board, remap to Button0
	#define	BUTTON3_IO			(PORTBbits.RB4)

	// ENC28J60 I/O pins
	#define ENC_RST_TRIS		(TRISBbits.TRISB5)
	#define ENC_RST_IO			(LATBbits.LATB5)
	#define ENC_CS_TRIS			(TRISBbits.TRISB3)
	#define ENC_CS_IO			(LATBbits.LATB3)
	#define ENC_SCK_TRIS		(TRISBbits.TRISB1)
	#define ENC_SDI_TRIS		(TRISBbits.TRISB0)
	#define ENC_SDO_TRIS		(TRISCbits.TRISC7)
	#define ENC_SPI_IF			(PIR1bits.SSPIF)
	#define ENC_SSPBUF			(SSPBUF)
	#define ENC_SPISTAT			(SSPSTAT)
	#define ENC_SPISTATbits		(SSPSTATbits)
	#define ENC_SPICON1			(SSPCON1)
	#define ENC_SPICON1bits		(SSPCON1bits)
	#define ENC_SPICON2			(SSPCON2)

	// 25LC256 I/O pins
	#define EEPROM_CS_TRIS		(TRISBbits.TRISB4)
	#define EEPROM_CS_IO		(LATBbits.LATB4)
	#define EEPROM_SCK_TRIS		(TRISBbits.TRISB1)
	#define EEPROM_SDI_TRIS		(TRISBbits.TRISB0)
	#define EEPROM_SDO_TRIS		(TRISCbits.TRISC7)
	#define EEPROM_SPI_IF		(PIR1bits.SSPIF)
	#define EEPROM_SSPBUF		(SSPBUF)
	#define EEPROM_SPICON1		(SSPCON1)
	#define EEPROM_SPICON1bits	(SSPCON1bits)
	#define EEPROM_SPICON2		(SSPCON2)
	#define EEPROM_SPISTAT		(SSPSTAT)
	#define EEPROM_SPISTATbits	(SSPSTATbits)

#elif defined(PICDEMNET) && !defined(HI_TECH_C)
// PICDEM.net (classic) board with Realtek RTL8019AS Ethernet controller
// It is strongly recommended that the PIC18F452 that came installed 
// on the PICDEM.net be removed and a PIC18F4620 be installed in its 
// place.  The PIC18F4620 has twice the FLASH, substantially more 
// RAM, and as a result can support all of the latest TCP/IP stack 
// modules compiled all at once.  The PIC18F4620 also has superior 
// peripherals that are natively supported by the stack.
//
// If using the PIC18F452, you most likely have to use the modified 
// 18f452i.lkr linker script and turn on all C18 compiler optimizations, 
// including procedural abstraction to get the project to compile.  The 
// stack ROM/RAM memory usage is right at the limits of the 18F452.
	// I/O pins
	#define LED0_TRIS			(TRISAbits.TRISA4)
	#define LED0_IO				(PORTAbits.RA4)
	#define LED1_TRIS			(TRISAbits.TRISA3)
	#define LED1_IO				(PORTAbits.RA3)
	#define LED2_TRIS			(TRISAbits.TRISA2)
	#define LED2_IO				(PORTAbits.RA2)
	#define LED3_TRIS			(TRISAbits.TRISA4)	// No LED3; remap
	#define LED3_IO				(PORTAbits.RA4)
	#define LED4_TRIS			(TRISAbits.TRISA3)	// No LED4; remap
	#define LED4_IO				(PORTAbits.RA3)
	#define LED5_TRIS			(TRISAbits.TRISA2)	// No LED5; remap
	#define LED5_IO				(PORTAbits.RA2)
	#define LED6_TRIS			(TRISAbits.TRISA4)	// No LED6; remap
	#define LED6_IO				(PORTAbits.RA4)
	#define LED7_TRIS			(TRISAbits.TRISA3)	// No LED7; remap
	#define LED7_IO				(PORTAbits.RA3)

	#define BUTTON0_TRIS		(TRISBbits.TRISB5)
	#define	BUTTON0_IO			(PORTBbits.RB5)
	#define BUTTON1_TRIS		(TRISBbits.TRISB5)	// No Button1 on this board, remap to Button0
	#define	BUTTON1_IO			(PORTBbits.RB5)
	#define BUTTON2_TRIS		(TRISBbits.TRISB5)	// No Button2 on this board, remap to Button0
	#define	BUTTON2_IO			(PORTBbits.RB5)
	#define BUTTON3_TRIS		(TRISBbits.TRISB5)	// No Button3 on this board, remap to Button0
	#define	BUTTON3_IO			(PORTBbits.RB5)

	// RTL8019AS I/O pins
	typedef struct
	{
		unsigned char data : 5;	// Bits 0 through 4
		unsigned char : 3;		// Bits 5 through 7
	} NIC_ADDR;
	typedef struct
	{
		unsigned char data : 8;	// Bits 0 through 7
	} NIC_DATA;
	#define NIC_ADDR_TRIS		(((NIC_ADDR*)&TRISB)->data)
	#define NIC_ADDR_IO			(((NIC_ADDR*)&LATB)->data)
	#define NIC_DATA_TRIS		(((NIC_DATA*)&TRISD)->data)
	#define NIC_DATA_IO			(((NIC_DATA*)&PORTD)->data)
	#define NIC_RESET_TRIS		(TRISEbits.TRISE2)
	#define NIC_RESET_IO        (LATEbits.LATE2)
	#define NIC_ADDR_LATCH_TRIS	(PRODL)
	#define NIC_ADDR_LATCH_IO	(PRODL)
	#define NIC_IOW_TRIS		(TRISEbits.TRISE1)
	#define NIC_IOW_IO          (LATEbits.LATE1)
	#define NIC_IOR_TRIS		(TRISEbits.TRISE0)
	#define NIC_IOR_IO          (LATEbits.LATE0)

	// 24LC256 I/O pins
	#define EEPROM_SCL_TRIS		(TRISCbits.TRISC3)
	#define EEPROM_SDA_TRIS		(TRISCbits.TRISC4)
	#define EEPROM_SSPBUF		(SSPBUF)
	#define EEPROM_SSPCON1		(SSPCON1)
	#define EEPROM_SSPCON1bits	(SSPCON1bits)
	#define EEPROM_SSPCON2		(SSPCON2)
	#define EEPROM_SSPCON2bits	(SSPCON2bits)
	#define EEPROM_SSPSTATbits	(SSPSTATbits)

	// 24LC256 configuration
	#define EEPROM_CONTROL	(0xA0)		// Address 0
	#define I2CBAUD			(400000)	// Hz

	// LCD
	// LCD Module I/O pins
	typedef struct
	{
		unsigned char data : 4;	// Bits 0 through 3
		unsigned char : 4;		// Bits 4 through 7
	} LCD_DATA;
	#define LCD_DATA_TRIS		(((volatile LCD_DATA*)&TRISD)->data)
	#define LCD_DATA_IO			(((volatile LCD_DATA*)&LATD)->data)
	#define LCD_RD_WR_TRIS		(TRISDbits.TRISD5)
	#define LCD_RD_WR_IO		(LATDbits.LATD5)
	#define LCD_RS_TRIS			(TRISDbits.TRISD4)
	#define LCD_RS_IO			(LATDbits.LATD4)
	#define LCD_E_TRIS			(TRISAbits.TRISA5)
	#define LCD_E_IO			(LATAbits.LATA5)

	// Do not use the DMA and other goodies that Microchip Ethernet modules have
	#define NON_MCHP_MAC

	#if defined(__18F452)
		#define OSCTUNE				PRODL
		#define ADCON2				PRODL
	#endif

#elif defined(PICDEMNET) && defined(HI_TECH_C)
// PICDEM.net (classic) board with Realtek RTL8019AS Ethernet controller
// It is strongly recommended that the PIC18F452 that came installed 
// on the PICDEM.net be removed and a PIC18F4620 be installed in its 
// place.  The PIC18F4620 has twice the FLASH, substantially more 
// RAM, and as a result can support all of the latest TCP/IP stack 
// modules compiled all at once.  The PIC18F4620 also has superior 
// peripherals that are natively supported by the stack.
//
// If using the PIC18F452, you most likely will not be able to compile
// the stack with the HI-TECH compiler due to excessive code space needed.
// You must remove unneeded modules or use a bigger microcontroller.
	typedef struct
	{
	    unsigned char BF:1;
	    unsigned char UA:1;
	    unsigned char R_W:1;
	    unsigned char S:1;
	    unsigned char P:1;
	    unsigned char D_A:1;
	    unsigned char CKE:1;
	    unsigned char SMP:1;
	} SSPSTATbits;
	typedef struct
	{
	    unsigned char SSPM0:1;
	    unsigned char SSPM1:1;
	    unsigned char SSPM2:1;
	    unsigned char SSPM3:1;
	    unsigned char CKP:1;
	    unsigned char SSPEN:1;
	    unsigned char SSPOV:1;
	    unsigned char WCOL:1;
	} SSPCON1bits;
	typedef struct
	{
	    unsigned char SEN:1;
	    unsigned char RSEN:1;
	    unsigned char PEN:1;
	    unsigned char RCEN:1;
	    unsigned char ACKEN:1;
	    unsigned char ACKDT:1;
	    unsigned char ACKSTAT:1;
	    unsigned char GCEN:1;
	} SSPCON2bits;
	typedef struct 
	{
	    unsigned char RBIF:1;
	    unsigned char INT0IF:1;
	    unsigned char TMR0IF:1;
		unsigned char RBIE:1;
	    unsigned char INT0IE:1;
	    unsigned char TMR0IE:1;
	    unsigned char GIEL:1;
	    unsigned char GIEH:1;
	} INTCONbits;
	typedef struct 
	{
	    unsigned char RBIP:1;
	    unsigned char INT3IP:1;
	    unsigned char TMR0IP:1;
	    unsigned char INTEDG3:1;
	    unsigned char INTEDG2:1;
	    unsigned char INTEDG1:1;
	    unsigned char INTEDG0:1;
	    unsigned char RBPU:1;
	} INTCON2bits;
	typedef struct 
	{
	    unsigned char ADON:1;
	    unsigned char GO:1;
	    unsigned char CHS0:1;
	    unsigned char CHS1:1;
	    unsigned char CHS2:1;
	    unsigned char CHS3:1;
	} ADCON0bits;
	typedef struct 
	{
		unsigned char ADCS0:1;
		unsigned char ADCS1:1;
		unsigned char ADCS2:1;
		unsigned char ACQT0:1;
		unsigned char ACQT1:1;
		unsigned char ACQT2:1;

⌨️ 快捷键说明

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