#ifndef __SN8P1907__H
#define __SN8P1907__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	FC = 0x86:2;
sbit	FDC = 0x86:1;
sbit	FZ = 0x86:0;
sfr	RBANK = 0x87;
sbit	FRBNKS0 = 0x87:0;
sbit	FRBNKS1 = 0x87:1;
sbit	FRBNKS2 = 0x87:2;
sbit	FRBNKS3 = 0x87:3;
#if ICE_Mode == 1
sfr	LCDM1 = 0XCB;
sbit	FLCDBNK = 0XCB:5;
sbit	FLCDENB = 0XCB:3;
sfr	Dummy = 0X8F;
sbit	FLCDDATA = 0X8F:4;
sbit	FLCDBIAS = 0X8F:2;
sbit	FLCDRATE = 0X8F:1;
sbit	FLCDCLK = 0X8F:0;
#else
sfr	LCDM1 = 0x89;
sbit	FLCDBNK = 0x89:5;
sbit	FLCDDATA = 0x89:4;
sbit	FLCDENB = 0x89:3;
sbit	FLCDBIAS = 0x89:2;
sbit	FLCDRATE = 0x89:1;
sbit	FLCDCLK = 0x89:0;
#endif
sfr	AMPM = 0x90;
sbit	FBGRENB = 0x90:6;
sbit	FFDS1 = 0x90:5;
sbit	FFDS0 = 0x90:4;
sbit	FGS2 = 0x90:3;
sbit	FGS1 = 0x90:2;
sbit	FGS0 = 0x90:1;
sbit	FAMPENB = 0x90:0;
sfr	AMPCHS = 0x91;
sbit	FCHS2 = 0x91:2;
sbit	FCHS1 = 0x91:1;
sbit	FCHS0 = 0x91:0;
sfr	AMPCKS = 0x92;
sbit	FAMPCKS2 = 0x92:2;
sbit	FAMPCKS1 = 0x92:1;
sbit	FAMPCKS0 = 0x92:0;
sfr	ADCM = 0x93;
sbit	FIRVS = 0x93:3;
sbit	FRVS1 = 0x93:2;
sbit	FRVS0 = 0x93:1;
sbit	FADCENB = 0x93:0;
sfr	ADCKS = 0X94;
sfr	CPM = 0x95;
sbit	FACMENB = 0x95:7;
sbit	FAVDDRENB = 0x95:6;
sbit	FAVESEL = 0x95:5;
sbit	FAVENB = 0x95:4;
sbit	FCPSTS = 0x95:3;
sbit	FCPAUTO = 0x95:2;
sbit	FCPON = 0x95:1;
sbit	FCPRENB = 0x95:0;
sfr	CPCKS = 0x96;
sbit	FCPCKS3 = 0x96:3;
sbit	FCPCKS2 = 0x96:2;
sbit	FCPCKS1 = 0x96:1;
sbit	FCPCKS0 = 0x96:0;
sfr	DFM = 0x97;
sbit	FWRS0 = 0x97:2;
sbit	FDRDY = 0x97:0;
sfr	ADCDL = 0x98;
sfr	ADCDH = 0x99;
sfr	LBTM = 0x9A;
sbit	FLBTO = 0x9A:2;
sbit	FP41IO = 0x9A:1;
sbit	FLBTENB = 0x9A:0;
sfr	CPMTEST = 0x9B;
sbit	FCPSAVE = 0x9B:0;
sfr	PEDGE = 0xBF;
sbit	FPEDGEN = 0xBF:7;
sbit	FP00G0 = 0xBF:3;
sbit	FP00G1 = 0xBF:4;
sfr	P1M = 0xC1;
sbit	FP13M = 0xC1:3;
sbit	FP12M = 0xC1:2;
sbit	FP11M = 0xC1:1;
sbit	FP10M = 0xC1:0;
sfr	P2M = 0xC2;
sbit	FP21M = 0xC2:1;
sbit	FP20M = 0xC2:0;
sfr	INTRQ = 0xc8;
sbit	FT0IRQ = 0xc8:4;
sbit	FP00IRQ = 0xc8:0;
sfr	INTEN = 0xc9;
sbit	FT0IEN = 0xc9:4;
sbit	FP00IEN = 0xc9:0;
sfr	OSCM = 0xCA;
sbit	FWTCKS = 0xCA:7;
sbit	FWDRST = 0xCA:6;
sbit	FWDRATE = 0xCA:5;
sbit	FCPUM0 = 0xCA:3;
sbit	FCLKMD = 0xCA:2;
sbit	FSTPHX = 0xCA:1;
sfr	PCL = 0xCE;
sfr	PCH = 0xCF;
sfr	P0 = 0xd0;
sbit	FP00 = 0xd0:0;
sfr	P1 = 0xD1;
sbit	FP13 = 0xD1:3;
sbit	FP12 = 0xD1:2;
sbit	FP11 = 0xD1:1;
sbit	FP10 = 0xD1:0;
sfr	P2 = 0xD2;
sbit	FP21 = 0xD2:1;
sbit	FP20 = 0xD2:0;
sfr	P4 = 0xD4;
sbit	FP42 = 0xD4:2;
sbit	FP41 = 0xD4:1;
sbit	FP40 = 0xD4:0;
sfr	P5 = 0xD5;
sbit	FP52 = 0xD5:2;
sbit	FP51 = 0xD5:1;
sbit	FP50 = 0xD5:0;
sfr	T0M = 0xD8;
sbit	FT0ENB = 0xD8:7;
sbit	FT0RATE2 = 0xD8:6;
sbit	FT0RATE1 = 0xD8:5;
sbit	FT0RATE0 = 0xD8:4;
sfr	T0C = 0xD9;
sfr	STKP = 0xDF;
sbit	FGIE = 0xDF:7;
sbit	FSTKPB3 = 0xDF:3;
sbit	FSTKPB2 = 0xDF:2;
sbit	FSTKPB1 = 0xDF:1;
sbit	FSTKPB0 = 0xDF:0;
sfr	P1UR = 0xE1;
sbit	FP13R = 0xE1:3;
sbit	FP12R = 0xE1:2;
sbit	FP11R = 0xE1:1;
sbit	FP10R = 0xE1:0;
sfr	P2UR = 0xE2;
sbit	FP21R = 0xE2:1;
sbit	FP20R = 0xE2:0;
sfr	_YZ = 0xE7;
sfr	DP1X = 0xE7;
sfr	STK7L = 0xf0;
sfr	STK7H = 0xf1;
sfr	STK6L = 0xf2;
sfr	STK6H = 0xf3;
sfr	STK5L = 0xf4;
sfr	STK5H = 0xf5;
sfr	STK4L = 0xf6;
sfr	STK4H = 0xf7;
sfr	STK3L = 0xf8;
sfr	STK3H = 0xf9;
sfr	STK2L = 0xfa;
sfr	STK2H = 0xfb;
sfr	STK1L = 0xfc;
sfr	STK1H = 0xfd;
sfr	STK0L = 0xfe;
sfr	STK0H = 0xff;
#define SLEEPMODE __asm{SleepMode}
#define SLOWMODE __asm{SlowMode}
#define SLOW2NORMAL __asm{Slow2Normal}
#if ICE_Mode == 1
sfr	P3M = 0xC3;
sbit	FP37M = 0xC3:7;
sbit	FP36M = 0xC3:6;
sbit	FP35M = 0xC3:5;
sbit	FP34M = 0xC3:4;
sbit	FP33M = 0xC3:3;
sbit	FP32M = 0xC3:2;
sbit	FP31M = 0xC3:1;
sbit	FP30M = 0xC3:0;
sfr	P3 = 0xD3;
sbit	FP37 = 0xD3:7;
sbit	FP36 = 0xD3:6;
sbit	FP35 = 0xD3:5;
sbit	FP34 = 0xD3:4;
sbit	FP33 = 0xD3:3;
sbit	FP32 = 0xD3:2;
sbit	FP31 = 0xD3:1;
sbit	FP30 = 0xD3:0;
sfr	P3UR = 0xE3;
sbit	FP37R = 0xE3:7;
sbit	FP36R = 0xE3:6;
sbit	FP35R = 0xE3:5;
sbit	FP34R = 0xE3:4;
sbit	FP33R = 0xE3:3;
sbit	FP32R = 0xE3:2;
sbit	FP31R = 0xE3:1;
sbit	FP30R = 0xE3:0;
#endif
#endif
