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

📄 main.pre

📁 USB interface examples using CDC by HT-PICC 18
💻 PRE
📖 第 1 页 / 共 4 页
字号:


static volatile near bit TMR1IF @ ((unsigned)&PIR1*8)+0;
static volatile near bit TMR2IF @ ((unsigned)&PIR1*8)+1;
static volatile near bit CCP1IF @ ((unsigned)&PIR1*8)+2;
static volatile near bit SSPIF @ ((unsigned)&PIR1*8)+3;
static volatile near bit TXIF @ ((unsigned)&PIR1*8)+4;
static volatile near bit RCIF @ ((unsigned)&PIR1*8)+5;
static volatile near bit ADIF @ ((unsigned)&PIR1*8)+6;
static volatile near bit SPPIF @ ((unsigned)&PIR1*8)+7;


static near bit TMR1IE @ ((unsigned)&PIE1*8)+0;
static near bit TMR2IE @ ((unsigned)&PIE1*8)+1;
static near bit CCP1IE @ ((unsigned)&PIE1*8)+2;
static near bit SSPIE @ ((unsigned)&PIE1*8)+3;
static near bit TXIE @ ((unsigned)&PIE1*8)+4;
static near bit RCIE @ ((unsigned)&PIE1*8)+5;
static near bit ADIE @ ((unsigned)&PIE1*8)+6;
static near bit SPPIE @ ((unsigned)&PIE1*8)+7;


static near bit TUN0 @ ((unsigned)&OSCTUNE*8)+0;
static near bit TUN1 @ ((unsigned)&OSCTUNE*8)+1;
static near bit TUN2 @ ((unsigned)&OSCTUNE*8)+2;
static near bit TUN3 @ ((unsigned)&OSCTUNE*8)+3;
static near bit TUN4 @ ((unsigned)&OSCTUNE*8)+4;
static near bit INTSRC @ ((unsigned)&OSCTUNE*8)+7;



static volatile near bit TRISE0 @ ((unsigned)&TRISE*8)+0;
static volatile near bit TRISE1 @ ((unsigned)&TRISE*8)+1;
static volatile near bit TRISE2 @ ((unsigned)&TRISE*8)+2;


static volatile near bit TRISD0 @ ((unsigned)&TRISD*8)+0;
static volatile near bit TRISD1 @ ((unsigned)&TRISD*8)+1;
static volatile near bit TRISD2 @ ((unsigned)&TRISD*8)+2;
static volatile near bit TRISD3 @ ((unsigned)&TRISD*8)+3;
static volatile near bit TRISD4 @ ((unsigned)&TRISD*8)+4;
static volatile near bit TRISD5 @ ((unsigned)&TRISD*8)+5;
static volatile near bit TRISD6 @ ((unsigned)&TRISD*8)+6;
static volatile near bit TRISD7 @ ((unsigned)&TRISD*8)+7;



static volatile near bit TRISC0 @ ((unsigned)&TRISC*8)+0;
static volatile near bit TRISC1 @ ((unsigned)&TRISC*8)+1;
static volatile near bit TRISC2 @ ((unsigned)&TRISC*8)+2;
static volatile near bit TRISC6 @ ((unsigned)&TRISC*8)+6;
static volatile near bit TRISC7 @ ((unsigned)&TRISC*8)+7;


static volatile near bit TRISB0 @ ((unsigned)&TRISB*8)+0;
static volatile near bit TRISB1 @ ((unsigned)&TRISB*8)+1;
static volatile near bit TRISB2 @ ((unsigned)&TRISB*8)+2;
static volatile near bit TRISB3 @ ((unsigned)&TRISB*8)+3;
static volatile near bit TRISB4 @ ((unsigned)&TRISB*8)+4;
static volatile near bit TRISB5 @ ((unsigned)&TRISB*8)+5;
static volatile near bit TRISB6 @ ((unsigned)&TRISB*8)+6;
static volatile near bit TRISB7 @ ((unsigned)&TRISB*8)+7;


static near bit TRISA0 @ ((unsigned)&TRISA*8)+0;
static near bit TRISA1 @ ((unsigned)&TRISA*8)+1;
static near bit TRISA2 @ ((unsigned)&TRISA*8)+2;
static near bit TRISA3 @ ((unsigned)&TRISA*8)+3;
static near bit TRISA4 @ ((unsigned)&TRISA*8)+4;
static near bit TRISA5 @ ((unsigned)&TRISA*8)+5;
static near bit TRISA6 @ ((unsigned)&TRISA*8)+6;



static volatile near bit LATE0 @ ((unsigned)&LATE*8)+0;
static volatile near bit LATE1 @ ((unsigned)&LATE*8)+1;
static volatile near bit LATE2 @ ((unsigned)&LATE*8)+2;


static volatile near bit LATD0 @ ((unsigned)&LATD*8)+0;
static volatile near bit LATD1 @ ((unsigned)&LATD*8)+1;
static volatile near bit LATD2 @ ((unsigned)&LATD*8)+2;
static volatile near bit LATD3 @ ((unsigned)&LATD*8)+3;
static volatile near bit LATD4 @ ((unsigned)&LATD*8)+4;
static volatile near bit LATD5 @ ((unsigned)&LATD*8)+5;
static volatile near bit LATD6 @ ((unsigned)&LATD*8)+6;
static volatile near bit LATD7 @ ((unsigned)&LATD*8)+7;



static volatile near bit LATC0 @ ((unsigned)&LATC*8)+0;
static volatile near bit LATC1 @ ((unsigned)&LATC*8)+1;
static volatile near bit LATC2 @ ((unsigned)&LATC*8)+2;
static volatile near bit LATC6 @ ((unsigned)&LATC*8)+6;
static volatile near bit LATC7 @ ((unsigned)&LATC*8)+7;


static volatile near bit LATB0 @ ((unsigned)&LATB*8)+0;
static volatile near bit LATB1 @ ((unsigned)&LATB*8)+1;
static volatile near bit LATB2 @ ((unsigned)&LATB*8)+2;
static volatile near bit LATB3 @ ((unsigned)&LATB*8)+3;
static volatile near bit LATB4 @ ((unsigned)&LATB*8)+4;
static volatile near bit LATB5 @ ((unsigned)&LATB*8)+5;
static volatile near bit LATB6 @ ((unsigned)&LATB*8)+6;
static volatile near bit LATB7 @ ((unsigned)&LATB*8)+7;


static volatile near bit LATA0 @ ((unsigned)&LATA*8)+0;
static volatile near bit LATA1 @ ((unsigned)&LATA*8)+1;
static volatile near bit LATA2 @ ((unsigned)&LATA*8)+2;
static volatile near bit LATA3 @ ((unsigned)&LATA*8)+3;
static volatile near bit LATA4 @ ((unsigned)&LATA*8)+4;
static volatile near bit LATA5 @ ((unsigned)&LATA*8)+5;
static volatile near bit LATA6 @ ((unsigned)&LATA*8)+6;



static volatile near bit RE0 @ ((unsigned)&PORTE*8)+0;
static volatile near bit RE1 @ ((unsigned)&PORTE*8)+1;
static volatile near bit RE2 @ ((unsigned)&PORTE*8)+2;

static volatile near bit RE3 @ ((unsigned)&PORTE*8)+3;

static near bit RDPU @ ((unsigned)&PORTE*8)+7;


static volatile near bit RD0 @ ((unsigned)&PORTD*8)+0;
static volatile near bit RD1 @ ((unsigned)&PORTD*8)+1;
static volatile near bit RD2 @ ((unsigned)&PORTD*8)+2;
static volatile near bit RD3 @ ((unsigned)&PORTD*8)+3;
static volatile near bit RD4 @ ((unsigned)&PORTD*8)+4;
static volatile near bit RD5 @ ((unsigned)&PORTD*8)+5;
static volatile near bit RD6 @ ((unsigned)&PORTD*8)+6;
static volatile near bit RD7 @ ((unsigned)&PORTD*8)+7;



static volatile near bit RC0 @ ((unsigned)&PORTC*8)+0;
static volatile near bit RC1 @ ((unsigned)&PORTC*8)+1;
static volatile near bit RC2 @ ((unsigned)&PORTC*8)+2;
static volatile near bit RC4 @ ((unsigned)&PORTC*8)+4;
static volatile near bit RC5 @ ((unsigned)&PORTC*8)+5;
static volatile near bit RC6 @ ((unsigned)&PORTC*8)+6;
static volatile near bit RC7 @ ((unsigned)&PORTC*8)+7;


static volatile near bit RB0 @ ((unsigned)&PORTB*8)+0;
static volatile near bit RB1 @ ((unsigned)&PORTB*8)+1;
static volatile near bit RB2 @ ((unsigned)&PORTB*8)+2;
static volatile near bit RB3 @ ((unsigned)&PORTB*8)+3;
static volatile near bit RB4 @ ((unsigned)&PORTB*8)+4;
static volatile near bit RB5 @ ((unsigned)&PORTB*8)+5;
static volatile near bit RB6 @ ((unsigned)&PORTB*8)+6;
static volatile near bit RB7 @ ((unsigned)&PORTB*8)+7;


static volatile near bit RA0 @ ((unsigned)&PORTA*8)+0;
static volatile near bit RA1 @ ((unsigned)&PORTA*8)+1;
static volatile near bit RA2 @ ((unsigned)&PORTA*8)+2;
static volatile near bit RA3 @ ((unsigned)&PORTA*8)+3;
static volatile near bit RA4 @ ((unsigned)&PORTA*8)+4;
static volatile near bit RA5 @ ((unsigned)&PORTA*8)+5;
static volatile near bit RA6 @ ((unsigned)&PORTA*8)+6;


static volatile near bit EPSTALL15 @ ((unsigned)&UEP15*8)+0;
static near bit EPINEN15 @ ((unsigned)&UEP15*8)+1;
static near bit EPOUTEN15 @ ((unsigned)&UEP15*8)+2;
static near bit EPCONDIS15 @ ((unsigned)&UEP15*8)+3;
static near bit EPHSHK15 @ ((unsigned)&UEP15*8)+4;


static volatile near bit EPSTALL14 @ ((unsigned)&UEP14*8)+0;
static near bit EPINEN14 @ ((unsigned)&UEP14*8)+1;
static near bit EPOUTEN14 @ ((unsigned)&UEP14*8)+2;
static near bit EPCONDIS14 @ ((unsigned)&UEP14*8)+3;
static near bit EPHSHK14 @ ((unsigned)&UEP14*8)+4;


static volatile near bit EPSTALL13 @ ((unsigned)&UEP13*8)+0;
static near bit EPINEN13 @ ((unsigned)&UEP13*8)+1;
static near bit EPOUTEN13 @ ((unsigned)&UEP13*8)+2;
static near bit EPCONDIS13 @ ((unsigned)&UEP13*8)+3;
static near bit EPHSHK13 @ ((unsigned)&UEP13*8)+4;


static volatile near bit EPSTALL12 @ ((unsigned)&UEP12*8)+0;
static near bit EPINEN12 @ ((unsigned)&UEP12*8)+1;
static near bit EPOUTEN12 @ ((unsigned)&UEP12*8)+2;
static near bit EPCONDIS12 @ ((unsigned)&UEP12*8)+3;
static near bit EPHSHK12 @ ((unsigned)&UEP12*8)+4;


static volatile near bit EPSTALL11 @ ((unsigned)&UEP11*8)+0;
static near bit EPINEN11 @ ((unsigned)&UEP11*8)+1;
static near bit EPOUTEN11 @ ((unsigned)&UEP11*8)+2;
static near bit EPCONDIS11 @ ((unsigned)&UEP11*8)+3;
static near bit EPHSHK11 @ ((unsigned)&UEP11*8)+4;


static volatile near bit EPSTALL10 @ ((unsigned)&UEP10*8)+0;
static near bit EPINEN10 @ ((unsigned)&UEP10*8)+1;
static near bit EPOUTEN10 @ ((unsigned)&UEP10*8)+2;
static near bit EPCONDIS10 @ ((unsigned)&UEP10*8)+3;
static near bit EPHSHK10 @ ((unsigned)&UEP10*8)+4;


static volatile near bit EPSTALL9 @ ((unsigned)&UEP9*8)+0;
static near bit EPINEN9 @ ((unsigned)&UEP9*8)+1;
static near bit EPOUTEN9 @ ((unsigned)&UEP9*8)+2;
static near bit EPCONDIS9 @ ((unsigned)&UEP9*8)+3;
static near bit EPHSHK9 @ ((unsigned)&UEP9*8)+4;


static volatile near bit EPSTALL8 @ ((unsigned)&UEP8*8)+0;
static near bit EPINEN8 @ ((unsigned)&UEP8*8)+1;
static near bit EPOUTEN8 @ ((unsigned)&UEP8*8)+2;
static near bit EPCONDIS8 @ ((unsigned)&UEP8*8)+3;
static near bit EPHSHK8 @ ((unsigned)&UEP8*8)+4;


static volatile near bit EPSTALL7 @ ((unsigned)&UEP7*8)+0;
static near bit EPINEN7 @ ((unsigned)&UEP7*8)+1;
static near bit EPOUTEN7 @ ((unsigned)&UEP7*8)+2;
static near bit EPCONDIS7 @ ((unsigned)&UEP7*8)+3;
static near bit EPHSHK7 @ ((unsigned)&UEP7*8)+4;


static volatile near bit EPSTALL6 @ ((unsigned)&UEP6*8)+0;
static near bit EPINEN6 @ ((unsigned)&UEP6*8)+1;
static near bit EPOUTEN6 @ ((unsigned)&UEP6*8)+2;
static near bit EPCONDIS6 @ ((unsigned)&UEP6*8)+3;
static near bit EPHSHK6 @ ((unsigned)&UEP6*8)+4;


static volatile near bit EPSTALL5 @ ((unsigned)&UEP5*8)+0;
static near bit EPINEN5 @ ((unsigned)&UEP5*8)+1;
static near bit EPOUTEN5 @ ((unsigned)&UEP5*8)+2;
static near bit EPCONDIS5 @ ((unsigned)&UEP5*8)+3;
static near bit EPHSHK5 @ ((unsigned)&UEP5*8)+4;


static volatile near bit EPSTALL4 @ ((unsigned)&UEP4*8)+0;
static near bit EPINEN4 @ ((unsigned)&UEP4*8)+1;
static near bit EPOUTEN4 @ ((unsigned)&UEP4*8)+2;
static near bit EPCONDIS4 @ ((unsigned)&UEP4*8)+3;
static near bit EPHSHK4 @ ((unsigned)&UEP4*8)+4;


static volatile near bit EPSTALL3 @ ((unsigned)&UEP3*8)+0;
static near bit EPINEN3 @ ((unsigned)&UEP3*8)+1;
static near bit EPOUTEN3 @ ((unsigned)&UEP3*8)+2;
static near bit EPCONDIS3 @ ((unsigned)&UEP3*8)+3;
static near bit EPHSHK3 @ ((unsigned)&UEP3*8)+4;


static volatile near bit EPSTALL2 @ ((unsigned)&UEP2*8)+0;
static near bit EPINEN2 @ ((unsigned)&UEP2*8)+1;
static near bit EPOUTEN2 @ ((unsigned)&UEP2*8)+2;
static near bit EPCONDIS2 @ ((unsigned)&UEP2*8)+3;
static near bit EPHSHK2 @ ((unsigned)&UEP2*8)+4;


static volatile near bit EPSTALL1 @ ((unsigned)&UEP1*8)+0;
static near bit EPINEN1 @ ((unsigned)&UEP1*8)+1;
static near bit EPOUTEN1 @ ((unsigned)&UEP1*8)+2;
static near bit EPCONDIS1 @ ((unsigned)&UEP1*8)+3;
static near bit EPHSHK1 @ ((unsigned)&UEP1*8)+4;


static volatile near bit EPSTALL0 @ ((unsigned)&UEP0*8)+0;
static near bit EPINEN0 @ ((unsigned)&UEP0*8)+1;
static near bit EPOUTEN0 @ ((unsigned)&UEP0*8)+2;
static near bit EPCONDIS0 @ ((unsigned)&UEP0*8)+3;
static near bit EPHSHK0 @ ((unsigned)&UEP0*8)+4;


static near bit UPP0 @ ((unsigned)&UCFG*8)+0;
static near bit UPP1 @ ((unsigned)&UCFG*8)+1;
static near bit FSEN @ ((unsigned)&UCFG*8)+2;
static near bit UTRDIS @ ((unsigned)&UCFG*8)+3;
static near bit UPUEN @ ((unsigned)&UCFG*8)+4;
static near bit UOEMON @ ((unsigned)&UCFG*8)+6;
static near bit UTEYE @ ((unsigned)&UCFG*8)+7;


static near bit SUSPND @ ((unsigned)&UCON*8)+1;
static near bit RESUME @ ((unsigned)&UCON*8)+2;
static volatile near bit USBEN @ ((unsigned)&UCON*8)+3;
static volatile near bit PKTDIS @ ((unsigned)&UCON*8)+4;
static volatile near bit SE0 @ ((unsigned)&UCON*8)+5;
static volatile near bit PPBRST @ ((unsigned)&UCON*8)+6;


static volatile near bit PPBI @ ((unsigned)&USTAT*8)+1;
static volatile near bit DIR @ ((unsigned)&USTAT*8)+2;
static volatile near bit ENDP0 @ ((unsigned)&USTAT*8)+3;
static volatile near bit ENDP1 @ ((unsigned)&USTAT*8)+4;
static volatile near bit ENDP2 @ ((unsigned)&USTAT*8)+5;
static volatile near bit ENDP3 @ ((unsigned)&USTAT*8)+6;


static near bit PIDEE @ ((unsigned)&UEIE*8)+0;
static near bit CRC5EE @ ((unsigned)&UEIE*8)+1;
static near bit CRC16EE @ ((unsigned)&UEIE*8)+2;
static near bit DFN8EE @ ((unsigned)&UEIE*8)+3;
static near bit BTOEE @ ((unsigned)&UEIE*8)+4;
static near bit BTSEE @ ((unsigned)&UEIE*8)+7;


static volatile near bit PIDEF @ ((unsigned)&UEIR*8)+0;
static volatile near bit CRC5EF @ ((unsigned)&UEIR*8)+1;
static volatile near bit CRC16EF @ ((unsigned)&UEIR*8)+2;
static volatile near bit DFN8EF @ ((unsigned)&UEIR*8)+3;
static volatile near bit BTOEF @ ((unsigned)&UEIR*8)+4;
static volatile near bit BTSEF @ ((unsigned)&UEIR*8)+7;


static near bit URSTIE @ ((unsigned)&UIE*8)+0;
static near bit UERRIE @ ((unsigned)&UIE*8)+1;
static near bit ACTVIE @ ((unsigned)&UIE*8)+2;
static near bit TRNIE @ ((unsigned)&UIE*8)+3;
static near bit IDLEIE @ ((unsigned)&UIE*8)+4;
static near bit STALLIE @ ((unsigned)&UIE*8)+5;
static near bit SOFIE @ ((unsigned)&UIE*8)+6;


static volatile near bit URSTIF @ ((unsigned)&UIR*8)+0;
static volatile near bit UERRIF @ ((unsigned)&UIR*8)+1;
static volatile near bit ACTVIF @ ((unsigned)&UIR*8)+2;
static volatile near bit TRNIF @ ((unsigned)&UIR*8)+3;
static volatile near bit IDLEIF @ ((unsigned)&UIR*8)+4;
static volatile near bit STALLIF @ ((unsigned)&UIR*8)+5;
static volatile near bit SOFIF @ ((unsigned)&UIR*8)+6;



static near bit SPPEN @ ((unsigned)&SPPCON*8)+0;
static near bit SPPOWN @ ((unsigned)&SPPCON*8)+1;


static near bit ADDR0 @ ((unsigned)&SPPEPS*8)+0;
static near bit ADDR1 @ ((unsigned)&SPPEPS*8)+1;
static near bit ADDR2 @ ((unsigned)&SPPEPS*8)+2;
static near bit ADDR3 @ ((unsigned)&SPPEPS*8)+3;
static volatile near bit BUSY @ ((unsigned)&SPPEPS*8)+4;
static volatile near bit WRSPP @ ((unsigned)&SPPEPS*8)+6;
static volatile near bit RDSPP @ ((unsigned)&SPPEPS*8)+7;


static near bit WS0 @ ((unsigned)&SPPCFG*8)+0;
static near bit WS1 @ ((unsigned)&SPPCFG*8)+1;
static near bit WS2 @ ((unsigned)&SPPCFG*8)+2;
static near bit WS3 @ ((unsigned)&SPPCFG*8)+3;
static near bit CLK1EN @ ((unsigned)&SPPCFG*8)+4;
static near bit CSEN @ ((unsigned)&SPPCFG*8)+5;
static near bit CLKCFG0 @ ((unsigned)&SPPCFG*8)+6;
static near bit CLKCFG1 @ ((unsigned)&SPPCFG*8)+7;

# 246 "C:\HT-PIC18\INCLUDE\pic18.h"
extern unsigned char eeprom_read(unsigned int address);
extern void eeprom_write(unsigned int address,unsigned char data);


extern unsigned char flash_read(unsigned long addr);
extern void flash_write(far unsigned char *,unsigned char,far unsigned char *);
extern void flash_erase(unsigned long addr);


extern unsigned int config_read(unsigned char reg_no);
extern void config_write(unsigned char reg_no, unsigned int dataword);


extern unsigned int device_id_read(void);


extern unsigned char idloc_read(unsigned char reg_no);
extern void idloc_write(unsigned char reg_no,unsigned char data);


extern void initiate_write(void);
extern void wait_on_wr(void);

# 287
extern unsigned char checksum8(unsigned long startAddr, unsigned long length);
extern unsigned int checksum16(unsigned long startAddr, unsigned long length);
extern unsigned long checksum32(unsigned long startAddr, unsigned long length);

# 5 "C:\Documents and Settings\Thai Hoa\Desktop\USB\GenericUSB.h"
typedef unsigned char byte;
typedef unsigned int word;
typedef unsigned long dword;
typedef union _BYTE
{
byte _byte;
} BYTE;

typedef union _WORD
{
word _word;
struct
{
byte byte0;
byte byte1;
} a;
struct
{
byte v[2];
} d;
} WORD;




typedef union _DWORD
{
dword _dword;
struct
{
byte byte0;
byte byte1;
byte byte2;
byte byte3;
} a;
struct
{
word word0;
word word1;
} b;

struct
{
byte v[4];
} e;
} DWORD;

# 57
typedef void(*pFunc)(void);

typedef union _POINTER
{
struct
{
byte bLow;
byte bHigh;

} a;
word _word;

byte* bRam;
word* wRam;
const byte* bRom;
const word* wRom;

} POINTER;

typedef enum _BOOL { FALSE = 0, TRUE } BOOL;

typedef struct
{
unsigned EPSTALL :1;
unsigned EPINEN :1;
unsigned EPOUTEN :1;
unsigned EPCONDIS :1;
unsigned EPHSHK :1;
unsigned Reserved :3;
} UEP0Type;

static volatile near UEP0Type UEP0bits @ 0xF70;


void USBCheckStdRequest(void);
void USBCtrlEPService(void);
void USBCtrlTrfTxService(void);

⌨️ 快捷键说明

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