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

/*header file for the ATMEL microcontroller
	AT89S4D12
 */

#ifndef __A89S4D12_H

#define __A89S4D12_H
	
typedef struct {
	unsigned B7:1;	/* this is the most significant bit */
	unsigned B6:1;
	unsigned B5:1;
	unsigned B4:1;
	unsigned B3:1;
	unsigned B2:1;
	unsigned B1:1;
	unsigned B0:1;
}	SFR_BITS;

static volatile unsigned char		DP0L	@ 0x82;
static volatile unsigned char		DP0H	@ 0x83;
// 16 bit definition
// Alternate definition
static volatile unsigned char		DP1L	@ 0x84;
static volatile unsigned char		DP1H	@ 0x85;
// 16 bit definition
static volatile unsigned char		SPDR	@ 0x86; //SPI Data Register
static 		unsigned char		PCON	@ 0x87;
static volatile unsigned char		P1	@ 0x90;
static volatile unsigned char		MCON	@ 0x96;
static volatile	unsigned char		SPSR	@ 0xAA;
static volatile unsigned char		PSW	@ 0xD0;
static		unsigned char		SPCR	@ 0xD5;
static volatile unsigned char		ACC	@ 0xE0;
static volatile unsigned char		B	@ 0xF0;

static 		SFR_BITS	PCON_BITS	@ 0x87;
static volatile SFR_BITS	MCON_BITS	@ 0x96;
static volatile SFR_BITS	SPSR_BITS	@ 0xAA;
static volatile SFR_BITS	PSW_BITS	@ 0xD0;
static volatile SFR_BITS	SPCR_BITS	@ 0xD5;
static volatile SFR_BITS	ACC_BITS	@ 0xE0;
static volatile SFR_BITS	B_BITS		@ 0xF0;

/*bit addressable locations*/
//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;
// Alternate Functions
static volatile bit	SDO	@ 0x90; //Serial Data Output pin
static volatile bit	SDI	@ 0x91; //Serial Data Input pin
static volatile bit	SCK	@ 0x93; //Clock Input for SPI

//Program Status Word PSW
static volatile bit	P	@ 0xD0;
static volatile bit	F1	@ 0xD1;
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

#endif
