
/**************************************************************
;V1.2：按照《HSmcu_HeadFile_定义参考说明-V1.00-20241119》编辑
;Special function register definitions
;IC Type Support:
;	HS2303,
;	<HS2303-P(P版)用户手册V1.3.pdf>
;	<HS2303-P(Q版)用户手册V1.03.pdf>
;Updata:20241122
;Designer:LBW
;*************************************************************/


#ifndef __HS2303_H
#define __HS2303_H



//------------------------------------------------------//
typedef		signed char 				s8;   //有符号数
typedef		signed int 					s16;
typedef		signed long 				s32;
			
typedef		unsigned char 				u8;   //无符号整数
typedef		unsigned int  				u16;
typedef		unsigned long 				u32;
			
typedef		volatile unsigned char 		vu8; //无符号整数
typedef		volatile unsigned int  		vu16;
typedef		volatile unsigned long 		vu32;


//------------------------------------------------------//
//#define	NOP()		asm("NOP")    
//#define	CLRWDT()	asm("clrwdt")    
//#define	SLEEP()		asm("sleep")  


#define		NOP			asm("NOP")
#define		CLRWDT		asm("clrwdt")
#define		SLEEP		asm("sleep")


//------------------------------------------------------------
// system public Special function register definitions
//------------------------------------------------------------


volatile unsigned char      PCL			@ 0x002;


volatile unsigned char      OPTIONR		@ 0x001;
#define 	OPTION 		OPTIONR
#define 	OPTION_REG 	OPTIONR
	volatile bit	WK_CTRL			@ ((unsigned) & OPTIONR * 8) + 7;
	volatile bit	IE_SEL			@ ((unsigned) & OPTIONR * 8) + 6;
	volatile bit	PS_SEL			@ ((unsigned) & OPTIONR * 8) + 5;
	volatile bit	PS2				@ ((unsigned) & OPTIONR * 8) + 4;
	volatile bit	PS1				@ ((unsigned) & OPTIONR * 8) + 3;
	volatile bit	PS0				@ ((unsigned) & OPTIONR * 8) + 2;
	volatile bit	TR0				@ ((unsigned) & OPTIONR * 8) + 1;
	volatile bit	WDTE			@ ((unsigned) & OPTIONR * 8) + 0;

	volatile bit	FWK_CTRL		@ ((unsigned) & OPTIONR * 8) + 7;
	volatile bit	FIE_SEL			@ ((unsigned) & OPTIONR * 8) + 6;
	volatile bit	FPS_SEL			@ ((unsigned) & OPTIONR * 8) + 5;
	volatile bit	FPS2			@ ((unsigned) & OPTIONR * 8) + 4;
	volatile bit	FPS1			@ ((unsigned) & OPTIONR * 8) + 3;
	volatile bit	FPS0			@ ((unsigned) & OPTIONR * 8) + 2;
	volatile bit	FTR0			@ ((unsigned) & OPTIONR * 8) + 1;
	volatile bit	FWDTE			@ ((unsigned) & OPTIONR * 8) + 0;


volatile unsigned char      STATUS		@ 0x003;
	volatile bit	LVD				@ ((unsigned) & STATUS * 8) + 7;
	volatile bit	PB_CTRL			@ ((unsigned) & STATUS * 8) + 6;
	volatile bit	PA_CTRL			@ ((unsigned) & STATUS * 8) + 5;
	volatile bit	T				@ ((unsigned) & STATUS * 8) + 4;
	volatile bit	P				@ ((unsigned) & STATUS * 8) + 3;
	volatile bit	Z				@ ((unsigned) & STATUS * 8) + 2;
	volatile bit	DC				@ ((unsigned) & STATUS * 8) + 1;
	volatile bit	C				@ ((unsigned) & STATUS * 8) + 0;
														
	volatile bit	FLVD			@ ((unsigned) & STATUS * 8) + 7;
	volatile bit	FPB_CTRL		@ ((unsigned) & STATUS * 8) + 6;
	volatile bit	FPA_CTRL		@ ((unsigned) & STATUS * 8) + 5;
	volatile bit	FT				@ ((unsigned) & STATUS * 8) + 4;
	volatile bit	FP				@ ((unsigned) & STATUS * 8) + 3;
	volatile bit	FZ				@ ((unsigned) & STATUS * 8) + 2;
	volatile bit	FDC				@ ((unsigned) & STATUS * 8) + 1;
	volatile bit	FC				@ ((unsigned) & STATUS * 8) + 0;


volatile unsigned char		PORTA		@ 0x005;
volatile unsigned char		PA			@ 0x005;
	volatile bit 	PA7				@ ((unsigned) & PORTA * 8) + 7;
	volatile bit 	PA6				@ ((unsigned) & PORTA * 8) + 6;
	volatile bit 	PA5				@ ((unsigned) & PORTA * 8) + 5;
	volatile bit 	PA4				@ ((unsigned) & PORTA * 8) + 4;
	volatile bit 	PA3				@ ((unsigned) & PORTA * 8) + 3;
	volatile bit 	PA2				@ ((unsigned) & PORTA * 8) + 2;
	volatile bit 	PA1				@ ((unsigned) & PORTA * 8) + 1;
	volatile bit 	PA0				@ ((unsigned) & PORTA * 8) + 0;
	
	volatile bit 	FPA7			@ ((unsigned) & PORTA * 8) + 7;
	volatile bit 	FPA6			@ ((unsigned) & PORTA * 8) + 6;
	volatile bit 	FPA5			@ ((unsigned) & PORTA * 8) + 5;
	volatile bit 	FPA4			@ ((unsigned) & PORTA * 8) + 4;
	volatile bit 	FPA3			@ ((unsigned) & PORTA * 8) + 3;
	volatile bit 	FPA2			@ ((unsigned) & PORTA * 8) + 2;
	volatile bit 	FPA1			@ ((unsigned) & PORTA * 8) + 1;
	volatile bit 	FPA0			@ ((unsigned) & PORTA * 8) + 0;


volatile unsigned char		PORTB		@ 0x006;
volatile unsigned char		PB			@ 0x006;
	volatile bit	REM				@ ((unsigned) & PORTB * 8) + 7;
	volatile bit	PB7				@ ((unsigned) & PORTB * 8) + 7;
	volatile bit	PB4				@ ((unsigned) & PORTB * 8) + 4;
	volatile bit	PB3				@ ((unsigned) & PORTB * 8) + 3;
	volatile bit	PB2				@ ((unsigned) & PORTB * 8) + 2;
	volatile bit	PB1				@ ((unsigned) & PORTB * 8) + 1;
	volatile bit	PB0				@ ((unsigned) & PORTB * 8) + 0;
	                                                
	volatile bit	FREM			@ ((unsigned) & PORTB * 8) + 7;
	volatile bit	FPB7			@ ((unsigned) & PORTB * 8) + 7;
	volatile bit	FPB4			@ ((unsigned) & PORTB * 8) + 4;
	volatile bit	FPB3			@ ((unsigned) & PORTB * 8) + 3;
	volatile bit	FPB2			@ ((unsigned) & PORTB * 8) + 2;
	volatile bit	FPB1			@ ((unsigned) & PORTB * 8) + 1;
	volatile bit	FPB0			@ ((unsigned) & PORTB * 8) + 0;


volatile unsigned char		TMR0		@ 0x08;


volatile unsigned char		DRVR		@ 0x0A;
	volatile bit	REMK			@ ((unsigned) & DRVR * 8) + 7;
	volatile bit	REMI			@ ((unsigned) & DRVR * 8) + 6;
	volatile bit	ELE_SEL			@ ((unsigned) & DRVR * 8) + 3;
	volatile bit	DRV_2			@ ((unsigned) & DRVR * 8) + 2;
	volatile bit	DRV_1			@ ((unsigned) & DRVR * 8) + 1;
	volatile bit	DRV_0			@ ((unsigned) & DRVR * 8) + 0;
													             
	volatile bit	FREMK			@ ((unsigned) & DRVR * 8) + 7;
	volatile bit	FREMI			@ ((unsigned) & DRVR * 8) + 6;
	volatile bit	FELE_SEL		@ ((unsigned) & DRVR * 8) + 3;
	volatile bit	FDRV_2			@ ((unsigned) & DRVR * 8) + 2;
	volatile bit	FDRV_1			@ ((unsigned) & DRVR * 8) + 1;
	volatile bit	FDRV_0			@ ((unsigned) & DRVR * 8) + 0;
	

volatile unsigned char		TMR0H		@ 0x0B;
	

volatile unsigned char		TC0M		@ 0x0C;
volatile unsigned char		T0M			@ 0x0C;
	volatile bit	CPUM			@ ((unsigned) & TC0M * 8) + 7;
	volatile bit	GREEN_MODE		@ ((unsigned) & TC0M * 8) + 7;
	volatile bit	T0HLS			@ ((unsigned) & TC0M * 8) + 6;
	volatile bit	T0CK1S			@ ((unsigned) & TC0M * 8) + 5;
	volatile bit	PWM_W1			@ ((unsigned) & TC0M * 8) + 4;
	volatile bit	PWM_W2			@ ((unsigned) & TC0M * 8) + 3;
	volatile bit	T0CK0S  		@ ((unsigned) & TC0M * 8) + 2;
	volatile bit	T0_OV			@ ((unsigned) & TC0M * 8) + 1;
	volatile bit	T0_OVS			@ ((unsigned) & TC0M * 8) + 1;
	volatile bit	T0_OVW			@ ((unsigned) & TC0M * 8) + 0;

	volatile bit	FCPUM			@ ((unsigned) & TC0M * 8) + 7;
	volatile bit	FGREEN_MODE		@ ((unsigned) & TC0M * 8) + 7;
	volatile bit	FT0HLS			@ ((unsigned) & TC0M * 8) + 6;
	volatile bit	FT0CK1S			@ ((unsigned) & TC0M * 8) + 5;
	volatile bit	FPWM_W1			@ ((unsigned) & TC0M * 8) + 4;
	volatile bit	FPWM_W2			@ ((unsigned) & TC0M * 8) + 3;
	volatile bit	FT0CK0S  		@ ((unsigned) & TC0M * 8) + 2;
	volatile bit	FT0_OV			@ ((unsigned) & TC0M * 8) + 1;
	volatile bit	FT0_OVS			@ ((unsigned) & TC0M * 8) + 1;
	volatile bit	FT0_OVW			@ ((unsigned) & TC0M * 8) + 0;
	

volatile unsigned char		PAM0		@ 0x0D;


volatile unsigned char		PAM1		@ 0x0E;


volatile unsigned char		PXPD		@ 0x0F;


volatile unsigned char		PBM0		@ 0x10;


volatile unsigned char		PBM1		@ 0x11;


volatile unsigned char		TC1C		@ 0x12;


volatile unsigned char		TC1M		@ 0x13;
	volatile bit	TC1TR			@ ((unsigned) & TC1M * 8) + 7;
	volatile bit	LVDS			@ ((unsigned) & TC1M * 8) + 6;
	volatile bit	TC1S0			@ ((unsigned) & TC1M * 8) + 4;
	volatile bit	TC1I1			@ ((unsigned) & TC1M * 8) + 3;
	volatile bit	TC1I0   		@ ((unsigned) & TC1M * 8) + 2;
	volatile bit	PWMOUT			@ ((unsigned) & TC1M * 8) + 0;
	
	volatile bit	FTC1TR			@ ((unsigned) & TC1M * 8) + 7;
	volatile bit	FLVDS			@ ((unsigned) & TC1M * 8) + 6;
	volatile bit	FTC1S0			@ ((unsigned) & TC1M * 8) + 4;
	volatile bit	FTC1I1			@ ((unsigned) & TC1M * 8) + 3;
	volatile bit	FTC1I0   		@ ((unsigned) & TC1M * 8) + 2;
	volatile bit	FPWMOUT			@ ((unsigned) & TC1M * 8) + 0;


volatile unsigned char		TC1R		@ 0x14;


volatile unsigned char		TC1D		@ 0x15;


volatile unsigned char		PXPD1		@ 0x16;


//------------------------------------------------------------
// end Special function register definitions
//------------------------------------------------------------



/*******************************************************
					位定义
********************************************************/
//#define	Set(x,y)	((x) |= (1 << (y)))				//位置1
//#define	Clr(x,y)	((x) &= ~ (1 << (y)))			//位清0

//#define	b0(x,y)		(((x) & (1 << (y))) == 0)		//位0判断 if(b0(x,y)) 判断是否为0
//#define	b1(x,y)		((x) & (1 << (y)))				//位1判断 if(b1(x,y)) 判断是否为1


/*
#ifndef _LIB_BUILD
volatile union {
    struct {
        unsigned	MULTS0              : 1;
        unsigned	MULTS1              : 1;
        unsigned	OPAMEN              : 1;
        unsigned	COMMS               : 1; 
        unsigned						: 4;
    };
} OPAMbits @ 0x0DB;
#endif
*/
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

/*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
变量定义 ：
bit				1	==布尔型位变量，0或1两种取值
char			8	==有符号或无符号字符变量，
unsigned char	8	==无符号字符变量
short			16	==有符号整型数
unsigned short	16	==无符号整型数
int				16	==有符号整型数
unsigned int	16	==无符号整型数
long			32	==有符号长整型
unsigned long	32	==无符号长整型
float			24	==浮点数
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
BANK数据寄存器定义的管理
如果没有特别说明，所定义的变量降被定义在Bank0;除了Bank0内的变量声明不需要特殊处理外，
定义在其它Bank内的变量前面必须加上相应的bank序号，例如
	bank1 unsigned char buffer[2]	;变量定位在bank0
	bank2 bit flag1,flag2	;变量定位在bank2(如果硬件有bank2)
	bank3 int U16_tmp0,U16_tmp1	;变量定位在bank3(如果硬件有bank3)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
其它变量修饰关键词:
extern - 外部变量声明；如果在一个C程序文件中要使用一些变量但其原型定义写在另外的文件中，
	那么在本文件中必须将这些变量声明成“extern ”外部类型。

volatile —易变型变量声明。
const  —  常数型变量声明。
persistent —  非初始化变量声明。
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

*/
#endif

