ifndef __SN8P2712__INC__H
SN8P2712__INC__H equ 1
	L	EQU	0x80
	H	EQU	0x81
	R	EQU	0x82
	Z	EQU	0x83
	
	Y	EQU	0x84
	REG_085H	EQU	0x85
	PFLAG	EQU	0x86
		FZ	EQU	PFLAG.0
		FDC	EQU	PFLAG.1
		FC	EQU	PFLAG.2
		FLVD24	EQU	PFLAG.4
		FLVD36	EQU	PFLAG.5
		FNPD	EQU	PFLAG.6
		FNT0	EQU	PFLAG.7
		
	REG_087H	EQU	0x87
	REG_088H	EQU	0x88
	REG_089H	EQU	0x89
	REG_08AH	EQU	0x8a
	REG_08BH	EQU	0x8b
	REG_08CH	EQU	0x8c
	REG_08DH	EQU	0x8d
	REG_08EH	EQU	0x8e
	REG_08FH	EQU	0x8f
	
	REG_090H	EQU	0x90
	REG_091H	EQU	0x91
	REG_092H	EQU	0x92
	REG_093H	EQU	0x93
	REG_094H	EQU	0x94
	REG_095H	EQU	0x95
	REG_096H	EQU	0x96
	REG_097H	EQU	0x97
	
	REG_098H	EQU	0x98
	REG_099H	EQU	0x99
	REG_09AH	EQU	0x9a
	REG_09BH	EQU	0x9b
	REG_09CH	EQU	0x9c
	REG_09DH	EQU	0x9d
	REG_09EH	EQU	0x9e
	REG_09FH	EQU	0x9f

	REG_0A0H	EQU		0A0H
	REG_0A1H	EQU		0A1H
	REG_0A2H	EQU		0A2H
	REG_0A3H	EQU		0A3H
	
	REG_0A4H	EQU		0A4H
	REG_0A5H	EQU		0A5H	
	REG_0A6H	EQU		0A6H
	REG_0A7H	EQU		0A7H
	
	REG_0A8H	EQU		0A8H
	REG_0A9H	EQU		0A9H
	REG_0AAH	EQU		0AAH
	PICON1		EQU		0ABH
	
	PWMS		EQU		0ACH
	PICON		EQU		0ADH
	
	P4CON		EQU		0AEH
		FP4CON0		EQU		P4CON.0
		FP4CON1		EQU		P4CON.1
		FP4CON2		EQU		P4CON.2
		FP4CON3		EQU		P4CON.3
		FP4CON4		EQU		P4CON.4
	VREFH		EQU		0AFH
		FVHS0		EQU		VREFH.0
		FVHS1		EQU		VREFH.1
		FEVHENB		EQU		VREFH.7

	REG_0B0H 		EQU		0B0H

	ADM 		EQU		0B1H
		FCHS0		EQU		ADM.0
		FCHS1		EQU		ADM.1
		FCHS2		EQU		ADM.2
		FCHS3		EQU		ADM.3
		
		FGCHS		EQU		ADM.4
		FEOC		EQU		ADM.5
		FADS		EQU		ADM.6
		FADENB		EQU		ADM.7

	ADB 		EQU		0B2H

	ADR 		EQU		0B3H
		FADB0		EQU		ADR.0
		FADB1		EQU		ADR.1
		FADB2		EQU		ADR.2
		FADB3		EQU		ADR.3
		
		FADCKS0		EQU		ADR.4
		;FADLEN		EQU		ADR.5
		FADCKS1		EQU		ADR.6

	ADT 		EQU		0B4H
		FADT0		EQU		ADT.0
		FADT1		EQU		ADT.1
		FADT2		EQU		ADT.2
		FADT3		EQU		ADT.3
		
		FADT4		EQU		ADT.4
		FADTS0		EQU		ADT.6
		FADTS1		EQU		ADT.7
		
	ADF0 		EQU		0B5H
	ADF1 		EQU		0B6H
	REG_0B7h 	EQU		0B7H
	
	P0M		EQU		0B8H
		FP00M		EQU		P0M.0
		FP01M		EQU		P0M.1
		FP02M		EQU		P0M.2
		FP03M		EQU		P0M.3
		FP04M		EQU		P0M.4
		FP05M		EQU		P0M.5
		FP06M		EQU		P0M.6
		FP07M		EQU		P0M.7
		
	REG_0B9h 		EQU		0B9H
	TC3M 		EQU		0BAH
	TC3C 		EQU		0BBH
	
	TC3R 		EQU		0BCH
	TC3D 		EQU		0BDH
	IRCF 		EQU		0BEH
	
	PEDGE		EQU		0BFH
		FP00G0		EQU		PEDGE.3
		FP00G1		EQU		PEDGE.4
	REG_0C0h		EQU		0C0H
	REG_0C1h		EQU		0C1H
	
	P2M		EQU		0C2H
		FP25M		EQU		P2M.5
		FP24M		EQU		P2M.4
		FP23M		EQU		P2M.3
		FP22M		EQU		P2M.2
		FP21M		EQU		P2M.1
		FP20M		EQU		P2M.0
		
	REG_0C3h		EQU		0C3H
	
	P4M		EQU		0C4H
		FP47M		EQU		P4M.7
		FP46M		EQU		P4M.6
		FP45M		EQU		P4M.5
		FP44M		EQU		P4M.4
		FP43M		EQU		P4M.3
		FP42M		EQU		P4M.2
		FP41M		EQU		P4M.1
		FP40M		EQU		P4M.0
		
	P5M		EQU		0C5H
		FP54M		EQU		P5M.4
		FP53M		EQU		P5M.3
		
	REG_0C6h		EQU		0C6H
	REG_0C7h		EQU		0C7H

	INTRQ		EQU		0C8H
		FADCIRQ		EQU		INTRQ.7
		FADCIF		EQU		INTRQ.7
		FTC1IRQ		EQU		INTRQ.6
		FTC1IF		EQU		INTRQ.6
		FTC0IRQ		EQU		INTRQ.5
		FTC0IF		EQU		INTRQ.5
    		FTC2IRQ  	EQU 		INTRQ.4
    		FTC2IF		EQU 		INTRQ.4
    		
    		FTC3IRQ		EQU 		INTEN.3
    		FTC3IF		EQU 		INTEN.3
    		FP01IRQ		EQU 		INTEN.1
		FINT1IF		EQU 		INTEN.1
		FP00IRQ		EQU		INTRQ.0
		FINT0IF		EQU		INTRQ.0
		
	INTEN		EQU		0C9H
		FADCIEN		EQU		INTEN.7
		FTC1IEN		EQU 		INTEN.6
		FTC0IEN		EQU		INTEN.5
		FTC2IEN		EQU 		INTEN.4
		
		FTC3IEN		EQU 		INTEN.3
		FP01IEN		EQU 		INTEN.1
		FINT1IE		EQU 		INTEN.1
		FP00IEN		EQU		INTEN.0
		FINT0IE		EQU		INTEN.0
		
	OSCM		EQU		0CAH
		FCPUM1		EQU		OSCM.4
		FCPUM0		EQU		OSCM.3
		FCLKMD		EQU		OSCM.2
		FSTPHX		EQU		OSCM.1
		
	REG_0CBh	EQU		0CBH

	WDTR		EQU		0CCH
	TC0R		EQU		0CDH
	PCL		EQU		0CEH
	PCH		EQU		0CFH
P0		EQU 		0D0H
		FP00		EQU 		P0.0
		FP01		EQU 		P0.1
		FP02		EQU 		P0.2
		FP03		EQU 		P0.3
		FP04		EQU 		P0.4
		FP05		EQU 		P0.5
		FP06		EQU 		P0.6
		FP07		EQU 		P0.7
;*******************************************************************************

	REG_0D1h		EQU 		0D1H
	P2		EQU 		0D2H
		FP20		EQU 		P2.0
		FP21		EQU 		P2.1
		FP22		EQU 		P2.2
		FP23		EQU 		P2.3
		FP24		EQU 		P2.4
		FP25		EQU 		P2.5
		
	REG_0D3h		EQU 		0D3H

	P4		EQU		0D4H
		FP47		EQU		P4.7
		FP46		EQU		P4.6
		FP45		EQU		P4.5
		FP44		EQU		P4.4
		FP43		EQU		P4.3
		FP42		EQU		P4.2
		FP41		EQU		P4.1
		FP40		EQU		P4.0
;*******************************************************************************
	P5		EQU 		0D5H
		FP54		EQU		P5.4
		FP53		EQU		P5.3
		
	REG_0D6h		EQU 		0D6H
	REG_0D7h		EQU 		0D7H
	
	T0M		EQU		0D8H
		FTC2X8	 	EQU  	 	T0M.4
		FTC1X8	 	EQU  	 	T0M.3
		FTC0X8	 	EQU  	 	T0M.2
		FTC0GN 		EQU  	 	T0M.1
		
   	REG_0D9h		EQU		0D9H
   	
	TC0M		EQU		0DAH
		FTC0ENB		EQU		TC0M.7
		FTC0R		EQU		TC0M.7
		FTC0RATE2	EQU		TC0M.6
		FTC0PS2		EQU		TC0M.6
		FTC0RATE1	EQU		TC0M.5
		FTC0PS1		EQU		TC0M.5
		FTC0RATE0	EQU		TC0M.4
		FTC0PS0		EQU		TC0M.4
		
		FTC0CKS		EQU		TC0M.3
       		FALOAD0    	EQU		TC0M.2
       		FTC0OUT   	EQU		TC0M.1
       		FPWM0OUT   	EQU		TC0M.0
       		FPWM0EN   	EQU		TC0M.0
       		
	TC0C		EQU		0DBH
	
	TC1M		EQU		0DCH
		FTC1ENB		EQU		TC1M.7
		FTC1R		EQU		TC1M.7
		FTC1RATE2	EQU		TC1M.6
		FTC1PS2		EQU		TC1M.6
		FTC1RATE1	EQU		TC1M.5
		FTC1PS1		EQU		TC1M.5
		FTC1RATE0	EQU		TC1M.4
		FTC1PS0		EQU		TC1M.4
		
		FTC1CKS		EQU		TC1M.3
		FALOAD1    	EQU		TC1M.2
       		FTC1OUT   	EQU		TC1M.1
       		FPWM1OUT   	EQU		TC1M.0
       		FPWM1EN   	EQU		TC1M.0
       		

	TC1C		EQU		0DDH
	TC1R		EQU		0DEH
	
	STKP		EQU		0DFH
		FGIE		EQU		STKP.7
		FSTKPB2		EQU		STKP.2
		FSTKPB1		EQU		STKP.1
		FSTKPB0		EQU		STKP.0

    	P0UR		EQU  		0E0H
    	
    	REG_0E1h		EQU  		0E1H
    	
    	P2UR		EQU  		0E2H
    	
    	REG_0E3h		EQU  		0E3H
    	
    	P4UR		EQU  		0E4H	;
    	P5UR		EQU  		0E5H
    	
	@HL		EQU		0E6H	;
	@YZ		EQU		0E7H	;
    	
    	REG_0E8h		EQU  		0E8H
    	REG_0E9h		EQU  		0E9H
    	REG_0EAh		EQU  		0EAH
    	
    	TC2CH		EQU  		0EBH
    	
    	TC2M		EQU  		0ECH
		FTC2ENB		EQU		TC2M.7
		FTC2R		EQU		TC2M.7
		FTC2RATE2	EQU		TC2M.6
		FTC2PS2		EQU		TC2M.6
		FTC2RATE1	EQU		TC2M.5
		FTC2PS1		EQU		TC2M.5
		FTC2RATE0	EQU		TC2M.4
		FTC2PS0		EQU		TC2M.4
		
		FTC2CKS		EQU		TC2M.3
		FALOAD2    	EQU		TC2M.2
       		FTC2OUT   	EQU		TC2M.1
       		FPWM2OUT   	EQU		TC2M.0
       		FPWM2EN   	EQU		TC2M.0
       		
    	TC2C		EQU  		0EDH
    	TC2CL		EQU  		0EDH
    	TC2R		EQU  		0EEH
    	
	
	STK7L	EQU	0xf0
	STK7H	EQU	0xf1
	STK6L	EQU	0xf2
	STK6H	EQU	0xf3
	STK5L	EQU	0xf4
	STK5H	EQU	0xf5
	STK4L	EQU	0xf6
	STK4H	EQU	0xf7
	STK3L	EQU	0xf8
	STK3H	EQU	0xf9
	STK2L	EQU	0xfa
	STK2H	EQU	0xfb
	STK1L	EQU	0xfc
	STK1H	EQU	0xfd
	STK0L	EQU	0xfe
	STK0H	EQU	0xff
@RST_WDT	macro		
		MOV	A, #0x5A
		B0MOV	WDTR, A
	endm

SleepMode	macro	
		B0BSET	FCPUM0
	endm

GreenMode	macro	
		B0BSET	FCPUM1
		NOP
		NOP
	endm

SlowMode	macro	
		B0BSET	FCLKMD
		B0BSET	FSTPHX
	endm

Slow2Normal	macro	
		B0BCLR	FSTPHX
		NOP
		NOP
		NOP
		B0BCLR	FCLKMD
	endm

endif
