/******************** (C) COPYRIGHT 2005 STMicroelectronics ********************
* File Name          : 91x_map.h
* Author             : MCD Application Team
* Date First Issued  : 08/24/2005
* Description        : Peripherals registers definition and memory mapping.
********************************************************************************
* History:
* 08/24/2005 : Created for IAR
* 06/03/2006 : adapted for GNUARM (VC/Raisonance)
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS
* A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

/* Define to prevent recursive inclusion ------------------------------------ */
#ifndef _STR91x_H_
#define _STR91x_H_

/******************************************************************************/
/*                             useful macros                                  */
/******************************************************************************/

//use this to convert a pointer to an _unbuffered_ region
// into a pointer to the same thing in the corresponding _buffered_ region
#define BUFFERED_POINTER( ptr ) ( ( ptr ) & 0xEFFFFFFF )
//use this to access a variable referenced in an _unbuffered_ region
// using the corresponding _buffered_ address.
#define BUFFERED_VAR( var ) ( * ( BUFFERED_POINTER( & var ) ) )

//use this to convert a pointer to a _buffered_ region
// into a pointer to the same thing in the corresponding _unbuffered_ region
#define UNBUFFERED_POINTER( ptr ) ( ( ptr ) | 0x10000000 )
//use this to access a variable referenced in a _buffered_ region
// using the corresponding _unbuffered_ address.
#define UNBUFFERED_VAR( var ) ( * ( UNBUFFERED_POINTER( & var ) ) )

//Note: The default linker script places the variable references
// in _unbuferred_ regions.


/******************************************************************************/
/*                          IP registers structures                           */
/******************************************************************************/

/*------------------------------------ FMI -----------------------------------*/

typedef struct
{
  volatile unsigned long BBSR;        /* Boot Bank Size Register             */
  volatile unsigned long NBBSR;       /* Non-Boot Bank Size Register         */
  volatile unsigned long BBADR;       /* Boot Bank Base Address Register     */
  volatile unsigned long NBBADR;      /* Non-Boot Bank Base Address Register */
} FMI_TypeDef;
extern FMI_TypeDef _FMI;
#define FMI (&_FMI)

/*----------------------  Analog to Digital Convertor ------------------------*/

typedef struct
{
  volatile unsigned short CR;        /* Control Register         */
  volatile unsigned short EMPTY1;
  volatile unsigned short CCR;        /* Channel Configuration Register */
  volatile unsigned short EMPTY2;
  volatile unsigned short LRR;        /* Low Threshold Register       */
  volatile unsigned short EMPTY3;
  volatile unsigned short HTR;        /* High Threshold Register      */
  volatile unsigned short EMPTY4;
  volatile unsigned short CRR;        /* Compare Result Register        */
  volatile unsigned short EMPTY5;
  volatile unsigned short DR0;        /* Data Register for Channel 0    */
  volatile unsigned short EMPTY6;
  volatile unsigned short DR1;        /* Data Register for Channel 1    */
  volatile unsigned short EMPTY7;
  volatile unsigned short DR2;        /* Data Register for Channel 2    */
  volatile unsigned short EMPTY8;
  volatile unsigned short DR3;        /* Data Register for Channel 3    */
  volatile unsigned short EMPTY9;
  volatile unsigned short DR4;        /* Data Register for Channel 4    */
  volatile unsigned short EMPTY10;
  volatile unsigned short DR5;        /* Data Register for Channel 5    */
  volatile unsigned short EMPTY11;
  volatile unsigned short DR6;        /* Data Register for Channel 6    */
  volatile unsigned short EMPTY12;
  volatile unsigned short DR7;        /* Data Register for Channel 7    */
  volatile unsigned short EMPTY13;
  volatile unsigned short PRS;        /* Prescaler Value Register       */
  volatile unsigned short EMPTY14;
} ADC_TypeDef;
extern ADC_TypeDef _ADC;
#define ADC (&_ADC)

/*--------------------- AHB APB BRIDGE registers strcture --------------------*/

typedef struct
{
  volatile unsigned long BSR;        /* Bridge Status Register            */
  volatile unsigned long BCR;        /* Bridge Configuration Register     */
  volatile unsigned long PAER;       /* Peripheral Address Error register */
} AHBAPB_TypeDef;
extern AHBAPB_TypeDef _AHBAPB0;
#define AHBAPB0 (&_AHBAPB0)
extern AHBAPB_TypeDef _AHBAPB1;
#define AHBAPB1 (&_AHBAPB1)

/*--------------- Controller Area Network Interface Register -----------------*/

typedef struct
{
  volatile unsigned short CRR;			/* IFn Command request Register       */
  volatile unsigned short EMPTY1;
  volatile unsigned short CMR;			/* IFn Command Mask Register          */
  volatile unsigned short EMPTY2;
  volatile unsigned short M1R;			/* IFn Message Mask 1 Register        */
  volatile unsigned short EMPTY3;
  volatile unsigned short M2R;			/* IFn Message Mask 2 Register        */
  volatile unsigned short EMPTY4;
  volatile unsigned short A1R;			/* IFn Message Arbitration 1 Register */
  volatile unsigned short EMPTY5;
  volatile unsigned short A2R;			/* IFn Message Arbitration 2 Register */
  volatile unsigned short EMPTY6;
  volatile unsigned short MCR;			/* IFn Message Control Register       */
  volatile unsigned short EMPTY7;
  volatile unsigned short DA1R;		        /* IFn DATA A 1 Register              */
  volatile unsigned short EMPTY8;
  volatile unsigned short DA2R;		        /* IFn DATA A 2 Register              */
  volatile unsigned short EMPTY9;
  volatile unsigned short DB1R;		        /* IFn DATA B 1 Register              */
  volatile unsigned short EMPTY10;
  volatile unsigned short DB2R;		        /* IFn DATA B 2 Register              */
  volatile unsigned short EMPTY11[27];
} CAN_MsgObj_TypeDef;

typedef struct
{
  volatile unsigned short CR;		/* Control Register                */
  volatile unsigned short EMPTY1;
  volatile unsigned short SR;	        /* Status Register                 */
  volatile unsigned short EMPTY2;
  volatile unsigned short ERR;		/* Error counter Register          */
  volatile unsigned short EMPTY3;
  volatile unsigned short BTR;		/* Bit Timing Register             */
  volatile unsigned short EMPTY4;
  volatile unsigned short IDR;		/* Interrupt Identifier Register   */
  volatile unsigned short EMPTY5;
  volatile unsigned short TESTR;		/* Test Register                   */
  volatile unsigned short EMPTY6;
  volatile unsigned short BRPR;		/* BRP Extension Register          */
  volatile unsigned short EMPTY7[3];
  CAN_MsgObj_TypeDef sMsgObj[2];
  volatile unsigned short EMPTY8[16];
  volatile unsigned short TXR1R;		/* Transmission request 1 Register */
  volatile unsigned short EMPTY9;
  volatile unsigned short TXR2R;		/* Transmission Request 2 Register */
  volatile unsigned short EMPTY10[13];
  volatile unsigned short ND1R;		/* New Data 1 Register             */
  volatile unsigned short EMPTY11;
  volatile unsigned short ND2R;		/* New Data 2 Register             */
  volatile unsigned short EMPTY12[13];
  volatile unsigned short IP1R;		/* Interrupt Pending 1 Register    */
  volatile unsigned short EMPTY13;
  volatile unsigned short IP2R;		/* Interrupt Pending 2 Register    */
  volatile unsigned short EMPTY14[13];
  volatile unsigned short MV1R;		/* Message Valid 1 Register        */
  volatile unsigned short EMPTY15;
  volatile unsigned short MV2R;		/* Message VAlid 2 Register        */
  volatile unsigned short EMPTY16;
} CAN_TypeDef;
extern CAN_TypeDef _CAN;
#define CAN (&_CAN)

/*----------------------- System Control Unit---------------------------------*/


typedef struct
{
  volatile unsigned long CLKCNTR;    /* Clock Control Register                       */
  volatile unsigned long PLLCONF;    /* PLL Configuration Register                   */
  volatile unsigned long SYSSTATUS;  /* System Status Register                       */
  volatile unsigned long PWRMNG;     /* Power Management Register                    */
  volatile unsigned long ITCMSK;     /* Interrupt Mask Register                      */
  volatile unsigned long PCGRO;      /* Peripheral Clock Gating Register 0           */
  volatile unsigned long PCGR1;      /* Peripheral Clock Gating Register 1           */
  volatile unsigned long PRR0;       /* Peripheral Reset Register 0                  */
  volatile unsigned long PRR1;       /* Peripheral Software Reset Register 1         */
  volatile unsigned long MGR0;       /* Mask Gating Register 0                       */
  volatile unsigned long MGR1;       /* Mask Gating Register 1                       */
  volatile unsigned long PECGR0;     /* Peripheral Emulation Clock Gating Register 0 */
  volatile unsigned long PECGR1;     /* Peripheral Emulation Clock Gating Register 1 */
  volatile unsigned long SCR0;       /* System Configuration Register 0              */
  volatile unsigned long SCR1;       /* System Configuration Register 1              */
  volatile unsigned long SCR2;       /* System Configuration Register 2              */
  volatile unsigned long EMPTY1;
  volatile unsigned long GPIOOUT[8];   /* GPIO Output Registers                      */
  volatile unsigned long GPIOIN[8];    /* GPIO Input Registers                       */
  volatile unsigned long GPIOTYPE[10]; /* GPIO Type Registers                        */
  volatile unsigned long GPIOEMI;      /* GPIO EMI Selector Register                 */
  volatile unsigned long WKUPSEL;      /* Wake-Up Selection Register                 */
  volatile unsigned long EMPTY2[7];
  volatile unsigned long GPIOANA;      /* GPIO Analag mode                           */
} SCU_TypeDef;
extern SCU_TypeDef _SCU;
#define SCU (&_SCU)

/*------------------------- DMA Channelx Registers ---------------------------*/

typedef struct

{
  volatile unsigned long CHSADDR;      /* Channelx Source Address Register      */
  volatile unsigned long CHDADDR;      /* Channelx Destination Address Register */
  volatile unsigned long CHLLIR;       /* Channelx Lincked List Item Register   */
  volatile unsigned long CHCTR;        /* Channelx Contol Register              */
  volatile unsigned long CHCFGR;       /* Channelx Configuration Register       */

} DMA_Channel_TypeDef;


/* x can be ,0,1,2,3,4,5,6 or 7. There are eight Channels AHB BUS Master */

/*----------------------------- DMA Controller -------------------------------*/

typedef struct
{
  volatile unsigned long ISR;         /* Interrupt Status Register                    */
  volatile unsigned long ITCSR;       /* Interrupt Terminal Count Status Register     */
  volatile unsigned long ITCCR;       /* Interrupt Terminal Count Clear Register      */
  volatile unsigned long IESR;        /* Interrupt Error Status Register              */
  volatile unsigned long IECR;        /* Interrupt Error Clear Register               */
  volatile unsigned long RITCSR;      /* Raw Interrupt Terminal Count Status Register */
  volatile unsigned long REISR;       /* Raw Error Interrupt Status Register          */
  volatile unsigned long ECR;         /* Enabled Channel Register                     */
  volatile unsigned long SBRR;        /* Software Burst Request Register              */
  volatile unsigned long SSRR;        /* Software Single Request Register             */
  volatile unsigned long SLBRR;       /* Software Last Burst Request Register         */
  volatile unsigned long SLSRR;       /* Software Last Single Request Register        */
  volatile unsigned long CR;          /* Configuration Register                       */
  volatile unsigned long SR;          /* Syncronization Register                      */
  volatile unsigned long EMPTY1[50];
  DMA_Channel_TypeDef DMA_Channel0;  /* DMA Channel0 Registers      */
  DMA_Channel_TypeDef DMA_Channel1;  /* DMA Channel1 Registers      */
  DMA_Channel_TypeDef DMA_Channel2;  /* DMA Channel2 Registers      */
  DMA_Channel_TypeDef DMA_Channel3;  /* DMA Channel3 Registers      */
  DMA_Channel_TypeDef DMA_Channel4;  /* DMA Channel4 Registers      */
  DMA_Channel_TypeDef DMA_Channel5;  /* DMA Channel5 Registers      */
  DMA_Channel_TypeDef DMA_Channel6;  /* DMA Channel6 Registers      */
  DMA_Channel_TypeDef DMA_Channel7;  /* DMA Channel7 Registers      */
  volatile unsigned long EMPTY2[192];
  volatile unsigned long TCR;         /* Test Control Register                        */
  volatile unsigned long ITOR1;       /* Integration Test Output Register 1           */
  volatile unsigned long ITOR2;       /* Integration Test Output Register 2           */
  volatile unsigned long ITOR3;       /* Integration Test Output Register 3           */
} DMA_TypeDef;
extern DMA_TypeDef _DMA;
#define DMA (&_DMA)


/*--------------------------------- TIM Timer --------------------------------*/

typedef struct
{
  volatile unsigned short ICAR;        /* Input Capture A Register  */
  volatile unsigned short EMPTY1;
  volatile unsigned short ICBR;        /* Input Capture B Register  */
  volatile unsigned short EMPTY2;
  volatile unsigned short OCAR;        /* Output Compare A Register */
  volatile unsigned short EMPTY3;
  volatile unsigned short OCBR;        /* Output Compare B Register  */
  volatile unsigned short EMPTY4;
  volatile unsigned short CNTR;        /* Counter Register          */
  volatile unsigned short EMPTY5;
  volatile unsigned short CR1;         /* Control Register 1        */
  volatile unsigned short EMPTY6;
  volatile unsigned short CR2;         /* Control Register 2        */
  volatile unsigned short EMPTY7;
  volatile unsigned short SR;          /* Status Register           */
  volatile unsigned short EMPTY8;
} TIM_TypeDef;
extern TIM_TypeDef _TIM0;
#define TIM0 (&_TIM0)
extern TIM_TypeDef _TIM1;
#define TIM1 (&_TIM1)
extern TIM_TypeDef _TIM2;
#define TIM2 (&_TIM2)
extern TIM_TypeDef _TIM3;
#define TIM3 (&_TIM3)


/*---------------------------- EMI Bankx Registers ---------------------------*/

typedef struct
{
  volatile unsigned long BICCR;       /* Bankx   Idle Cycle Control Register                    */
  volatile unsigned long BRWSCR;      /* Bankx   Read Wait State Control Register               */
  volatile unsigned long BWWSCR;      /* Bankx   Write Wait State Control Register              */
  volatile unsigned long BOEADCR;     /* Bankx   Output Enable Assertion Delay Control Register */
  volatile unsigned long BWEADCR;     /* Bankx   Write Enable Assertion Delay Control Register  */
  volatile unsigned long BCR;         /* Bankx   Control Register                               */
  volatile unsigned long BSR;         /* Bankx   Status Register                                */
  volatile unsigned long BBRWDCR;     /* Bankx   Burst Read Wait Delay Control Register         */
} EMI_Bank_TypeDef;

/*------------------------- External Memory Interface ------------------------*/

typedef struct
{
  EMI_Bank_TypeDef EMI_Bank0;      /* EMI Bank0 Registers   */
  EMI_Bank_TypeDef EMI_Bank1;      /* EMI Bank1 Registers   */
  EMI_Bank_TypeDef EMI_Bank2;      /* EMI Bank2 Registers   */
  volatile unsigned long EMPTY1[32];
  EMI_Bank_TypeDef EMI_Bank7;      /* EMI Bank7 Registers   */
  volatile unsigned long EMPTY2[64];
  volatile unsigned long SSMCSR;                     /* SSMC Status Register  */
  volatile unsigned long SSMCCR;                     /* SSMC Control Register */
} EMI_TypeDef;
extern EMI_TypeDef _EMI;
#define EMI (&_EMI)

/*---------------------------- Ethernet Controller ---------------------------*/

typedef struct
{
  volatile unsigned long MCR;      /* MAC Control Register             */
  volatile unsigned long MAHR;     /* MAC Address High Register        */
  volatile unsigned long MALR;     /* MAC Address Low Register         */
  volatile unsigned long MCAHR;    /* Multicast Address High Register  */
  volatile unsigned long MCALR;    /* Multicast Address Low Register   */
  volatile unsigned long MIIR;     /* MII Address Register             */
  volatile unsigned long MIIDR;    /* MII Data Register                */
  volatile unsigned long MCFR;     /* MAC Control Frame Register       */
  volatile unsigned long VL1R;     /* VLAN1 Register                   */
  volatile unsigned long VL2R;     /* VLAN2 register                   */
  volatile unsigned long MTSR;     /* MAC Transmission Status Register */
  volatile unsigned long MRSR;     /* MAC Reception Status Register    */
} MAC_TypeDef;

typedef volatile unsigned long FIFO_TypeDef;

typedef struct
{
  volatile unsigned long DSCR;                /* DMA Status and Control Register         */
  volatile unsigned long DISER;               /* DMA Interrupt Sources Enable Register   */
  volatile unsigned long DISR;                /* DMA Interrupt Status Register           */
  volatile unsigned long CPR;                 /* Clock Phase Relation : HCLK, PCLK and MAC_CLK
                               phase relations                         */
  volatile unsigned long RxDSR;               /* Rx DMA start Register                   */
  volatile unsigned long RxDCR;               /* Rx DMA Control Register                 */
  volatile unsigned long RxDBAR;              /* Rx DMA Base Address Register            */
  volatile unsigned long RxDNDAR;             /* Rx DMA Next Descriptor Address Register */
  volatile unsigned long RxDCAR;              /* Rx DMA Current Address Register         */
  volatile unsigned long RxDCTR;              /* Rx DMA Current Transfer Count Register  */
  volatile unsigned long RxDFIFOTOR;          /* Rx DMA FIFO Time Out Register           */
  volatile unsigned long RxDFIFOSR;           /* Rx DMA FIFO Status Register             */
  volatile unsigned long TxDSR;               /* Tx DMA start Register                   */
  volatile unsigned long TxDCR;               /* Tx DMA Control Register                 */
  volatile unsigned long TxDBAR;              /* Tx DMA Base Address Register            */
  volatile unsigned long TxDNDAR;             /* Tx DMA Next Descriptor Address Register */
  volatile unsigned long TxDCAR;              /* Tx DMA Current Address Register         */
  volatile unsigned long TxDCTR;              /* Tx DMA Current Transfer Count Register  */
  volatile unsigned long TxDFIFOTOR;          /* Tx DMA FIFO Time Out Register           */
  volatile unsigned long TxDFIFOSR;           /* Tx DMA FIFO Status Register             */
  volatile unsigned long EMPTY1[44];
  FIFO_TypeDef RxFIFO[32];  /*  Rx FIFO 32 bit word #0 - #31           */
  volatile unsigned long EMPTY2[32];
  FIFO_TypeDef TxFIFO[32];  /*  Tx FIFO 32 bit word #0 - #31           */
} DMAC_TypeDef;

/*------------------------------------- GPIO ---------------------------------*/

typedef struct
{
  volatile unsigned long DATA[0x100]; /* Data Register (the offset in the table gives the mask) */
  volatile unsigned long DIR;         /* Data Direction Register          */
  volatile unsigned long EMPTY[5];
  volatile unsigned long SEL;         /* Interrupt Sence register         */
} GPIO_TypeDef;

//macros for writing the GPIO DATA registers...
#define GPIO_WRITEDATA_MASKED( gpioptr , val , mask ) ( ( gpioptr )->DATA )[ ( mask ) & 0xFF] = ( val ) & 0xFF 
#define GPIO_WRITEDATA( gpioptr , val ) GPIO_WRITEDATA_MASKED( gpioptr , val , 0xFF ) 

//macros for reading the GPIO DATA registers...
#define GPIO_READDATA_MASKED( gpioptr , mask ) ( ( ( gpioptr )->DATA )[ ( mask ) & 0xFF] ) 
#define GPIO_READDATA( gpioptr ) GPIO_READDATA_MASKED( gpioptr , 0xFF ) 

extern GPIO_TypeDef _GPIO0;
#define GPIO0 (&_GPIO0)
extern GPIO_TypeDef _GPIO1;
#define GPIO1 (&_GPIO1)
extern GPIO_TypeDef _GPIO2;
#define GPIO2 (&_GPIO2)
extern GPIO_TypeDef _GPIO3;
#define GPIO3 (&_GPIO3)
extern GPIO_TypeDef _GPIO4;
#define GPIO4 (&_GPIO4)
extern GPIO_TypeDef _GPIO5;
#define GPIO5 (&_GPIO5)
extern GPIO_TypeDef _GPIO6;
#define GPIO6 (&_GPIO6)
extern GPIO_TypeDef _GPIO7;
#define GPIO7 (&_GPIO7)
extern GPIO_TypeDef _GPIO8;
#define GPIO8 (&_GPIO8)
extern GPIO_TypeDef _GPIO9;
#define GPIO9 (&_GPIO9)

/*-------------------------------- I2C interface -----------------------------*/

typedef struct
{
  volatile unsigned char  CR;                 /* Control Register                */
  volatile unsigned char  EMPTY1[3];
  volatile unsigned char  SR1;                /* Status Register 1               */
  volatile unsigned char  EMPTY2[3];
  volatile unsigned char  SR2;                /* Status Register 2               */
  volatile unsigned char  EMPTY3[3];
  volatile unsigned char  CCR;                /* Clock Control Register          */
  volatile unsigned char  EMPTY4[3];
  volatile unsigned char  OAR1;               /* Own Address Register 1          */
  volatile unsigned char  EMPTY5[3];
  volatile unsigned char  OAR2;               /* Own Address Register 2          */
  volatile unsigned char  EMPTY6[3];
  volatile unsigned char  DR;                 /* Data Register                   */
  volatile unsigned char  EMPTY7[3];
  volatile unsigned char  ECCR;               /* Extended Clock Control Register */
  volatile unsigned char  EMPTY8[3];
} I2C_TypeDef;
extern I2C_TypeDef _I2C0;
#define I2C0 (&_I2C0)
extern I2C_TypeDef _I2C1;
#define I2C1 (&_I2C1)

/*------------------------------------- VIC ----------------------------------*/

typedef struct
{
  volatile unsigned long ISR;                /* IRQ Status Register               */
  volatile unsigned long FSR;                /* FIQ Status Register               */
  volatile unsigned long RINTSR;             /* Raw Interrupt Status Register     */
  volatile unsigned long INTSR;              /* Interrupt Select Register         */
  volatile unsigned long INTER;              /* Interrupt Enable Register         */
  volatile unsigned long INTECR;             /* Interrupt Enable Clear Register   */
  volatile unsigned long SWINTR;             /* Software Interrupt Register       */
  volatile unsigned long SWINTCR;            /* Software Interrupt clear Register */
  volatile unsigned long PER;                /* Protection Enable Register        */
  volatile unsigned long EMPTY1[3];
  volatile unsigned long VAR;                /* Vector Address Register           */
  volatile unsigned long DVAR;               /* Default Vector Address Register   */
  volatile unsigned long EMPTY2[50];
  volatile unsigned long VAiR[16];           /* Vector Address 0-15 Register      */
  volatile unsigned long EMPTY3[48];
  volatile unsigned long VCiR[16];           /* Vector Control 0-15 Register      */
  volatile unsigned long EMPTY4[48];
  volatile unsigned long TCR;                /* Test Control Register             */
  volatile unsigned long TIR1;               /* Test Input Register 1             */
  volatile unsigned long TIR2;               /* Test Input Register 2             */
  volatile unsigned long TOR1;               /* Test Output Register 1            */
  volatile unsigned long TOR2;               /* Test Output Register 2            */
} VIC_TypeDef;
extern VIC_TypeDef _VIC0;
#define VIC0 (&_VIC0)
extern VIC_TypeDef _VIC1;
#define VIC1 (&_VIC1)

/*-------------------------------- Motor Control -----------------------------*/

typedef struct
{
  volatile unsigned short TCAPR;         /* Tacho Capture Register           */
  volatile unsigned short EMPTY1;
  volatile unsigned short TCMPR;         /* Tacho Compare Register           */
  volatile unsigned short EMPTY2;
  volatile unsigned short IPR;           /* Input Pending Register           */
  volatile unsigned short EMPTY3;
  volatile unsigned short TPR;           /* Tacho Prescaler Register         */
  volatile unsigned short EMPTY4;
  volatile unsigned short PWMCPR;        /* PWM Counter Prescaler Register   */
  volatile unsigned short EMPTY5;
  volatile unsigned short RCR;           /* Repetition Counter Register      */
  volatile unsigned short EMPTY6;
  volatile unsigned short CMPPWPR;       /* Compare Phase W Preload Register */
  volatile unsigned short EMPTY7;
  volatile unsigned short CMPPVPR;       /* Compare Phase V Preload Register */
  volatile unsigned short EMPTY8;
  volatile unsigned short CMPPUPR;       /* Compare Phase U Preload Register */
  volatile unsigned short EMPTY9;
  volatile unsigned short CMP0PR;        /* Compare 0 Preload Register       */
  volatile unsigned short EMPTY10;
  volatile unsigned short PCR0;          /* Peripheral Control Register 0    */
  volatile unsigned short EMPTY11;
  volatile unsigned short PCR1;          /* Peripheral Control Register 1    */
  volatile unsigned short EMPTY12;
  volatile unsigned short PCR2;          /* Peripheral Control Register 2    */
  volatile unsigned short EMPTY13;
  volatile unsigned short PSR;           /* Polarity Selection Register      */
  volatile unsigned short EMPTY14;
  volatile unsigned short OPR;           /* Output Peripheral Register       */
  volatile unsigned short EMPTY15;
  volatile unsigned short IMR;           /* Interrupt Mask Register          */
  volatile unsigned short EMPTY16;
  volatile unsigned short DTGR;          /* Dead Time Generator Register     */
  volatile unsigned short EMPTY17;
  volatile unsigned short ESCR;          /* Emergency Stop Clear Register    */
  volatile unsigned short EMPTY18;
}MC_TypeDef;
extern MC_TypeDef _MC;
#define MC (&_MC)

/*------------------------------------- RTC ----------------------------------*/

typedef struct
{
  volatile unsigned long TR;         /* Time Register       */
  volatile unsigned long DR;         /* Date Register       */
  volatile unsigned long AR;         /* Alarm time Register */
  volatile unsigned long CR;         /* Control Register    */
  volatile unsigned long SR;         /* Status Register     */
  volatile unsigned long MR;         /* Millisec Register   */
}RTC_TypeDef;
extern RTC_TypeDef _RTC;
#define RTC (&_RTC)

/*------------------------------------- SPI ----------------------------------*/

typedef struct
{
  volatile unsigned short CR0;        /* Control Register 1                   */
  volatile unsigned short EMPTY1;
  volatile unsigned short CR1;        /* Control Register 2                   */
  volatile unsigned short EMPTY2;
  volatile unsigned short DR;         /* Data Register                        */
  volatile unsigned short EMPTY3;
  volatile unsigned short SR;         /* Status Register                      */
  volatile unsigned short EMPTY4;
  volatile unsigned short CPSR;       /* Clock Prescale Register              */
  volatile unsigned short EMPTY5;
  volatile unsigned short IMSC;       /* Interrupt Mask Set or Clear Register */
  volatile unsigned short EMPTY6;
  volatile unsigned short RIS;        /* Raw Interrupt Status Register        */
  volatile unsigned short EMPTY7;
  volatile unsigned short MIS;        /* Masked Interrupt Status Register     */
  volatile unsigned short EMPTY8;
  volatile unsigned short ICR;        /* Interrupt Clear Register             */
  volatile unsigned short EMPTY9;
  volatile unsigned short DMACR;      /* DMA Control Register                 */
  volatile unsigned short EMPTY10;
}SPI_TypeDef;
extern SPI_TypeDef _SPI0;
#define SPI0 (&_SPI0)
extern SPI_TypeDef _SPI1;
#define SPI1 (&_SPI1)

/*------------------------------------ UART ----------------------------------*/

typedef struct
{
  volatile unsigned short DR;        /*00: Data Register                         */
  volatile unsigned short EMPTY1;
  volatile unsigned short RSR_ECR;   /*04: Receive Status Register (read)/
                     Error Clear Register (write)          */
  volatile unsigned short EMPTY2[9];
  volatile unsigned short FR;        /*18: Flag Register                         */
  volatile unsigned short EMPTY3[3];
  volatile unsigned short ILPR;      /*20: IrDA Low-Power counter Register       */
  volatile unsigned short EMPTY4;
  volatile unsigned short IBRD;      /*24: Integer Baud Rate Divisor Register    */
  volatile unsigned short EMPTY5;
  volatile unsigned short FBRD;      /*28: Fractional Baud Rate Divisor Register */
  volatile unsigned short EMPTY6;
  volatile unsigned short LCR;       /*2C: Line Control Register,        */
  volatile unsigned short EMPTY7;
  volatile unsigned short CR;        /*30: Control Register                      */
  volatile unsigned short EMPTY8;
  volatile unsigned short IFLS;      /*34: Interrupt FIFO Level Select Register  */
  volatile unsigned short EMPTY9;
  volatile unsigned short IMSC;      /*38: Interrupt Mask Set/Clear Register     */
  volatile unsigned short EMPTY10;
  volatile unsigned short RIS;       /*3C: Raw Interrupt Status Register         */
  volatile unsigned short EMPTY11;
  volatile unsigned short MIS;       /*40: Masked Interrupt Status Register      */
  volatile unsigned short EMPTY12;
  volatile unsigned short ICR;       /*44: Interrupt Clear Register              */
  volatile unsigned short EMPTY13;
  volatile unsigned short DMACR;     /*48: DMA Control Register                  */
  volatile unsigned short EMPTY14;
}UART_TypeDef;
extern UART_TypeDef _UART0;
#define UART0 (&_UART0)
extern UART_TypeDef _UART1;
#define UART1 (&_UART1)
extern UART_TypeDef _UART2;
#define UART2 (&_UART2)

/*------------------------------- Wake-up System -----------------------------*/

typedef struct
{
  volatile unsigned long  CTRL;   /* Control Register            */
  volatile unsigned long  MR;     /* Mask Register               */
  volatile unsigned long  TR;     /* Trigger Register            */
  volatile unsigned long  PR;     /* Pending Register            */
  volatile unsigned long  INTR;   /* Software Interrupt Register */
} WIU_TypeDef;
extern WIU_TypeDef _WIU;
#define WIU (&_WIU)

/*------------------------------- WatchDog Timer -----------------------------*/

typedef struct
{
  volatile unsigned short CR;        /* Control Register        */
  volatile unsigned short EMPTY1;
  volatile unsigned short PR;        /* Presclar Register       */
  volatile unsigned short EMPTY2;
  volatile unsigned short VR;        /* Pre-load Value Register */
  volatile unsigned short EMPTY3;
  volatile unsigned short CNT;       /* Counter Register        */
  volatile unsigned short EMPTY4;
  volatile unsigned short SR;        /* Status Register         */
  volatile unsigned short EMPTY5;
  volatile unsigned short MR;        /* Mask Register           */
  volatile unsigned short EMPTY6;
  volatile unsigned short KR;        /* Key Register            */
  volatile unsigned short EMPTY7;
} WDG_TypeDef;
extern WDG_TypeDef _WDG;
#define WDG (&_WDG)


#endif  /* _STR91x_H_*/

/******************* (C) COPYRIGHT 2005 STMicroelectronics *****END OF FILE****/

