
#ifndef	_HTC_H_
#warning Header file mtv230m.h included directly. Use #include <htc.h> instead.
#endif

/* This is a header file for the MYSON Microcontroller
	MTV230M
*/

#ifndef __MTV230M_H
#define __MTV230M_H


typedef struct {
	unsigned B7:1; //This is the most signifigant bit
	unsigned B6:1;
	unsigned B5:1;
	unsigned B4:1;
	unsigned B3:1;
	unsigned B2:1;
	unsigned B1:1;
	unsigned B0:1;
}	SFR_BITS;

// 8051 Special Function Registers
static volatile unsigned char	P0	@ 0x80;
static volatile unsigned char	SP	@ 0x81;
static volatile unsigned char	DPL	@ 0x82;
static volatile unsigned char	DPH	@ 0x83;
// 16 bit definition
static 		unsigned char	PCON	@ 0x87;
static volatile	unsigned char	TCON	@ 0x88;
static 		unsigned char	TMOD	@ 0x89;
static volatile unsigned char	TL0	@ 0x8A;
static volatile unsigned char	TL1	@ 0x8B;
static volatile unsigned char	TH0	@ 0x8C;
static volatile unsigned char	TH1	@ 0x8D;
static volatile unsigned char	P1	@ 0x90;
static 		unsigned char	SCON	@ 0x98;
static volatile unsigned char	SBUF	@ 0x99;
static volatile unsigned char	P2	@ 0xA0;
static 		unsigned char	IE	@ 0xA8;
static volatile unsigned char	P3	@ 0xB0;
static 		unsigned char	IP	@ 0xB8;
static volatile unsigned char	PSW	@ 0xD0;
static volatile unsigned char	ACC	@ 0xE0;
static volatile unsigned char	B	@ 0xF0;

// External Special Function Registers (XFRs)
static volatile unsigned char IICCTR	@ 0xF00;
static volatile unsigned char IICSTUSL	@ 0xF01;
static volatile unsigned char IICSTUSH	@ 0xF02;
static volatile unsigned char INTFLG0	@ 0xF03;
static		unsigned char INTEN0	@ 0xF04;
static volatile unsigned char MBUF	@ 0xF05;
static volatile unsigned char RCABUF	@ 0xF06;
// alternate function
static volatile unsigned char TXABUF	@ 0xF06;
static		unsigned char SLVAADR	@ 0xF07;
static volatile unsigned char RCBBUF	@ 0xF08;
// alternate function
static volatile unsigned char TXBBUF	@ 0xF08;
static		unsigned char SLVBADR	@ 0xF09;
static		unsigned char ISPSLV	@ 0xF0B;
static		unsigned char ISPEN	@ 0xF0C;
static volatile unsigned char ADC	@ 0xF10;
static		unsigned char WDT	@ 0xF18;
static		unsigned char DA0	@ 0xF20;
static		unsigned char DA1	@ 0xF21;
static		unsigned char DA2	@ 0xF22;
static		unsigned char DA3	@ 0xF23;
static		unsigned char PORT60	@ 0xF28;
static		unsigned char PORT61	@ 0xF29;
static		unsigned char PORT62	@ 0xF2A;
static		unsigned char PADMOD0	@ 0xF2B;
static		unsigned char PADMOD1	@ 0xF2C;
static		unsigned char PADMOD2	@ 0xF2D;
static		unsigned char PADMOD3	@ 0xF2E;
static		unsigned char OPTION	@ 0xF2F;
static volatile unsigned char PORT40	@ 0xF30;
static volatile unsigned char PORT41	@ 0xF31;
static volatile unsigned char PORT42	@ 0xF32;
static volatile unsigned char PORT43	@ 0xF33;
static volatile unsigned char PORT44	@ 0xF34;
static volatile unsigned char PORT45	@ 0xF35;
static volatile unsigned char PORT46	@ 0xF36;
static volatile unsigned char PORT47	@ 0xF37;
static volatile unsigned char PORT50	@ 0xF38;
static volatile unsigned char PORT51	@ 0xF39;
static volatile unsigned char PORT52	@ 0xF3A;
static volatile unsigned char PORT53	@ 0xF3B;
static volatile unsigned char PORT54	@ 0xF3C;
static volatile unsigned char PORT55	@ 0xF3D;
static volatile unsigned char PORT56	@ 0xF3E;
static volatile unsigned char PORT57	@ 0xF3F;
static volatile unsigned char HVCTR0	@ 0xF40;
// alternate function
static volatile unsigned char HVSTUS	@ 0xF40;
static volatile unsigned char HCNTH	@ 0xF41;
static volatile unsigned char HCNTL	@ 0xF42;
static volatile unsigned char HVCTR3	@ 0xF43;
// alternate function
static volatile unsigned char VCNTH	@ 0xF43;
static volatile unsigned char VCNTL	@ 0xF44;
static volatile unsigned char INTFLG1	@ 0xF48;
static		unsigned char INTEN1	@ 0xF49;
static		unsigned char OSDRA	@ 0xFA0;
static		unsigned char OSDCA	@ 0xFA1;
static		unsigned char OSDDT0	@ 0xFA2;
static		unsigned char OSDDT1	@ 0xFA3;
static		unsigned char W1ROW	@ 0xFC0;
static		unsigned char W1COLL	@ 0xFC1;
static		unsigned char W1COLH	@ 0xFC2;
static		unsigned char W2ROW	@ 0xFC3;
static		unsigned char W2COLL	@ 0xFC4;
static		unsigned char W2COLH	@ 0xFC5;
static		unsigned char W3ROW	@ 0xFC6;
static		unsigned char W3COLL	@ 0xFC7;
static		unsigned char W3COLH	@ 0xFC8;
static		unsigned char W4ROW	@ 0xFC9;
static		unsigned char W4COLL	@ 0xFCA;
static		unsigned char W4COLH	@ 0xFCB;
static		unsigned char VERTD	@ 0xFCC;
static		unsigned char HORD	@ 0xFCD;
static		unsigned char CH	@ 0xFCE;
static		unsigned char RSPACE	@ 0xFD0;
static		unsigned char OSDCONL	@ 0xFD1;
static		unsigned char OSDCONH	@ 0xFD2;
static		unsigned char CHSC	@ 0xFD3;
static		unsigned char FSSTP	@ 0xFD4;
static		unsigned char WINSW	@ 0xFD5;
static		unsigned char WINSH	@ 0xFD6;
static		unsigned char WINSC0	@ 0xFD7;
static		unsigned char WINSC1	@ 0xFD8;
static		unsigned char XDEL	@ 0xFD9;

// 8051 Special Function Registers
static volatile SFR_BITS	P0_BITS		@ 0x80;
static 		SFR_BITS	PCON_BITS	@ 0x87;
static volatile	SFR_BITS	TCON_BITS	@ 0x88;
static 		SFR_BITS	TMOD_BITS	@ 0x89;
static volatile SFR_BITS	P1_BITS		@ 0x90;
static 		SFR_BITS	SCON_BITS	@ 0x98;
static volatile SFR_BITS	P2_BITS		@ 0xA0;
static 		SFR_BITS	IE_BITS		@ 0xA8;
static volatile SFR_BITS	P3_BITS		@ 0xB0;
static 		SFR_BITS	IP_BITS		@ 0xB8;
static volatile SFR_BITS	PSW_BITS	@ 0xD0;
static volatile SFR_BITS	ACC_BITS	@ 0xE0;
static volatile SFR_BITS	B_BITS		@ 0xF0;

// External Special Function Registers (XFRs)
static volatile SFR_BITS IICCTR_BITS		@ 0xF00;
static volatile SFR_BITS IICSTUSL_BITS		@ 0xF01;
static volatile SFR_BITS IICSTUSH_BITS		@ 0xF02;
static volatile SFR_BITS INTFLG0_BITS		@ 0xF03;
static		SFR_BITS INTEN0_BITS		@ 0xF04;
static		SFR_BITS SLVAADR_BITS		@ 0xF07;
static		SFR_BITS SLVBADR_BITS		@ 0xF09;
static		SFR_BITS ISPSLV_BITS		@ 0xF0B;
static		SFR_BITS ISPEN_BITS		@ 0xF0C;
static volatile SFR_BITS ADC_BITS		@ 0xF10;
static		SFR_BITS WDT_BITS		@ 0xF18;
static		SFR_BITS PORT60_BITS		@ 0xF28;
static		SFR_BITS PORT61_BITS		@ 0xF29;
static		SFR_BITS PORT62_BITS		@ 0xF2A;
static		SFR_BITS PADMOD0_BITS		@ 0xF2B;
static		SFR_BITS PADMOD1_BITS		@ 0xF2C;
static		SFR_BITS PADMOD2_BITS		@ 0xF2D;
static		SFR_BITS PADMOD3_BITS		@ 0xF2E;
static		SFR_BITS OPTION_BITS		@ 0xF2F;
static volatile SFR_BITS PORT40_BITS		@ 0xF30;
static volatile SFR_BITS PORT41_BITS		@ 0xF31;
static volatile SFR_BITS PORT42_BITS		@ 0xF32;
static volatile SFR_BITS PORT43_BITS		@ 0xF33;
static volatile SFR_BITS PORT44_BITS		@ 0xF34;
static volatile SFR_BITS PORT45_BITS		@ 0xF35;
static volatile SFR_BITS PORT46_BITS		@ 0xF36;
static volatile SFR_BITS PORT47_BITS		@ 0xF37;
static volatile SFR_BITS PORT50_BITS		@ 0xF38;
static volatile SFR_BITS PORT51_BITS		@ 0xF39;
static volatile SFR_BITS PORT52_BITS		@ 0xF3A;
static volatile SFR_BITS PORT53_BITS		@ 0xF3B;
static volatile SFR_BITS PORT54_BITS		@ 0xF3C;
static volatile SFR_BITS PORT55_BITS		@ 0xF3D;
static volatile SFR_BITS PORT56_BITS		@ 0xF3E;
static volatile SFR_BITS PORT57_BITS		@ 0xF3F;
static volatile SFR_BITS HVCTR0_BITS		@ 0xF40;
// alternate function
static volatile SFR_BITS HVSTUS_BITS		@ 0xF40;
static volatile SFR_BITS HCNTH_BITS		@ 0xF41;
static volatile SFR_BITS HCNTL_BITS		@ 0xF42;
static volatile SFR_BITS HVCTR3_BITS		@ 0xF43;
// alternate function
static volatile SFR_BITS VCNTH_BITS		@ 0xF43;
static volatile SFR_BITS VCNTL_BITS		@ 0xF44;
static volatile SFR_BITS INTFLG1_BITS		@ 0xF48;
static		SFR_BITS INTEN1_BITS		@ 0xF49;
static		SFR_BITS OSDRA_BITS		@ 0xFA0;
static		SFR_BITS OSDCA_BITS		@ 0xFA1;
static		SFR_BITS OSDDT0_BITS		@ 0xFA2;
static		SFR_BITS OSDDT1_BITS		@ 0xFA3;
static		SFR_BITS W1ROW_BITS		@ 0xFC0;
static		SFR_BITS W1COLL_BITS		@ 0xFC1;
static		SFR_BITS W1COLH_BITS		@ 0xFC2;
static		SFR_BITS W2ROW_BITS		@ 0xFC3;
static		SFR_BITS W2COLL_BITS		@ 0xFC4;
static		SFR_BITS W2COLH_BITS		@ 0xFC5;
static		SFR_BITS W3ROW_BITS		@ 0xFC6;
static		SFR_BITS W3COLL_BITS		@ 0xFC7;
static		SFR_BITS W3COLH_BITS		@ 0xFC8;
static		SFR_BITS W4ROW_BITS		@ 0xFC9;
static		SFR_BITS W4COLL_BITS		@ 0xFCA;
static		SFR_BITS W4COLH_BITS		@ 0xFCB;
static		SFR_BITS OSDCONL_BITS		@ 0xFD1;
static		SFR_BITS OSDCONH_BITS		@ 0xFD2;
static		SFR_BITS CHSC_BITS		@ 0xFD3;
static		SFR_BITS FSSTP_BITS		@ 0xFD4;
static		SFR_BITS WINSW_BITS		@ 0xFD5;
static		SFR_BITS WINSH_BITS		@ 0xFD6;
static		SFR_BITS WINSC0_BITS		@ 0xFD7;
static		SFR_BITS WINSC1_BITS		@ 0xFD8;
static		SFR_BITS XDEL_BITS		@ 0xFD9;

//Bit Addressable Locations
//Port 0 P0
static volatile bit	P00	@ 0x80;
static volatile bit	P01	@ 0x81;
static volatile bit	P02	@ 0x82;
static volatile bit	P03	@ 0x83;
static volatile bit	P04	@ 0x84;
static volatile bit	P05	@ 0x85;
static volatile bit	P06	@ 0x86;
static volatile bit	P07	@ 0x87;

//Timer Control TCON
static 		bit	IT0	@ 0x88;
static volatile bit	IE0	@ 0x89;
static 		bit	IT1	@ 0x8A;
static volatile bit	IE1	@ 0x8B;
static 		bit	TR0	@ 0x8C;
static volatile bit	TF0	@ 0x8D;
static 		bit	TR1	@ 0x8E;
static volatile bit	TF1	@ 0x8F;

//Port 1 P1
static volatile bit	P10	@ 0x90;
static volatile bit	P11	@ 0x91;
static volatile bit	P12	@ 0x92;
static volatile bit	P13	@ 0x93;
static volatile bit	P14	@ 0x94;
static volatile bit	P15	@ 0x95;
static volatile bit	P16	@ 0x96;
static volatile bit	P17	@ 0x97;

//Serial Control SCON
static volatile bit	RI	@ 0x98;
static volatile bit	TI	@ 0x99;
static volatile bit	RB8	@ 0x9A;
static		bit	TB8	@ 0x9B;
static		bit	REN	@ 0x9C;
static		bit	SM2	@ 0x9D;
static		bit	SM1	@ 0x9E;
static		bit	SM0	@ 0x9F;

//Port 2 P2
static volatile bit	P20	@ 0xA0;
static volatile bit	P21	@ 0xA1;
static volatile bit	P22	@ 0xA2;
static volatile bit	P23	@ 0xA3;
static volatile bit	P24	@ 0xA4;
static volatile bit	P25	@ 0xA5;
static volatile bit	P26	@ 0xA6;
static volatile bit	P27	@ 0xA7;

//Interrupt Enable IE
static		bit	EX0	@ 0xA8;
static		bit	ET0	@ 0xA9;
static		bit	EX1	@ 0xAA;
static		bit	ET1	@ 0xAB;
static 		bit	ES	@ 0xAC;
static 		bit	EA	@ 0xAF;

//Port 3 P3
static volatile bit	P30	@ 0xB0;
static volatile bit	P31	@ 0xB1;
static volatile bit	P32	@ 0xB2;
static volatile bit	P33	@ 0xB3;
static volatile bit	P34	@ 0xB4;
static volatile bit	P35	@ 0xB5;
static volatile bit	P36	@ 0xB6;
static volatile bit	P37	@ 0xB7;
// Alternate Functions
static volatile bit	RXD	@ 0xB0;
static volatile bit	TXD	@ 0xB1;
static volatile bit	INT0	@ 0xB2;
static volatile bit	INT1	@ 0xB3;
static volatile bit	T0	@ 0xB4;
static volatile bit	T1	@ 0xB5;
static volatile bit	WR	@ 0xB6;
static volatile bit	RD	@ 0xB7;

//Interrupt Priority
static 		bit	PX0	@ 0xB8;
static 		bit	PT0	@ 0xB9;
static 		bit	PX1	@ 0xBA;
static 		bit	PT1	@ 0xBB;
static 		bit	PS	@ 0xBC;

//Program Status Word PSW
static volatile bit	P	@ 0xD0;
static volatile bit	OV	@ 0xD2;
static 		bit	RS0	@ 0xD3;
static 		bit	RS1	@ 0xD4;
static volatile bit	F0	@ 0xD5;
static volatile bit	AC	@ 0xD6;
static volatile bit	CY	@ 0xD7;

//Accumulator ACC
static volatile bit	ACC0	@ 0xE0;
static volatile bit	ACC1	@ 0xE1;
static volatile bit	ACC2	@ 0xE2;
static volatile bit	ACC3	@ 0xE3;
static volatile bit	ACC4	@ 0xE4;
static volatile bit	ACC5	@ 0xE5;
static volatile bit	ACC6	@ 0xE6;
static volatile bit	ACC7	@ 0xE7;

//B register
static volatile bit	B0	@ 0xF0;
static volatile bit	B1	@ 0xF1;
static volatile bit	B2	@ 0xF2;
static volatile bit	B3	@ 0xF3;
static volatile bit	B4	@ 0xF4;
static volatile bit	B5	@ 0xF5;
static volatile bit	B6	@ 0xF6;
static volatile bit	B7	@ 0xF7;


//Interrupt Vectors
#define	RESET	0
#define	EXTINT0	0x03
#define TIMER0	0x0B
#define	EXTINT1	0x13
#define	TIMER1	0x1B
#define	SERIAL	0x23

#endif
