// FM8PE531A C General Head Ver:1.00.000, lastedit:20160503
// Header Author:hu_cy; hu_cy@feeling-tech.com.tw
// CHIP Version:N/A(General)
// Compatible spec V0.00.001
//--------------HEAD Credit History-------------------------------------------
//2016/05/03	Release
//--------------Common define Segment-----------------------------------------
#ifndef	__8PE531A_H

#define	__8PE531A_H

//--------------Misc instruction define---------------------------------------
#define		SLEEP()		asm("SLEEP")
#define		NOP()		asm("NOP")
#define		CLRWDT()	asm("CLRWDT")
#define		ENI()		INTENbits.GIE=1
#define		DISI()		INTENbits.GIE=0

//--------------Interrupt vector address--------------------------------------
#define	HWINT_BASE	0x008

//--------------Operation Registers Maps--------------------------------------
#define INDF_BASE	0x00
#define PCL_BASE	0x02
#define STATUS_BASE	0x03
#define FSR_BASE	0x04
#define IOSTA_BASE	0x05
#define PORTA_BASE	0x06
#define IOSTB_BASE	0x07
#define PORTB_BASE	0x08
#define T1CON_BASE	0x09
#define TMR1LB_BASE	0x0A
#define TMR1HB_BASE	0x0B
#define OSCCON_BASE	0x0C
#define LVDTCON_BASE	0x0D
#define INTEN_BASE	0x0E
#define INTFLAG_BASE	0x0F
#define PWMCON_BASE	0x10
#define P0DPR_BASE	0x11
#define P1DPR_BASE	0x12
#define RFCCON_BASE	0x13
#define RFCDLB_BASE	0x14
#define RFCDHB_BASE	0x15
#define AWUCON_BASE	0x10
#define APHCON_BASE	0x11
#define BWUCON_BASE	0x12
#define BPHCON_BASE	0x13
#define CMPCON1_BASE	0x14
#define CMPCON2_BASE	0x15


volatile unsigned char	INDF @ INDF_BASE;
volatile unsigned char	PCL @ PCL_BASE;
//-------------------------------
volatile unsigned char	STATUS @ STATUS_BASE;
typedef struct	{
		volatile unsigned char C	:1;
		volatile unsigned char DC	:1;
		volatile unsigned char Z	:1;
		volatile unsigned char PD	:1;
		volatile unsigned char TO	:1;
		unsigned char PG0	:1;
		unsigned char PG1	:1;
		volatile unsigned char RST	:1;
		}tagSTATUSbits;
volatile tagSTATUSbits	STATUSbits @ STATUS_BASE;

//-------------------------------
volatile unsigned char	FSR @ FSR_BASE;
typedef struct	{
		unsigned char		:6;
		unsigned char RP0	:1;
		unsigned char RP1	:1;
		}tagFSRbits;
volatile tagFSRbits	FSRbits @ FSR_BASE;

//-------------------------------
volatile unsigned char	IOSTA @ IOSTA_BASE;
typedef struct	{
		volatile unsigned char IOSTA0	:1;
		volatile unsigned char IOSTA1	:1;
		volatile unsigned char IOSTA2	:1;
		volatile unsigned char IOSTA3	:1;
		volatile unsigned char IOSTA4	:1;
		volatile unsigned char IOSTA5	:1;
		}tagIOSTAbits;
volatile tagIOSTAbits	IOSTAbits @ IOSTA_BASE;

//-------------------------------
volatile unsigned char	PORTA @ PORTA_BASE;
typedef struct	{
		volatile unsigned char IOA0	:1;
		volatile unsigned char IOA1	:1;
		volatile unsigned char IOA2	:1;
		volatile unsigned char IOA3	:1;
		volatile unsigned char IOA4	:1;
		volatile unsigned char IOA5	:1;
		}tagPORTAbits;
volatile tagPORTAbits	PORTAbits @ PORTA_BASE;

//-------------------------------
volatile unsigned char	IOSTB @ IOSTB_BASE;
typedef struct	{
		volatile unsigned char IOSTB0	:1;
		volatile unsigned char IOSTB1	:1;
		volatile unsigned char IOSTB2	:1;
		volatile unsigned char IOSTB3	:1;
		volatile unsigned char IOSTB4	:1;
		volatile unsigned char IOSTB5	:1;
		volatile unsigned char IOSTB6	:1;
		volatile unsigned char IOSTB7	:1;
		}tagIOSTBbits;
volatile tagIOSTBbits	IOSTBbits @ IOSTB_BASE;

//-------------------------------
volatile unsigned char	PORTB @ PORTB_BASE;
typedef struct	{
		volatile unsigned char IOB0	:1;
		volatile unsigned char IOB1	:1;
		volatile unsigned char IOB2	:1;
		volatile unsigned char IOB3	:1;
		volatile unsigned char IOB4	:1;
		volatile unsigned char IOB5	:1;
		volatile unsigned char IOB6	:1;
		volatile unsigned char IOB7	:1;
		}tagPORTBbits;
volatile tagPORTBbits	PORTBbits @ PORTB_BASE;

//-------------------------------
unsigned char	T1CON @ T1CON_BASE;
typedef struct	{
		unsigned char T1EN 	:1;
		unsigned char T1CS 	:1;
		unsigned char      	:1;
		unsigned char T1PS0	:1;
		unsigned char T1PS1	:1;
		}tagT1CONbits;
tagT1CONbits	T1CONbits @ T1CON_BASE;

//-------------------------------
volatile unsigned char	TMR1LB @ TMR1LB_BASE;
volatile unsigned char	TMR1HB @ TMR1HB_BASE;

//-------------------------------
unsigned char	OSCCON @ OSCCON_BASE;
typedef struct	{
		unsigned char IRCF0     :1;
		unsigned char IRCF1     :1;
		unsigned char IRCF2     :1;
		unsigned char CPUS      :1;
		unsigned char WDTSEL0   :1;
		unsigned char WDTSEL1   :1;
		unsigned char IRCEN	:1;
		unsigned char WDTEN	:1;
		}tagOSCCONbits;
tagOSCCONbits	OSCCONbits @ OSCCON_BASE;

//-------------------------------
unsigned char	LVDTCON @ LVDTCON_BASE;
typedef struct	{
		unsigned char LVDSEL0	:1;
		unsigned char LVDSEL1   :1;
		unsigned char LVDSEL2   :1;
		unsigned char INTEDG    :1;
		unsigned char LVREN     :1;
		unsigned char IOB3EN    :1;
		unsigned char RDPORT    :1;
		unsigned char EIS	:1;
		}tagLVDTCONbits;
tagLVDTCONbits	LVDTCONbits @ LVDTCON_BASE;

//-------------------------------
volatile unsigned char	INTEN @ INTEN_BASE;
typedef struct	{
		unsigned char T1IE      :1;
		unsigned char RFCIE     :1;
		unsigned char INTIE     :1;
		unsigned char CMPIE     :1;
		unsigned char LVDTIE	:1;
		unsigned char 		:2;
		volatile unsigned char GIE	:1;
		}tagINTENbits;
volatile tagINTENbits	INTENbits @ INTEN_BASE;

//-------------------------------
volatile unsigned char	INTFLAG @ INTFLAG_BASE;
typedef struct	{
		volatile unsigned char T1IF      :1;
		volatile unsigned char RFCIF     :1;
		volatile unsigned char INTIF     :1;
		volatile unsigned char CMPIF     :1;
		volatile unsigned char LVDTIF	:1;
		}tagINTFLAGbits;
volatile tagINTFLAGbits	INTFLAGbits @ INTFLAG_BASE;

//-------------------------------
unsigned char	PWMCON @ PWMCON_BASE :BANK0;
typedef struct	{
		unsigned char P0EN      :1;
		unsigned char P1EN      :1;
		unsigned char PWMCS0    :1;
		unsigned char PWMCS1    :1;
		unsigned char PWMCS2	:1;
		}tagPWMCONbits;
tagPWMCONbits	PWMCONbits @ PWMCON_BASE :BANK0;

//-------------------------------
unsigned char	P0DPR @ P0DPR_BASE :BANK0;
unsigned char	P1DPR @ P1DPR_BASE :BANK0;

//-------------------------------
volatile unsigned char	RFCCON @ RFCCON_BASE :BANK0;
typedef struct	{
		unsigned char RFCS0	:1;
		unsigned char RFCS1	:1;
		unsigned char 		:2;
		unsigned char RFCMOD	:1;
		unsigned char 		:1;
		volatile unsigned char START	:1;
		unsigned char RFCON	:1;
		}tagRFCCONbits;
volatile tagRFCCONbits	RFCCONbits @ RFCCON_BASE :BANK0;

//-------------------------------
volatile unsigned char	RFCDLB @ RFCDLB_BASE :BANK0;

//-------------------------------
volatile unsigned char	RFCDHB @ RFCDHB_BASE :BANK0;
typedef struct	{
		unsigned char 		:7;
		volatile unsigned char RFCOV	:1;
		}tagRFCDHBbits;
volatile tagRFCDHBbits	RFCDHBbits @ RFCDHB_BASE :BANK0;

//-------------------------------
unsigned char	AWUCON @ AWUCON_BASE :BANK2;
typedef struct	{
		unsigned char WUA0	:1;
		unsigned char WUA1	:1;
		unsigned char WUA2	:1;
		unsigned char WUA3	:1;
		unsigned char WUA4	:1;
		unsigned char WUA5	:1;
		}tagAWUCONbits;
tagAWUCONbits	AWUCONbits @ AWUCON_BASE :BANK2;

//-------------------------------
unsigned char	APHCON @ APHCON_BASE :BANK2;
typedef struct	{
		unsigned char PHA0	:1;
		unsigned char PHA1	:1;
		unsigned char PHA2	:1;
		unsigned char PHA3	:1;
		unsigned char PHA4	:1;
		unsigned char PHA5	:1;
		}tagAPHCONbits;
tagAPHCONbits	APHCONbits @ APHCON_BASE :BANK2;

//-------------------------------
unsigned char	BWUCON @ BWUCON_BASE :BANK2;
typedef struct	{
		unsigned char WUB0	:1;
		unsigned char WUB1	:1;
		unsigned char WUB2	:1;
		unsigned char WUB3	:1;
		unsigned char WUB4	:1;
		unsigned char WUB5	:1;
		unsigned char WUB6	:1;
		unsigned char WUB7	:1;
		}tagBWUCONbits;
tagBWUCONbits	BWUCONbits @ BWUCON_BASE :BANK2;

//-------------------------------
unsigned char	BPHCON @ BPHCON_BASE :BANK2;
typedef struct	{
		unsigned char PHB0	:1;
		unsigned char PHB1	:1;
		unsigned char PHB2	:1;
		unsigned char		:1;
		unsigned char PHB4	:1;
		unsigned char PHB5	:1;
		unsigned char PHB6	:1;
		unsigned char PHB7	:1;
		}tagBPHCONbits;
tagBPHCONbits	BPHCONbits @ BPHCON_BASE :BANK2;

//-------------------------------
volatile unsigned char	CMPCON1 @ CMPCON1_BASE :BANK2;
typedef struct	{
		unsigned char CM0       :1;
		unsigned char CM1       :1;
		unsigned char CM2       :1;
		unsigned char CINS      :1;
		unsigned char CINV      :1;
		volatile unsigned char COUT	:1;
		}tagCMPCON1bits;
volatile tagCMPCON1bits	CMPCON1bits @ CMPCON1_BASE :BANK2;

//-------------------------------
unsigned char	CMPCON2 @ CMPCON2_BASE :BANK2;
typedef struct	{
		unsigned char CVR0      :1;
		unsigned char CVR1      :1;
		unsigned char CVR2      :1;
		unsigned char CVR3      :1;
		unsigned char CVRR      :1;
		unsigned char CVREN	:1;
		}tagCMPCON2bits;
tagCMPCON2bits	CMPCON2bits @ CMPCON2_BASE :BANK2;
#endif
