/************************************************************************/
/* CQBBEL GNU CC Common Control Software / (C) Toshio MURAI 2011, 2012	*/
/*      This is Free Software;   You can redistribute this software     */
/*      and/or modify it under the terms of the GNU General Public      */
/*      License version 3, or (at your option) any later version.       */
/************************************************************************/

struct str_inter {
	volatile unsigned char	EIRR;
	volatile unsigned char	ENIR;
	volatile unsigned short	ELVR;
};
#define	INTER ((struct str_inter*)0x0040)

struct str_pfr {
	volatile unsigned char	PFR_0;
	volatile unsigned char	PFR_1;
	volatile unsigned char	PFR_2;
	volatile unsigned char	PFR_3;
};
#define	PFR	((struct str_pfr*)0x0410)

struct str_port {
	volatile unsigned char	PORT0;
	volatile unsigned char	PORT1;
	volatile unsigned char	PORT2;
	volatile unsigned char	PORT3;
	volatile unsigned char	PORT4;
	volatile unsigned char	PORT5;
	volatile unsigned char	PORT6;
	volatile unsigned char	PORT7;
};
#define	PDR	((struct str_port*) 0x0010)	//Port Data Register
#define	DDR	((struct str_port*) 0x0400)	//Data Direction Register
	
#define	ICR ((char*)0x0440)

struct str_ppg {
	volatile unsigned short	PTMR;	//0x0120
	volatile unsigned short	PCSR;	//0x0122
	volatile unsigned short	PDUT;	//0x0124
	volatile unsigned short	PCN;	//Control & Status
};
#define	PPG0	((struct str_ppg*)0x120)
#define	PPG1	((struct str_ppg*)0x128)
#define	PPG2	((struct str_ppg*)0x130)
#define	PPG3	((struct str_ppg*)0x138)


//	PPG0->PCN=0xC02C;	// 1/1
#define	CNTE	0x8000			//1	15	Enalbe
#define	STGR	0x4000			//1	14	Software Triger
#define	MDSE	0x2000			//0	13	0:PWM/1:OneShot
#define	RTRG	0x1000			//	12	Retrigger?
#define	CKS		0x0C00			//2	10-11	0 1(1/4) 2(1/16) 3(1/16)
#define	PGMS	0x0200			//	 9	Mask PGM Output
#define	EGS		0x00C0			//	6-7	Triger Edge 
#define	IREN	0x0020			//1	 5	Interrupt Enable
#define	IRQF	0x0010			//0	 4	Interrupt Flag
#define	IRS		0x000C			//3	2-3	Interrupt Reason
#define	OSEL	0x0001			//	 0	Outp put 


struct str_adc {
	volatile unsigned short	ADCT;	//0x0020
	volatile unsigned short	ADCH;
	volatile unsigned short	ADAT0;
	volatile unsigned short	ADAT1;
	
	volatile unsigned short	ADAT9;	//0x0038
};

#define	ADC	((struct str_adc*)0x0020)
