#ifndef __SN8P2213__H
#define __SN8P2213__H

void _ClearWatchDogTimer(void);
void _ClrRAM(void);

#define NOP(X)  	__asm{	_NOP X }
#define LOG(X)  	__asm{	LOG CNameToAsmLabel(X) }
sfr	R = 0x82;
sfr	Z = 0x83;
sfr	Y = 0x84;
sfr	PFLAG = 0x86;
sbit	FZ = 0x86:0;
sbit	FDC = 0x86:1;
sbit	FC = 0x86:2;
sbit	FNPD = 0x86:6;
sbit	FNT0 = 0x86:7;
sfr	RBANK = 0x87;
sbit	FRBNKS0 = 0x87:0;
sfr	UDA = 0xa0;
sbit	FUDE = 0xa0:7;
sbit	FUDA6 = 0xa0:6;
sbit	FUDA5 = 0xa0:5;
sbit	FUDA4 = 0xa0:4;
sbit	FUDA3 = 0xa0:3;
sbit	FUDA2 = 0xa0:2;
sbit	FUDA1 = 0xa0:1;
sbit	FUDA0 = 0xa0:0;
sfr	USTATUS = 0xa1;
sbit	FBUSRST = 0xa1:6;
sbit	FUSUSPEND = 0xa1:5;
sbit	FUEP0SETUP = 0xa1:4;
sbit	FUEP0IN = 0xa1:3;
sbit	FUEP0OUT = 0xa1:2;
sbit	FUEP1ACK = 0xa1:1;
sbit	FUEP2ACK = 0xa1:0;
sfr	UCTRL = 0xa2;
sbit	FFFS2 = 0xa2:7;
sbit	FFFS1 = 0xa2:6;
sbit	FFFS0 = 0xa2:5;
sbit	FUEP0OC4 = 0xa2:4;
sbit	FUEP0OC3 = 0xa2:3;
sbit	FUEP0OC2 = 0xa2:2;
sbit	FUEP0OC1 = 0xa2:1;
sbit	FUEP0OC0 = 0xa2:0;
sfr	UE0R = 0xa3;
sbit	FUE0M1 = 0xa3:6;
sbit	FUE0M0 = 0xa3:5;
sbit	FUE0C3 = 0xa3:3;
sbit	FUE0C2 = 0xa3:2;
sbit	FUE0C1 = 0xa3:1;
sbit	FUE0C0 = 0xa3:0;
sfr	UE1R = 0xa4;
sbit	FUE1E = 0xa4:7;
sbit	FUE1M1 = 0xa4:6;
sbit	FUE1M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P1OC4 = 0xab:4;
sbit	FEP1OC3 = 0xab:3;
sbit	FEP1OC2 = 0xab:2;
sbit	FEP1OC1 = 0xab:1;
sbit	FEP1OC0 = 0xab:0;
sfr	EP2OUT_CNT = 0xac;
sbit	FEP2OC4 = 0xac:4;
sbit	FEP2OC3 = 0xac:3;
sbit	FEP2OC2 = 0xac:2;
sbit	FEP2OC1 = 0xac:1;
sbit	FEP2OC0 = 0xac:0;
sfr	SIOM = 0xb4;
sbit	FSENB = 0xb4:7;
sbit	FSTART = 0xb4:6;
sbit	FSRATE1 = 0xb4:5;
sbit	FSRATE0 = 0xb4:4;
sbit	FSCKMD = 0xb4:2;
sbit	FSEDGE = 0xb4:1;
sbit	FTXRX = 0xb4:0;
sfr	SIOR = 0xb5;
sfr	SIOB = 0xb6;
sfr	P0M = 0xb8;
sbit	FP04M = 0xb8:4;
sbit	FP03M = 0xb8:3;
sbit	FP02M = 0xb8:2;
sbit	FP01M = 0xb8:1;
sbit	FP00M = 0xb8:0;
sfr	PEDGE = 0xbf;
sbit	FP00G1 = 0xbf:4;
sbit	FP00G0 = 0xbf:3;
sfr	P1W = 0xc0;
sbit	FP17W = 0xc0:7;
sbit	FP16W = 0xc0:6;
sbit	FP15W = 0xc0:5;
sbit	FP14W = 0xc0:4;
sbit	FP13W = 0xc0:3;
sbit	FP12W = 0xc0:2;
sbit	FP11W = 0xc0:1;
sbit	FP10W = 0xc0:0;
sfr	P1M = 0xc1;
sbit	FP17M = 0xc1:7;
sbit	FP16M = 0xc1:6;
sbit	FP15M = 0xc1:5;
sbit	FP14M = 0xc1:4;
sbit	FP13M = 0xc1:3;
sbit	FP12M = 0xc1:2;
sbit	FP11M = 0xc1:1;
sbit	FP10M = 0xc1:0;
sfr	P5M = 0xc5;
sbit	FP52M = 0xc5:2;
sbit	FP51M = 0xc5:1;
sbit	FP50M = 0xc5:0;
sfr	INTRQ = 0xc8;
sbit	FUSBIRQ = 0xc8:6;
sbit	FTC0IRQ = 0xc8:5;
sbit	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bit	FSTKPB0 = 0xdf:0;
sfr	P0UR = 0xe0;
sbit	FP04R = 0xe0:4;
sbit	FP03R = 0xe0:3;
sbit	FP02R = 0xe0:2;
sbit	FP01R = 0xe0:1;
sbit	FP00R = 0xe0:0;
sfr	P1UR = 0xe1;
sfr	P5UR = 0xe5;
sbit	FP52R = 0xe5:2;
sbit	FP51R = 0xe5:1;
sbit	FP50R = 0xe5:0;
sfr	_YZ = 0xe7;
sfr	P1OC = 0xe9;
sbit	FP52OC = 0xe9:3;
sbit	FP50OC = 0xe9:2;
sbit	FP11OC = 0xe9:1;
sbit	FP10OC = 0xe9:0;
sfr	STK7L = 0xf0;
sfr	STK7H = 0xf1;
sbit	FS7PC12 = 0xf1:4;
sbit	FS7PC11 = 0xf1:3;
sbit	FS7PC10 = 0xf1:2;
sbit	FS7PC9 = 0xf1:1;
sbit	FS7PC8 = 0xf1:0;
sfr	STK6L = 0xf2;
sfr	STK6H = 0xf3;
sbit	FS6PC12 = 0xf3:4;
sbit	FS6PC11 = 0xf3:3;
sbit	FS6PC10 = 0xf3:2;
sbit	FS6PC9 = 0xf3:1;
sbit	FS6PC8 = 0xf3:0;
sfr	STK5L = 0xf4;
sfr	STK5H = 0xf5;
sbit	FS5PC12 = 0xf5:4;
sbit	FS5PC11 = 0xf5:3;
sbit	FS5PC10 = 0xf5:2;
sbit	FS5PC9 = 0xf5:1;
sbit	FS5PC8 = 0xf5:0;
sfr	STK4L = 0xf6;
sfr	STK4H = 0xf7;
sbit	FS4PC12 = 0xf7:4;
sbit	FS4PC11 = 0xf7:3;
sbit	FS4PC10 = 0xf7:2;
sbit	FS4PC9 = 0xf7:1;
sbit	FS4PC8 = 0xf7:0;
sfr	STK3L = 0xf8;
sfr	STK3H = 0xf9;
sbit	FS3PC12 = 0xf9:4;
sbit	FS3PC11 = 0xf9:3;
sbit	FS3PC10 = 0xf9:2;
sbit	FS3PC9 = 0xf9:1;
sbit	FS3PC8 = 0xf9:0;
sfr	STK2L = 0xfa;
sfr	STK2H = 0xfb;
sbit	FS2PC12 = 0xfb:4;
sbit	FS2PC11 = 0xfb:3;
sbit	FS2PC10 = 0xfb:2;
sbit	FS2PC9 = 0xfb:1;
sbit	FS2PC8 = 0xfb:0;
sfr	STK1L = 0xfc;
sfr	STK1H = 0xfd;
sbit	FS1PC12 = 0xfd:4;
sbit	FS1PC11 = 0xfd:3;
sbit	FS1PC10 = 0xfd:2;
sbit	FS1PC9 = 0xfd:1;
sbit	FS1PC8 = 0xfd:0;
sfr	STK0L = 0xfe;
sfr	STK0H = 0xff;
sbit	FS0PC12 = 0xff:4;
sbit	FS0PC11 = 0xff:3;
sbit	FS0PC10 = 0xff:2;
sbit	FS0PC9 = 0xff:1;
sbit	FS0PC8 = 0xff:0;
#define SLEEPMODE __asm{SleepMode}
#define GREENMODE __asm{GreenMode}
#define SLOWMODE __asm{SlowMode}
#define SLOW2NORMAL __asm{Slow2Normal}
#endif
