www.pudn.com > LPC1768_SD_Test.rar > spi_lpc17xx.i, change:2010-06-05,size:56403b


#line 1 "SPI_LPC17xx.c" 
 
 
 
 
 
 
 
 
 
  
 
#line 1 "C:\\Keil\\ARM\\INC\\NXP\\LPC17xx.H" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
  
 
typedef enum IRQn 
{ 
  
  NonMaskableInt_IRQn           = -14,        
  MemoryManagement_IRQn         = -12,        
  BusFault_IRQn                 = -11,        
  UsageFault_IRQn               = -10,        
  SVCall_IRQn                   = -5,         
  DebugMonitor_IRQn             = -4,         
  PendSV_IRQn                   = -2,         
  SysTick_IRQn                  = -1,         
 
  
  WDT_IRQn                      = 0,          
  TIMER0_IRQn                   = 1,          
  TIMER1_IRQn                   = 2,          
  TIMER2_IRQn                   = 3,          
  TIMER3_IRQn                   = 4,          
  UART0_IRQn                    = 5,          
  UART1_IRQn                    = 6,          
  UART2_IRQn                    = 7,          
  UART3_IRQn                    = 8,          
  PWM1_IRQn                     = 9,          
  I2C0_IRQn                     = 10,         
  I2C1_IRQn                     = 11,         
  I2C2_IRQn                     = 12,         
  SPI_IRQn                      = 13,         
  SSP0_IRQn                     = 14,         
  SSP1_IRQn                     = 15,         
  PLL0_IRQn                     = 16,         
  RTC_IRQn                      = 17,         
  EINT0_IRQn                    = 18,         
  EINT1_IRQn                    = 19,         
  EINT2_IRQn                    = 20,         
  EINT3_IRQn                    = 21,         
  ADC_IRQn                      = 22,         
  BOD_IRQn                      = 23,         
  USB_IRQn                      = 24,         
  CAN_IRQn                      = 25,         
  DMA_IRQn                      = 26,         
  I2S_IRQn                      = 27,         
  ENET_IRQn                     = 28,         
  RIT_IRQn                      = 29,         
  MCPWM_IRQn                    = 30,         
  QEI_IRQn                      = 31,         
  PLL1_IRQn                     = 32,         
} IRQn_Type; 
 
 
 
 
 
 
  
 
  
 
 
 
 
 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
  
  
  
  
  
  
  
  
 
 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\stdint.h" 
  
  
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
#line 25 "C:\\Keil\\\\ARM\\RV31\\INC\\stdint.h" 
 
 
 
 
 
 
 
  
 
      
 
      
typedef   signed          char int8_t; 
typedef   signed short     int int16_t; 
typedef   signed           int int32_t; 
typedef   signed       __int64 int64_t; 
 
      
typedef unsigned          char uint8_t; 
typedef unsigned short     int uint16_t; 
typedef unsigned           int uint32_t; 
typedef unsigned       __int64 uint64_t; 
 
      
 
      
      
typedef   signed          char int_least8_t; 
typedef   signed short     int int_least16_t; 
typedef   signed           int int_least32_t; 
typedef   signed       __int64 int_least64_t; 
 
      
typedef unsigned          char uint_least8_t; 
typedef unsigned short     int uint_least16_t; 
typedef unsigned           int uint_least32_t; 
typedef unsigned       __int64 uint_least64_t; 
 
      
 
      
typedef   signed           int int_fast8_t; 
typedef   signed           int int_fast16_t; 
typedef   signed           int int_fast32_t; 
typedef   signed       __int64 int_fast64_t; 
 
      
typedef unsigned           int uint_fast8_t; 
typedef unsigned           int uint_fast16_t; 
typedef unsigned           int uint_fast32_t; 
typedef unsigned       __int64 uint_fast64_t; 
 
      
typedef   signed           int intptr_t; 
typedef unsigned           int uintptr_t; 
 
      
typedef   signed       __int64 intmax_t; 
typedef unsigned       __int64 uintmax_t; 
 
 
 
 
      
 
      
 
 
 
 
 
      
 
 
 
 
 
      
 
 
 
 
 
      
 
      
 
 
 
 
 
      
 
 
 
 
 
      
 
 
 
 
 
      
 
      
 
 
 
 
 
      
 
 
 
 
 
      
 
 
 
 
 
      
 
      
 
 
      
 
 
      
 
 
      
 
      
 
 
      
 
 
      
 
 
      
 
      
 
 
 
      
 
 
 
      
 
 
      
     
  
 
 
 
#line 196 "C:\\Keil\\\\ARM\\RV31\\INC\\stdint.h" 
 
      
 
 
 
 
 
 
 
      
 
 
 
 
 
 
 
 
 
 
      
 
 
 
 
 
 
 
 
 
 
 
#line 260 "C:\\Keil\\\\ARM\\RV31\\INC\\stdint.h" 
 
 
 
  
 
 
#line 86 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
#line 112 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
 
 
 
 
  
 
 
  
 
 
 
 
 
  
 
 
 
 
 
 
  
typedef struct 
{ 
  volatile uint32_t ISER[8];                        
       uint32_t RESERVED0[24]; 
  volatile uint32_t ICER[8];                        
       uint32_t RSERVED1[24]; 
  volatile uint32_t ISPR[8];                        
       uint32_t RESERVED2[24]; 
  volatile uint32_t ICPR[8];                        
       uint32_t RESERVED3[24]; 
  volatile uint32_t IABR[8];                        
       uint32_t RESERVED4[56]; 
  volatile uint8_t  IP[240];                        
       uint32_t RESERVED5[644]; 
  volatile  uint32_t STIR;                           
}  NVIC_Type; 
 
 
  
typedef struct 
{ 
  volatile const  uint32_t CPUID;                          
  volatile uint32_t ICSR;                           
  volatile uint32_t VTOR;                           
  volatile uint32_t AIRCR;                          
  volatile uint32_t SCR;                            
  volatile uint32_t CCR;                            
  volatile uint8_t  SHP[12];                        
  volatile uint32_t SHCSR;                          
  volatile uint32_t CFSR;                           
  volatile uint32_t HFSR;                           
  volatile uint32_t DFSR;                           
  volatile uint32_t MMFAR;                          
  volatile uint32_t BFAR;                           
  volatile uint32_t AFSR;                           
  volatile const  uint32_t PFR[2];                         
  volatile const  uint32_t DFR;                            
  volatile const  uint32_t ADR;                            
  volatile const  uint32_t MMFR[4];                        
  volatile const  uint32_t ISAR[5];                        
} SCB_Type; 
 
 
  
typedef struct 
{ 
  volatile uint32_t CTRL;                           
  volatile uint32_t LOAD;                           
  volatile uint32_t VAL;                            
  volatile const  uint32_t CALIB;                          
} SysTick_Type; 
 
 
  
typedef struct 
{ 
  volatile  union   
  { 
    volatile  uint8_t    u8;                         
    volatile  uint16_t   u16;                        
    volatile  uint32_t   u32;                        
  }  PORT [32];                                 
       uint32_t RESERVED0[864]; 
  volatile uint32_t TER;                            
       uint32_t RESERVED1[15]; 
  volatile uint32_t TPR;                            
       uint32_t RESERVED2[15]; 
  volatile uint32_t TCR;                            
       uint32_t RESERVED3[29]; 
  volatile uint32_t IWR;                            
  volatile uint32_t IRR;                            
  volatile uint32_t IMCR;                           
       uint32_t RESERVED4[43]; 
  volatile uint32_t LAR;                            
  volatile uint32_t LSR;                            
       uint32_t RESERVED5[6]; 
  volatile const  uint32_t PID4;                           
  volatile const  uint32_t PID5; 
  volatile const  uint32_t PID6; 
  volatile const  uint32_t PID7; 
  volatile const  uint32_t PID0; 
  volatile const  uint32_t PID1; 
  volatile const  uint32_t PID2; 
  volatile const  uint32_t PID3; 
  volatile const  uint32_t CID0; 
  volatile const  uint32_t CID1; 
  volatile const  uint32_t CID2; 
  volatile const  uint32_t CID3; 
} ITM_Type; 
 
 
  
typedef struct 
{ 
       uint32_t RESERVED0; 
  volatile const  uint32_t ICTR;                           
 
 
 
       uint32_t RESERVED1; 
 
} InterruptType_Type; 
 
 
  
 
typedef struct 
{ 
  volatile const  uint32_t TYPE;                           
  volatile uint32_t CTRL;                           
  volatile uint32_t RNR;                            
  volatile uint32_t RBAR;                           
  volatile uint32_t RASR;                           
  volatile uint32_t RBAR_A1;                        
  volatile uint32_t RASR_A1;                        
  volatile uint32_t RBAR_A2;                        
  volatile uint32_t RASR_A2;                        
  volatile uint32_t RBAR_A3;                        
  volatile uint32_t RASR_A3;                        
} MPU_Type; 
 
 
 
  
typedef struct 
{ 
  volatile uint32_t DHCSR;                          
  volatile  uint32_t DCRSR;                          
  volatile uint32_t DCRDR;                          
  volatile uint32_t DEMCR;                          
} CoreDebug_Type; 
 
 
  
#line 274 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
#line 281 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
#line 311 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
 
  
 
 
  
 
 
 
 
#line 336 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
 
  
  
  
  
 
 
 
 
 
 
 
 
 
  
extern uint32_t __get_PSP(void); 
 
 
 
 
 
 
 
 
 
  
extern void __set_PSP(uint32_t topOfProcStack); 
 
 
 
 
 
 
 
 
 
  
extern uint32_t __get_MSP(void); 
 
 
 
 
 
 
 
 
 
  
extern void __set_MSP(uint32_t topOfMainStack); 
 
 
 
 
 
 
 
 
  
extern uint32_t __REV16(uint16_t value); 
 
 
 
 
 
 
 
 
  
extern int32_t __REVSH(int16_t value); 
 
 
#line 502 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t  __get_BASEPRI(void) 
{ 
  register uint32_t __regBasePri         __asm("basepri"); 
  return(__regBasePri); 
} 
 
 
 
 
 
 
 
 
  
static __inline void __set_BASEPRI(uint32_t basePri) 
{ 
  register uint32_t __regBasePri         __asm("basepri"); 
  __regBasePri = (basePri & 0x1ff); 
} 
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t __get_PRIMASK(void) 
{ 
  register uint32_t __regPriMask         __asm("primask"); 
  return(__regPriMask); 
} 
 
 
 
 
 
 
 
 
  
static __inline void __set_PRIMASK(uint32_t priMask) 
{ 
  register uint32_t __regPriMask         __asm("primask"); 
  __regPriMask = (priMask); 
} 
 
 
 
 
 
 
 
 
  
static __inline uint32_t __get_FAULTMASK(void) 
{ 
  register uint32_t __regFaultMask       __asm("faultmask"); 
  return(__regFaultMask); 
} 
 
 
 
 
 
 
 
 
  
static __inline void __set_FAULTMASK(uint32_t faultMask) 
{ 
  register uint32_t __regFaultMask       __asm("faultmask"); 
  __regFaultMask = (faultMask & 1); 
} 
 
 
 
 
 
 
 
 
  
static __inline uint32_t __get_CONTROL(void) 
{ 
  register uint32_t __regControl         __asm("control"); 
  return(__regControl); 
} 
 
 
 
 
 
 
 
 
  
static __inline void __set_CONTROL(uint32_t control) 
{ 
  register uint32_t __regControl         __asm("control"); 
  __regControl = control; 
} 
 
 
 
 
 
#line 1044 "C:\\Keil\\\\ARM\\RV31\\INC\\core_cm3.h" 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
  
static __inline void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) 
{ 
  uint32_t reg_value; 
  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);                           
   
  reg_value  = ((SCB_Type *) ((0xE000E000) + 0x0D00))->AIRCR;                                                      
  reg_value &= ~((0xFFFFU << 16) | (0x0F << 8));                                
  reg_value  = ((reg_value | (0x5FA << 16) | (PriorityGroupTmp << 8)));    
  ((SCB_Type *) ((0xE000E000) + 0x0D00))->AIRCR = reg_value; 
} 
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t NVIC_GetPriorityGrouping(void) 
{ 
  return ((((SCB_Type *) ((0xE000E000) + 0x0D00))->AIRCR >> 8) & 0x07);                                            
} 
 
 
 
 
 
 
 
 
 
  
static __inline void NVIC_EnableIRQ(IRQn_Type IRQn) 
{ 
  ((NVIC_Type *) ((0xE000E000) + 0x0100))->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));   
} 
 
 
 
 
 
 
 
 
 
  
static __inline void NVIC_DisableIRQ(IRQn_Type IRQn) 
{ 
  ((NVIC_Type *) ((0xE000E000) + 0x0100))->ICER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));   
} 
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) 
{ 
  return((uint32_t) ((((NVIC_Type *) ((0xE000E000) + 0x0100))->ISPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));   
} 
 
 
 
 
 
 
 
 
 
  
static __inline void NVIC_SetPendingIRQ(IRQn_Type IRQn) 
{ 
  ((NVIC_Type *) ((0xE000E000) + 0x0100))->ISPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));   
} 
 
 
 
 
 
 
 
 
 
  
static __inline void NVIC_ClearPendingIRQ(IRQn_Type IRQn) 
{ 
  ((NVIC_Type *) ((0xE000E000) + 0x0100))->ICPR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));   
} 
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t NVIC_GetActive(IRQn_Type IRQn) 
{ 
  return((uint32_t)((((NVIC_Type *) ((0xE000E000) + 0x0100))->IABR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F)))?1:0));   
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
static __inline void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) 
{ 
  if(IRQn < 0) { 
    ((SCB_Type *) ((0xE000E000) + 0x0D00))->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - 5)) & 0xff); }   
  else { 
    ((NVIC_Type *) ((0xE000E000) + 0x0100))->IP[(uint32_t)(IRQn)] = ((priority << (8 - 5)) & 0xff);    }          
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t NVIC_GetPriority(IRQn_Type IRQn) 
{ 
 
  if(IRQn < 0) { 
    return((uint32_t)(((SCB_Type *) ((0xE000E000) + 0x0D00))->SHP[((uint32_t)(IRQn) & 0xF)-4] >> (8 - 5)));  }   
  else { 
    return((uint32_t)(((NVIC_Type *) ((0xE000E000) + 0x0100))->IP[(uint32_t)(IRQn)]           >> (8 - 5)));  }   
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) 
{ 
  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);                           
  uint32_t PreemptPriorityBits; 
  uint32_t SubPriorityBits; 
 
  PreemptPriorityBits = ((7 - PriorityGroupTmp) > 5) ? 5 : 7 - PriorityGroupTmp; 
  SubPriorityBits     = ((PriorityGroupTmp + 5) < 7) ? 0 : PriorityGroupTmp - 7 + 5; 
  
  return ( 
           ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) | 
           ((SubPriority     & ((1 << (SubPriorityBits    )) - 1))) 
         ); 
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
static __inline void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority) 
{ 
  uint32_t PriorityGroupTmp = (PriorityGroup & 0x07);                           
  uint32_t PreemptPriorityBits; 
  uint32_t SubPriorityBits; 
 
  PreemptPriorityBits = ((7 - PriorityGroupTmp) > 5) ? 5 : 7 - PriorityGroupTmp; 
  SubPriorityBits     = ((PriorityGroupTmp + 5) < 7) ? 0 : PriorityGroupTmp - 7 + 5; 
   
  *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1); 
  *pSubPriority     = (Priority                   ) & ((1 << (SubPriorityBits    )) - 1); 
} 
 
 
 
  
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t SysTick_Config(uint32_t ticks) 
{  
  if (ticks > ((1<<24) -1))  return (1);                                               
 
  ((SysTick_Type *) ((0xE000E000) + 0x0010))->LOAD  =  (ticks & ((1<<24) -1)) - 1;                                        
  NVIC_SetPriority (SysTick_IRQn, (1<<5) - 1);                              
  ((SysTick_Type *) ((0xE000E000) + 0x0010))->VAL   =  (0x00);                                                                
  ((SysTick_Type *) ((0xE000E000) + 0x0010))->CTRL = (1 << 2) | (1<<0) | (1<<1);   
  return (0);                                                                              
} 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
  
static __inline void NVIC_SystemReset(void) 
{ 
  ((SCB_Type *) ((0xE000E000) + 0x0D00))->AIRCR  = ((0x5FA << 16) | (((SCB_Type *) ((0xE000E000) + 0x0D00))->AIRCR & (0x700)) | (1<<2));   
  __dsb(0);                                                                                             
  while(1);                                                                              
} 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
  
static __inline uint32_t ITM_SendChar (uint32_t ch) 
{ 
  if (ch == '\n') ITM_SendChar('\r'); 
   
  if ((((CoreDebug_Type *) (0xE000EDF0))->DEMCR & (1 << 24))  && 
      (((ITM_Type *) (0xE0000000))->TCR & 1)                  && 
      (((ITM_Type *) (0xE0000000))->TER & (1UL << 0))  )  
  { 
    while (((ITM_Type *) (0xE0000000))->PORT[0].u32 == 0); 
    ((ITM_Type *) (0xE0000000))->PORT[0].u8 = (uint8_t) ch; 
  }   
  return (ch); 
} 
 
 
 
 
 
 
 
  
#line 95 "C:\\Keil\\ARM\\INC\\NXP\\LPC17xx.H" 
#line 1 "C:\\Keil\\ARM\\INC\\NXP\\system_LPC17xx.h" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
extern uint32_t SystemFrequency;      
 
 
 
 
 
 
 
 
 
 
  
extern void SystemInit (void); 
 
 
 
 
 
#line 96 "C:\\Keil\\ARM\\INC\\NXP\\LPC17xx.H" 
 
 
  
  
  
 
#pragma anon_unions 
 
  
typedef struct 
{ 
  volatile uint32_t FLASHCFG;                 
       uint32_t RESERVED0[31]; 
  volatile uint32_t PLL0CON;                  
  volatile uint32_t PLL0CFG; 
  volatile const  uint32_t PLL0STAT; 
  volatile  uint32_t PLL0FEED; 
       uint32_t RESERVED1[4]; 
  volatile uint32_t PLL1CON; 
  volatile uint32_t PLL1CFG; 
  volatile const  uint32_t PLL1STAT; 
  volatile  uint32_t PLL1FEED; 
       uint32_t RESERVED2[4]; 
  volatile uint32_t PCON; 
  volatile uint32_t PCONP; 
       uint32_t RESERVED3[15]; 
  volatile uint32_t CCLKCFG; 
  volatile uint32_t USBCLKCFG; 
  volatile uint32_t CLKSRCSEL; 
       uint32_t RESERVED4[12]; 
  volatile uint32_t EXTINT;                   
       uint32_t RESERVED5; 
  volatile uint32_t EXTMODE; 
  volatile uint32_t EXTPOLAR; 
       uint32_t RESERVED6[12]; 
  volatile uint32_t RSID;                     
       uint32_t RESERVED7[7]; 
  volatile uint32_t SCS;                      
  volatile uint32_t IRCTRIM;                  
  volatile uint32_t PCLKSEL0; 
  volatile uint32_t PCLKSEL1; 
       uint32_t RESERVED8[4]; 
  volatile uint32_t USBIntSt;                 
       uint32_t RESERVED9; 
  volatile uint32_t CLKOUTCFG;                
 } LPC_SC_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t PINSEL0; 
  volatile uint32_t PINSEL1; 
  volatile uint32_t PINSEL2; 
  volatile uint32_t PINSEL3; 
  volatile uint32_t PINSEL4; 
  volatile uint32_t PINSEL5; 
  volatile uint32_t PINSEL6; 
  volatile uint32_t PINSEL7; 
  volatile uint32_t PINSEL8; 
  volatile uint32_t PINSEL9; 
  volatile uint32_t PINSEL10; 
       uint32_t RESERVED0[5]; 
  volatile uint32_t PINMODE0; 
  volatile uint32_t PINMODE1; 
  volatile uint32_t PINMODE2; 
  volatile uint32_t PINMODE3; 
  volatile uint32_t PINMODE4; 
  volatile uint32_t PINMODE5; 
  volatile uint32_t PINMODE6; 
  volatile uint32_t PINMODE7; 
  volatile uint32_t PINMODE8; 
  volatile uint32_t PINMODE9; 
  volatile uint32_t PINMODE_OD0; 
  volatile uint32_t PINMODE_OD1; 
  volatile uint32_t PINMODE_OD2; 
  volatile uint32_t PINMODE_OD3; 
  volatile uint32_t PINMODE_OD4; 
  volatile uint32_t I2CPADCFG; 
} LPC_PINCON_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t FIODIR; 
       uint32_t RESERVED0[3]; 
  volatile uint32_t FIOMASK; 
  volatile uint32_t FIOPIN; 
  volatile uint32_t FIOSET; 
  volatile  uint32_t FIOCLR; 
} LPC_GPIO_TypeDef; 
 
typedef struct 
{ 
  volatile const  uint32_t IntStatus; 
  volatile const  uint32_t IO0IntStatR; 
  volatile const  uint32_t IO0IntStatF; 
  volatile  uint32_t IO0IntClr; 
  volatile uint32_t IO0IntEnR; 
  volatile uint32_t IO0IntEnF; 
       uint32_t RESERVED0[3]; 
  volatile const  uint32_t IO2IntStatR; 
  volatile const  uint32_t IO2IntStatF; 
  volatile  uint32_t IO2IntClr; 
  volatile uint32_t IO2IntEnR; 
  volatile uint32_t IO2IntEnF; 
} LPC_GPIOINT_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t IR; 
  volatile uint32_t TCR; 
  volatile uint32_t TC; 
  volatile uint32_t PR; 
  volatile uint32_t PC; 
  volatile uint32_t MCR; 
  volatile uint32_t MR0; 
  volatile uint32_t MR1; 
  volatile uint32_t MR2; 
  volatile uint32_t MR3; 
  volatile uint32_t CCR; 
  volatile const  uint32_t CR0; 
  volatile const  uint32_t CR1; 
       uint32_t RESERVED0[2]; 
  volatile uint32_t EMR; 
       uint32_t RESERVED1[24]; 
  volatile uint32_t CTCR; 
} LPC_TIM_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t IR; 
  volatile uint32_t TCR; 
  volatile uint32_t TC; 
  volatile uint32_t PR; 
  volatile uint32_t PC; 
  volatile uint32_t MCR; 
  volatile uint32_t MR0; 
  volatile uint32_t MR1; 
  volatile uint32_t MR2; 
  volatile uint32_t MR3; 
  volatile uint32_t CCR; 
  volatile const  uint32_t CR0; 
  volatile const  uint32_t CR1; 
  volatile const  uint32_t CR2; 
  volatile const  uint32_t CR3; 
       uint32_t RESERVED0; 
  volatile uint32_t MR4; 
  volatile uint32_t MR5; 
  volatile uint32_t MR6; 
  volatile uint32_t PCR; 
  volatile uint32_t LER; 
       uint32_t RESERVED1[7]; 
  volatile uint32_t CTCR; 
} LPC_PWM_TypeDef; 
 
  
typedef struct 
{ 
  union { 
  volatile const  uint8_t  RBR; 
  volatile  uint8_t  THR; 
  volatile uint8_t  DLL; 
       uint32_t RESERVED0; 
  }; 
  union { 
  volatile uint8_t  DLM; 
  volatile uint32_t IER; 
  }; 
  union { 
  volatile const  uint32_t IIR; 
  volatile  uint8_t  FCR; 
  }; 
  volatile uint8_t  LCR; 
       uint8_t  RESERVED1[7]; 
  volatile const  uint8_t  LSR; 
       uint8_t  RESERVED2[7]; 
  volatile uint8_t  SCR; 
       uint8_t  RESERVED3[3]; 
  volatile uint32_t ACR; 
  volatile uint8_t  ICR; 
       uint8_t  RESERVED4[3]; 
  volatile uint8_t  FDR; 
       uint8_t  RESERVED5[7]; 
  volatile uint8_t  TER; 
       uint8_t  RESERVED6[39]; 
  volatile const  uint8_t  FIFOLVL; 
} LPC_UART_TypeDef; 
 
typedef struct 
{ 
  union { 
  volatile const  uint8_t  RBR; 
  volatile  uint8_t  THR; 
  volatile uint8_t  DLL; 
       uint32_t RESERVED0; 
  }; 
  union { 
  volatile uint8_t  DLM; 
  volatile uint32_t IER; 
  }; 
  union { 
  volatile const  uint32_t IIR; 
  volatile  uint8_t  FCR; 
  }; 
  volatile uint8_t  LCR; 
       uint8_t  RESERVED1[7]; 
  volatile const  uint8_t  LSR; 
       uint8_t  RESERVED2[7]; 
  volatile uint8_t  SCR; 
       uint8_t  RESERVED3[3]; 
  volatile uint32_t ACR; 
  volatile uint8_t  ICR; 
       uint8_t  RESERVED4[3]; 
  volatile uint8_t  FDR; 
       uint8_t  RESERVED5[7]; 
  volatile uint8_t  TER; 
       uint8_t  RESERVED6[39]; 
  volatile const  uint8_t  FIFOLVL; 
       uint8_t  RESERVED7[363]; 
  volatile uint32_t DMAREQSEL; 
} LPC_UART0_TypeDef; 
 
typedef struct 
{ 
  union { 
  volatile const  uint8_t  RBR; 
  volatile  uint8_t  THR; 
  volatile uint8_t  DLL; 
       uint32_t RESERVED0; 
  }; 
  union { 
  volatile uint8_t  DLM; 
  volatile uint32_t IER; 
  }; 
  union { 
  volatile const  uint32_t IIR; 
  volatile  uint8_t  FCR; 
  }; 
  volatile uint8_t  LCR; 
       uint8_t  RESERVED1[3]; 
  volatile uint8_t  MCR; 
       uint8_t  RESERVED2[3]; 
  volatile const  uint8_t  LSR; 
       uint8_t  RESERVED3[3]; 
  volatile const  uint8_t  MSR; 
       uint8_t  RESERVED4[3]; 
  volatile uint8_t  SCR; 
       uint8_t  RESERVED5[3]; 
  volatile uint32_t ACR; 
       uint32_t RESERVED6; 
  volatile uint32_t FDR; 
       uint32_t RESERVED7; 
  volatile uint8_t  TER; 
       uint8_t  RESERVED8[27]; 
  volatile uint8_t  RS485CTRL; 
       uint8_t  RESERVED9[3]; 
  volatile uint8_t  ADRMATCH; 
       uint8_t  RESERVED10[3]; 
  volatile uint8_t  RS485DLY; 
       uint8_t  RESERVED11[3]; 
  volatile const  uint8_t  FIFOLVL; 
} LPC_UART1_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t SPCR; 
  volatile  uint32_t SPSR; 
  volatile uint32_t SPDR; 
  volatile uint32_t SPCCR; 
       uint32_t RESERVED0[3]; 
  volatile uint32_t SPINT; 
} LPC_SPI_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t CR0; 
  volatile uint32_t CR1; 
  volatile uint32_t DR; 
  volatile const  uint32_t SR; 
  volatile uint32_t CPSR; 
  volatile uint32_t IMSC; 
  volatile uint32_t RIS; 
  volatile uint32_t MIS; 
  volatile uint32_t ICR; 
  volatile uint32_t DMACR; 
} LPC_SSP_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t I2CONSET; 
  volatile const  uint32_t I2STAT; 
  volatile uint32_t I2DAT; 
  volatile uint32_t I2ADR0; 
  volatile uint32_t I2SCLH; 
  volatile uint32_t I2SCLL; 
  volatile  uint32_t I2CONCLR; 
  volatile uint32_t MMCTRL; 
  volatile uint32_t I2ADR1; 
  volatile uint32_t I2ADR2; 
  volatile uint32_t I2ADR3; 
  volatile const  uint32_t I2DATA_BUFFER; 
  volatile uint32_t I2MASK0; 
  volatile uint32_t I2MASK1; 
  volatile uint32_t I2MASK2; 
  volatile uint32_t I2MASK3; 
} LPC_I2C_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t I2SDAO; 
  volatile uint32_t I2SDAI; 
  volatile  uint32_t I2STXFIFO; 
  volatile const  uint32_t I2SRXFIFO; 
  volatile const  uint32_t I2SSTATE; 
  volatile uint32_t I2SDMA1; 
  volatile uint32_t I2SDMA2; 
  volatile uint32_t I2SIRQ; 
  volatile uint32_t I2STXRATE; 
  volatile uint32_t I2SRXRATE; 
  volatile uint32_t I2STXBITRATE; 
  volatile uint32_t I2SRXBITRATE; 
  volatile uint32_t I2STXMODE; 
  volatile uint32_t I2SRXMODE; 
} LPC_I2S_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t RICOMPVAL; 
  volatile uint32_t RIMASK; 
  volatile uint8_t  RICTRL; 
       uint8_t  RESERVED0[3]; 
  volatile uint32_t RICOUNTER; 
} LPC_RIT_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint8_t  ILR; 
       uint8_t  RESERVED0[7]; 
  volatile uint8_t  CCR; 
       uint8_t  RESERVED1[3]; 
  volatile uint8_t  CIIR; 
       uint8_t  RESERVED2[3]; 
  volatile uint8_t  AMR; 
       uint8_t  RESERVED3[3]; 
  volatile const  uint32_t CTIME0; 
  volatile const  uint32_t CTIME1; 
  volatile const  uint32_t CTIME2; 
  volatile uint8_t  SEC; 
       uint8_t  RESERVED4[3]; 
  volatile uint8_t  MIN; 
       uint8_t  RESERVED5[3]; 
  volatile uint8_t  HOUR; 
       uint8_t  RESERVED6[3]; 
  volatile uint8_t  DOM; 
       uint8_t  RESERVED7[3]; 
  volatile uint8_t  DOW; 
       uint8_t  RESERVED8[3]; 
  volatile uint16_t DOY; 
       uint16_t RESERVED9; 
  volatile uint8_t  MONTH; 
       uint8_t  RESERVED10[3]; 
  volatile uint16_t YEAR; 
       uint16_t RESERVED11; 
  volatile uint32_t CALIBRATION; 
  volatile uint32_t GPREG0; 
  volatile uint32_t GPREG1; 
  volatile uint32_t GPREG2; 
  volatile uint32_t GPREG3; 
  volatile uint32_t GPREG4; 
  volatile uint8_t  RTC_AUXEN; 
       uint8_t  RESERVED12[3]; 
  volatile uint8_t  RTC_AUX; 
       uint8_t  RESERVED13[3]; 
  volatile uint8_t  ALSEC; 
       uint8_t  RESERVED14[3]; 
  volatile uint8_t  ALMIN; 
       uint8_t  RESERVED15[3]; 
  volatile uint8_t  ALHOUR; 
       uint8_t  RESERVED16[3]; 
  volatile uint8_t  ALDOM; 
       uint8_t  RESERVED17[3]; 
  volatile uint8_t  ALDOW; 
       uint8_t  RESERVED18[3]; 
  volatile uint16_t ALDOY; 
       uint16_t RESERVED19; 
  volatile uint8_t  ALMON; 
       uint8_t  RESERVED20[3]; 
  volatile uint16_t ALYEAR; 
       uint16_t RESERVED21; 
} LPC_RTC_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint8_t  WDMOD; 
       uint8_t  RESERVED0[3]; 
  volatile uint32_t WDTC; 
  volatile  uint8_t  WDFEED; 
       uint8_t  RESERVED1[3]; 
  volatile const  uint32_t WDTV; 
  volatile uint32_t WDCLKSEL; 
} LPC_WDT_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t ADCR; 
  volatile uint32_t ADGDR; 
       uint32_t RESERVED0; 
  volatile uint32_t ADINTEN; 
  volatile const  uint32_t ADDR0; 
  volatile const  uint32_t ADDR1; 
  volatile const  uint32_t ADDR2; 
  volatile const  uint32_t ADDR3; 
  volatile const  uint32_t ADDR4; 
  volatile const  uint32_t ADDR5; 
  volatile const  uint32_t ADDR6; 
  volatile const  uint32_t ADDR7; 
  volatile const  uint32_t ADSTAT; 
  volatile uint32_t ADTRM; 
} LPC_ADC_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t DACR; 
  volatile uint32_t DACCTRL; 
  volatile uint16_t DACCNTVAL; 
} LPC_DAC_TypeDef; 
 
  
typedef struct 
{ 
  volatile const  uint32_t MCCON; 
  volatile  uint32_t MCCON_SET; 
  volatile  uint32_t MCCON_CLR; 
  volatile const  uint32_t MCCAPCON; 
  volatile  uint32_t MCCAPCON_SET; 
  volatile  uint32_t MCCAPCON_CLR; 
  volatile uint32_t MCTIM0; 
  volatile uint32_t MCTIM1; 
  volatile uint32_t MCTIM2; 
  volatile uint32_t MCPER0; 
  volatile uint32_t MCPER1; 
  volatile uint32_t MCPER2; 
  volatile uint32_t MCPW0; 
  volatile uint32_t MCPW1; 
  volatile uint32_t MCPW2; 
  volatile uint32_t MCDEADTIME; 
  volatile uint32_t MCCCP; 
  volatile uint32_t MCCR0; 
  volatile uint32_t MCCR1; 
  volatile uint32_t MCCR2; 
  volatile const  uint32_t MCINTEN; 
  volatile  uint32_t MCINTEN_SET; 
  volatile  uint32_t MCINTEN_CLR; 
  volatile const  uint32_t MCCNTCON; 
  volatile  uint32_t MCCNTCON_SET; 
  volatile  uint32_t MCCNTCON_CLR; 
  volatile const  uint32_t MCINTFLAG; 
  volatile  uint32_t MCINTFLAG_SET; 
  volatile  uint32_t MCINTFLAG_CLR; 
  volatile  uint32_t MCCAP_CLR; 
} LPC_MCPWM_TypeDef; 
 
  
typedef struct 
{ 
  volatile  uint32_t QEICON; 
  volatile const  uint32_t QEISTAT; 
  volatile uint32_t QEICONF; 
  volatile const  uint32_t QEIPOS; 
  volatile uint32_t QEIMAXPOS; 
  volatile uint32_t CMPOS0; 
  volatile uint32_t CMPOS1; 
  volatile uint32_t CMPOS2; 
  volatile const  uint32_t INXCNT; 
  volatile uint32_t INXCMP; 
  volatile uint32_t QEILOAD; 
  volatile const  uint32_t QEITIME; 
  volatile const  uint32_t QEIVEL; 
  volatile const  uint32_t QEICAP; 
  volatile uint32_t VELCOMP; 
  volatile uint32_t FILTER; 
       uint32_t RESERVED0[998]; 
  volatile  uint32_t QEIIEC; 
  volatile  uint32_t QEIIES; 
  volatile const  uint32_t QEIINTSTAT; 
  volatile const  uint32_t QEIIE; 
  volatile  uint32_t QEICLR; 
  volatile  uint32_t QEISET; 
} LPC_QEI_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t mask[512];                
} LPC_CANAF_RAM_TypeDef; 
 
typedef struct                            
{ 
  volatile uint32_t AFMR; 
  volatile uint32_t SFF_sa; 
  volatile uint32_t SFF_GRP_sa; 
  volatile uint32_t EFF_sa; 
  volatile uint32_t EFF_GRP_sa; 
  volatile uint32_t ENDofTable; 
  volatile const  uint32_t LUTerrAd; 
  volatile const  uint32_t LUTerr; 
  volatile uint32_t FCANIE; 
  volatile uint32_t FCANIC0; 
  volatile uint32_t FCANIC1; 
} LPC_CANAF_TypeDef; 
 
typedef struct                            
{ 
  volatile const  uint32_t CANTxSR; 
  volatile const  uint32_t CANRxSR; 
  volatile const  uint32_t CANMSR; 
} LPC_CANCR_TypeDef; 
 
typedef struct                            
{ 
  volatile uint32_t MOD; 
  volatile  uint32_t CMR; 
  volatile uint32_t GSR; 
  volatile const  uint32_t ICR; 
  volatile uint32_t IER; 
  volatile uint32_t BTR; 
  volatile uint32_t EWL; 
  volatile const  uint32_t SR; 
  volatile uint32_t RFS; 
  volatile uint32_t RID; 
  volatile uint32_t RDA; 
  volatile uint32_t RDB; 
  volatile uint32_t TFI1; 
  volatile uint32_t TID1; 
  volatile uint32_t TDA1; 
  volatile uint32_t TDB1; 
  volatile uint32_t TFI2; 
  volatile uint32_t TID2; 
  volatile uint32_t TDA2; 
  volatile uint32_t TDB2; 
  volatile uint32_t TFI3; 
  volatile uint32_t TID3; 
  volatile uint32_t TDA3; 
  volatile uint32_t TDB3; 
} LPC_CAN_TypeDef; 
 
  
typedef struct                            
{ 
  volatile const  uint32_t DMACIntStat; 
  volatile const  uint32_t DMACIntTCStat; 
  volatile  uint32_t DMACIntTCClear; 
  volatile const  uint32_t DMACIntErrStat; 
  volatile  uint32_t DMACIntErrClr; 
  volatile const  uint32_t DMACRawIntTCStat; 
  volatile const  uint32_t DMACRawIntErrStat; 
  volatile const  uint32_t DMACEnbldChns; 
  volatile uint32_t DMACSoftBReq; 
  volatile uint32_t DMACSoftSReq; 
  volatile uint32_t DMACSoftLBReq; 
  volatile uint32_t DMACSoftLSReq; 
  volatile uint32_t DMACConfig; 
  volatile uint32_t DMACSync; 
} LPC_GPDMA_TypeDef; 
 
typedef struct                            
{ 
  volatile uint32_t DMACCSrcAddr; 
  volatile uint32_t DMACCDestAddr; 
  volatile uint32_t DMACCLLI; 
  volatile uint32_t DMACCControl; 
  volatile uint32_t DMACCConfig; 
} LPC_GPDMACH_TypeDef; 
 
  
typedef struct 
{ 
  volatile const  uint32_t HcRevision;               
  volatile uint32_t HcControl; 
  volatile uint32_t HcCommandStatus; 
  volatile uint32_t HcInterruptStatus; 
  volatile uint32_t HcInterruptEnable; 
  volatile uint32_t HcInterruptDisable; 
  volatile uint32_t HcHCCA; 
  volatile const  uint32_t HcPeriodCurrentED; 
  volatile uint32_t HcControlHeadED; 
  volatile uint32_t HcControlCurrentED; 
  volatile uint32_t HcBulkHeadED; 
  volatile uint32_t HcBulkCurrentED; 
  volatile const  uint32_t HcDoneHead; 
  volatile uint32_t HcFmInterval; 
  volatile const  uint32_t HcFmRemaining; 
  volatile const  uint32_t HcFmNumber; 
  volatile uint32_t HcPeriodicStart; 
  volatile uint32_t HcLSTreshold; 
  volatile uint32_t HcRhDescriptorA; 
  volatile uint32_t HcRhDescriptorB; 
  volatile uint32_t HcRhStatus; 
  volatile uint32_t HcRhPortStatus1; 
  volatile uint32_t HcRhPortStatus2; 
       uint32_t RESERVED0[40]; 
  volatile const  uint32_t Module_ID; 
 
  volatile const  uint32_t OTGIntSt;                 
  volatile uint32_t OTGIntEn; 
  volatile  uint32_t OTGIntSet; 
  volatile  uint32_t OTGIntClr; 
  volatile uint32_t OTGStCtrl; 
  volatile uint32_t OTGTmr; 
       uint32_t RESERVED1[58]; 
 
  volatile const  uint32_t USBDevIntSt;              
  volatile uint32_t USBDevIntEn; 
  volatile  uint32_t USBDevIntClr; 
  volatile  uint32_t USBDevIntSet; 
 
  volatile  uint32_t USBCmdCode;               
  volatile const  uint32_t USBCmdData; 
 
  volatile const  uint32_t USBRxData;                
  volatile  uint32_t USBTxData; 
  volatile const  uint32_t USBRxPLen; 
  volatile  uint32_t USBTxPLen; 
  volatile uint32_t USBCtrl; 
  volatile  uint32_t USBDevIntPri; 
 
  volatile const  uint32_t USBEpIntSt;               
  volatile uint32_t USBEpIntEn; 
  volatile  uint32_t USBEpIntClr; 
  volatile  uint32_t USBEpIntSet; 
  volatile  uint32_t USBEpIntPri; 
 
  volatile uint32_t USBReEp;                  
  volatile  uint32_t USBEpInd; 
  volatile uint32_t USBMaxPSize; 
 
  volatile const  uint32_t USBDMARSt;                
  volatile  uint32_t USBDMARClr; 
  volatile  uint32_t USBDMARSet; 
       uint32_t RESERVED2[9]; 
  volatile uint32_t USBUDCAH; 
  volatile const  uint32_t USBEpDMASt; 
  volatile  uint32_t USBEpDMAEn; 
  volatile  uint32_t USBEpDMADis; 
  volatile const  uint32_t USBDMAIntSt; 
  volatile uint32_t USBDMAIntEn; 
       uint32_t RESERVED3[2]; 
  volatile const  uint32_t USBEoTIntSt; 
  volatile  uint32_t USBEoTIntClr; 
  volatile  uint32_t USBEoTIntSet; 
  volatile const  uint32_t USBNDDRIntSt; 
  volatile  uint32_t USBNDDRIntClr; 
  volatile  uint32_t USBNDDRIntSet; 
  volatile const  uint32_t USBSysErrIntSt; 
  volatile  uint32_t USBSysErrIntClr; 
  volatile  uint32_t USBSysErrIntSet; 
       uint32_t RESERVED4[15]; 
 
  volatile const  uint32_t I2C_RX;                   
  volatile  uint32_t I2C_WO; 
  volatile const  uint32_t I2C_STS; 
  volatile uint32_t I2C_CTL; 
  volatile uint32_t I2C_CLKHI; 
  volatile  uint32_t I2C_CLKLO; 
       uint32_t RESERVED5[823]; 
 
  union { 
  volatile uint32_t USBClkCtrl;               
  volatile uint32_t OTGClkCtrl; 
  }; 
  union { 
  volatile const  uint32_t USBClkSt; 
  volatile const  uint32_t OTGClkSt; 
  }; 
} LPC_USB_TypeDef; 
 
  
typedef struct 
{ 
  volatile uint32_t MAC1;                     
  volatile uint32_t MAC2; 
  volatile uint32_t IPGT; 
  volatile uint32_t IPGR; 
  volatile uint32_t CLRT; 
  volatile uint32_t MAXF; 
  volatile uint32_t SUPP; 
  volatile uint32_t TEST; 
  volatile uint32_t MCFG; 
  volatile uint32_t MCMD; 
  volatile uint32_t MADR; 
  volatile  uint32_t MWTD; 
  volatile const  uint32_t MRDD; 
  volatile const  uint32_t MIND; 
       uint32_t RESERVED0[2]; 
  volatile uint32_t SA0; 
  volatile uint32_t SA1; 
  volatile uint32_t SA2; 
       uint32_t RESERVED1[45]; 
  volatile uint32_t Command;                  
  volatile const  uint32_t Status; 
  volatile uint32_t RxDescriptor; 
  volatile uint32_t RxStatus; 
  volatile uint32_t RxDescriptorNumber; 
  volatile const  uint32_t RxProduceIndex; 
  volatile uint32_t RxConsumeIndex; 
  volatile uint32_t TxDescriptor; 
  volatile uint32_t TxStatus; 
  volatile uint32_t TxDescriptorNumber; 
  volatile uint32_t TxProduceIndex; 
  volatile const  uint32_t TxConsumeIndex; 
       uint32_t RESERVED2[10]; 
  volatile const  uint32_t TSV0; 
  volatile const  uint32_t TSV1; 
  volatile const  uint32_t RSV; 
       uint32_t RESERVED3[3]; 
  volatile uint32_t FlowControlCounter; 
  volatile const  uint32_t FlowControlStatus; 
       uint32_t RESERVED4[34]; 
  volatile uint32_t RxFilterCtrl;             
  volatile uint32_t RxFilterWoLStatus; 
  volatile uint32_t RxFilterWoLClear; 
       uint32_t RESERVED5; 
  volatile uint32_t HashFilterL; 
  volatile uint32_t HashFilterH; 
       uint32_t RESERVED6[882]; 
  volatile const  uint32_t IntStatus;                
  volatile uint32_t IntEnable; 
  volatile  uint32_t IntClear; 
  volatile  uint32_t IntSet; 
       uint32_t RESERVED7; 
  volatile uint32_t PowerDown; 
       uint32_t RESERVED8; 
  volatile uint32_t Module_ID; 
} LPC_EMAC_TypeDef; 
 
#pragma no_anon_unions 
 
 
  
  
  
  
#line 856 "C:\\Keil\\ARM\\INC\\NXP\\LPC17xx.H" 
 
  
#line 877 "C:\\Keil\\ARM\\INC\\NXP\\LPC17xx.H" 
 
  
#line 891 "C:\\Keil\\ARM\\INC\\NXP\\LPC17xx.H" 
 
  
#line 904 "C:\\Keil\\ARM\\INC\\NXP\\LPC17xx.H" 
 
  
 
 
 
 
 
 
 
  
  
  
#line 963 "C:\\Keil\\ARM\\INC\\NXP\\LPC17xx.H" 
 
#line 13 "SPI_LPC17xx.c" 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\File_Config.h" 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\RTL.h" 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
  
 
  
 
 
#line 27 "C:\\Keil\\\\ARM\\RV31\\INC\\RTL.h" 
 
 
 
 
 
 
 
 typedef unsigned int   size_t; 
 
 
typedef signed char     S8; 
typedef unsigned char   U8; 
typedef short           S16; 
typedef unsigned short  U16; 
typedef int             S32; 
typedef unsigned int    U32; 
typedef long long       S64; 
typedef unsigned long long U64; 
typedef unsigned char   BIT; 
typedef unsigned int    BOOL; 
 
#line 54 "C:\\Keil\\\\ARM\\RV31\\INC\\RTL.h" 
 
 
 
  
 
 
 
 
 
  
typedef U32 OS_SEM[2]; 
 
  
 
typedef U32 OS_MBX[]; 
 
  
typedef U32 OS_MUT[3]; 
 
  
typedef U32 OS_TID; 
 
  
typedef void *OS_ID; 
 
  
typedef U32 OS_RESULT; 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
#line 176 "C:\\Keil\\\\ARM\\RV31\\INC\\RTL.h" 
 
 
 
  
 
 
 
  
extern void      os_set_env    (void); 
extern void      rt_sys_init   (void (*task)(void), U8 priority, void *stk); 
extern void      rt_tsk_pass   (void); 
extern OS_TID    rt_tsk_self   (void); 
extern OS_RESULT rt_tsk_prio   (OS_TID task_id, U8 new_prio); 
extern OS_TID    rt_tsk_create (void (*task)(void), U8 priority, void *stk, void *argv); 
extern OS_RESULT rt_tsk_delete (OS_TID task_id); 
 
#line 211 "C:\\Keil\\\\ARM\\RV31\\INC\\RTL.h" 
 
extern void      _os_sys_init(U32 p, void (*task)(void), U32 prio_stksz, 
                                     void *stk)                        __svc_indirect(0); 
extern OS_TID    _os_tsk_create (U32 p, void (*task)(void), U32 prio_stksz, 
                                        void *stk, void *argv)         __svc_indirect(0); 
extern OS_TID    _os_tsk_create_ex (U32 p, void (*task)(void *), U32 prio_stksz, 
                                           void *stk, void *argv)      __svc_indirect(0); 
extern OS_TID    _os_tsk_self (U32 p)                                  __svc_indirect(0); 
extern void      _os_tsk_pass (U32 p)                                  __svc_indirect(0); 
extern OS_RESULT _os_tsk_prio (U32 p, OS_TID task_id, U8 new_prio)     __svc_indirect(0); 
extern OS_RESULT _os_tsk_delete (U32 p, OS_TID task_id)                __svc_indirect(0); 
 
  
extern OS_RESULT rt_evt_wait (U16 wait_flags,  U16 timeout, BOOL and_wait); 
extern void      rt_evt_set  (U16 event_flags, OS_TID task_id); 
extern void      rt_evt_clr  (U16 clear_flags, OS_TID task_id); 
extern U16       rt_evt_get  (void); 
 
 
 
 
 
 
 
extern OS_RESULT _os_evt_wait(U32 p, U16 wait_flags, U16 timeout, 
                                     BOOL and_wait)                    __svc_indirect(0); 
extern void      _os_evt_set (U32 p, U16 event_flags, OS_TID task_id)  __svc_indirect(0); 
extern void      _os_evt_clr (U32 p, U16 clear_flags, OS_TID task_id)  __svc_indirect(0); 
extern U16       _os_evt_get (U32 p)                                   __svc_indirect(0); 
extern void      isr_evt_set (U16 event_flags, OS_TID task_id); 
 
  
extern void      rt_sem_init (OS_ID semaphore, U16 token_count); 
extern OS_RESULT rt_sem_send (OS_ID semaphore); 
extern OS_RESULT rt_sem_wait (OS_ID semaphore, U16 timeout); 
 
 
 
 
 
extern void      _os_sem_init (U32 p, OS_ID semaphore,  
                                      U16 token_count)                 __svc_indirect(0); 
extern OS_RESULT _os_sem_send (U32 p, OS_ID semaphore)                 __svc_indirect(0); 
extern OS_RESULT _os_sem_wait (U32 p, OS_ID semaphore, U16 timeout)    __svc_indirect(0); 
extern void      isr_sem_send (OS_ID semaphore); 
 
  
extern void      rt_mbx_init  (OS_ID mailbox, U16 mbx_size); 
extern OS_RESULT rt_mbx_send  (OS_ID mailbox, void *p_msg,    U16 timeout); 
extern OS_RESULT rt_mbx_wait  (OS_ID mailbox, void **message, U16 timeout); 
extern OS_RESULT rt_mbx_check (OS_ID mailbox); 
 
 
 
 
 
 
 
extern void      _os_mbx_init (U32 p, OS_ID mailbox, U16 mbx_size)     __svc_indirect(0); 
extern OS_RESULT _os_mbx_send (U32 p, OS_ID mailbox, void *message_ptr, 
                                      U16 timeout)                     __svc_indirect(0); 
extern OS_RESULT _os_mbx_wait (U32 p, OS_ID mailbox, void  **message, 
                                      U16 timeout)                     __svc_indirect(0); 
extern OS_RESULT _os_mbx_check (U32 p, OS_ID mailbox)                  __svc_indirect(0); 
extern void      isr_mbx_send (OS_ID mailbox, void *message_ptr); 
extern OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message); 
 
  
extern void      rt_mut_init    (OS_ID mutex); 
extern OS_RESULT rt_mut_release (OS_ID mutex); 
extern OS_RESULT rt_mut_wait    (OS_ID mutex, U16 timeout); 
 
 
 
 
 
extern void      _os_mut_init (U32 p, OS_ID mutex)                     __svc_indirect(0); 
extern OS_RESULT _os_mut_release (U32 p, OS_ID mutex)                  __svc_indirect(0); 
extern OS_RESULT _os_mut_wait (U32 p, OS_ID mutex, U16 timeout)        __svc_indirect(0); 
 
  
extern void      rt_dly_wait (U16 delay_time); 
extern void      rt_itv_set  (U16 interval_time); 
extern void      rt_itv_wait (void); 
 
 
 
 
 
extern void      _os_dly_wait (U32 p, U16 delay_time)                  __svc_indirect(0); 
extern void      _os_itv_set (U32 p, U16 interval_time)                __svc_indirect(0); 
extern void      _os_itv_wait (U32 p)                                  __svc_indirect(0); 
 
  
extern OS_ID     rt_tmr_create (U16 tcnt, U16 info); 
extern OS_ID     rt_tmr_kill   (OS_ID timer); 
 
 
 
 
extern OS_ID     _os_tmr_create (U32 p, U16 tcnt, U16 info)            __svc_indirect(0); 
extern OS_ID     _os_tmr_kill (U32 p, OS_ID timer)                     __svc_indirect(0); 
 
  
extern void      rt_tsk_lock   (void); 
extern void      rt_tsk_unlock (void); 
 
 
 
 
extern void      _os_tsk_lock (U32 p)                                  __svc_indirect(0); 
extern void      _os_tsk_unlock (U32 p)                                __svc_indirect(0); 
 
  
extern int       _init_box (void *box_mem, U32 box_size, U32 blk_size); 
extern void     *_alloc_box (void *box_mem); 
extern void     *_calloc_box (void *box_mem); 
extern int       _free_box (void *box_mem, void *box); 
 
 
 
 
 
 
 
 
 
 
  
 
typedef struct {                          
   U8  hr;                                
   U8  min;                               
   U8  sec;                               
   U8  day;                               
   U8  mon;                               
   U16 year;                              
} RL_TIME; 
 
typedef struct {                          
   S8  name[256];                         
   U32 size;                              
   U16 fileID;                            
   U8  attrib;                            
   RL_TIME time;                          
} FINFO; 
 
extern int finit (void); 
extern int fdelete (const char *filename); 
extern int frename (const char *oldname, const char *newname); 
extern int ffind (const char *pattern, FINFO *info); 
extern U32 ffree (const char *drive); 
extern int fformat (const char *drive); 
extern int fanalyse (const char *drive); 
extern int fcheck (const char *drive); 
extern int fdefrag (const char *drive); 
 
  
 
 
 
 
  
 
  
 
 
 
  
 
 
 
 
  
#line 391 "C:\\Keil\\\\ARM\\RV31\\INC\\RTL.h" 
 
  
#line 404 "C:\\Keil\\\\ARM\\RV31\\INC\\RTL.h" 
 
  
 
 
 
 
 
  
#line 418 "C:\\Keil\\\\ARM\\RV31\\INC\\RTL.h" 
 
  
 
 
 
 
  
 
 
 
extern void init_TcpNet (void); 
extern void main_TcpNet (void); 
extern void timer_tick (void); 
extern U8   udp_get_socket (U8 tos, U8 opt,  
                            U16 (*listener)(U8 socket, U8 *remip, U16 port, U8 *buf, U16 len)); 
extern BOOL udp_release_socket (U8 socket); 
extern BOOL udp_open (U8 socket, U16 locport); 
extern BOOL udp_close (U8 socket); 
extern BOOL udp_mcast_ttl (U8 socket, U8 ttl); 
extern U8  *udp_get_buf (U16 size); 
extern BOOL udp_send (U8 socket, U8 *remip, U16 remport, 
                      U8 *buf,   U16 dlen); 
extern U8   tcp_get_socket (U8 type, U8 tos, U16 tout, 
                            U16 (*listener)(U8 socket, U8 event, U8 *buf, U16 len)); 
extern BOOL tcp_release_socket (U8 socket); 
extern BOOL tcp_listen (U8 socket, U16 locport); 
extern BOOL tcp_connect (U8 socket, U8 *remip, U16 remport, U16 locport); 
extern U8  *tcp_get_buf (U16 size); 
extern U16  tcp_max_dsize (U8 socket); 
extern BOOL tcp_check_send (U8 socket); 
extern U8   tcp_get_state (U8 socket); 
extern BOOL tcp_send (U8 socket, U8 *buf, U16 dlen); 
extern BOOL tcp_close (U8 socket); 
extern BOOL tcp_abort (U8 socket); 
extern void tcp_reset_window (U8 socket); 
extern BOOL arp_cache_ip (U8 *ipadr, U8 type); 
extern void ppp_listen (char const *user, char const *passw); 
extern void ppp_connect (char const *dialnum, char const *user, char const *passw); 
extern void ppp_close (void); 
extern BOOL ppp_is_up (void); 
extern void slip_listen (void); 
extern void slip_connect (char const *dialnum); 
extern void slip_close (void); 
extern BOOL slip_is_up (void); 
extern U8   get_host_by_name (U8 *hostn, void (*cbfunc)(U8 event, U8 *host_ip)); 
extern BOOL smtp_connect (U8 *ipadr, U16 port, void (*cbfunc)(U8 event)); 
extern void dhcp_disable (void); 
extern BOOL igmp_join (U8 *group_ip); 
extern BOOL igmp_leave (U8 *group_ip); 
 
 
 
 
 
 
  
   
 
  
#line 16 "C:\\Keil\\\\ARM\\RV31\\INC\\File_Config.h" 
 
  
 
 
 
 
 
 
  
 
 
 
  
 
 
  
typedef struct DevConf { 
   U32 bStart; 
   U32 bEnd; 
} DEVCONF; 
 
  
typedef struct iob { 
   U16   fileID;                          
   U16   flags;                           
   U8    drive;                           
   U8    attrib;                          
   U16   NumSect;                         
   U32   InitVal;                         
   void *DevCfg;                          
   U16   _fblock;                         
   U16   _fidx;                           
   U32   _fbot;                           
   U32   _ftop;                           
   U32   _firstClus;                      
   U32   _lastEntClus;                    
   U8    _currDatSect;                    
   U32   _currDatClus;                    
   U32   fsize;                           
   U32   fpos;                            
} IOB; 
 
  
 
  
#line 69 "C:\\Keil\\\\ARM\\RV31\\INC\\File_Config.h" 
 
  
 
 
 
 
  
typedef struct falloc { 
   U32 end; 
   U16 fileID; 
   U16 index; 
} FALLOC; 
 
  
typedef struct fdbuf { 
   U16 index; 
   U16 fblock; 
   U32 fbot; 
   U32 ftop; 
} FDBUF; 
 
  
typedef struct fatinfo { 
   U32 BootRecSec;                        
   U8  FatType;                           
   U8  NumOfFat;                          
   U8  SecPerClus;                        
   U16 FatSize;                           
   U16 RsvdSecCnt;                        
   U32 DskSize;                           
   U32 DataSecCnt;                        
   U16 RootEntCnt;                        
   U16 BytesPerSec;                       
   U32 DataClusCnt;                       
   U16 RootDirAddr;                       
   U16 RootSecCnt;                        
   U32 ClusSize;                          
   U16 EntsPerClus;                       
                                          
   U16 FAT32_ExtFlags;                    
   U32 FAT32_RootClus;                    
   U16 FAT32_FSInfo;                      
   U16 FAT32_BkBootSec;                   
} FATINFO; 
 
  
typedef struct filerec { 
   U8  FileName[11];                      
   U8  Attr;                              
   U8  NTRsvd;                            
   U8  CrtTimeTenth;                      
   U16 CrtTime;                           
   U16 CrtDate;                           
   U16 LastAccDate;                       
   U16 FirstClusHI;                       
   U16 WriteTime;                         
   U16 WriteDate;                         
   U16 FirstClusLO;                       
   U32 FileSize;                          
} FILEREC; 
 
  
typedef struct lfn_filerec { 
   U8  Ordinal;                           
   U8  Unichar0[10];                      
   U8  Attr;                              
   U8  Rsvd;                              
   U8  Checksum;                          
   U8  Unichar1[12];                      
   U16 FirstClusLO;                       
   U8  Unichar2[4];                       
} LFN_FILEREC; 
 
 
 
  
typedef struct devpar { 
   U8  FatType;                           
   U8  SecClus;                           
   U8  SecClus32;                         
   U16 NumHeads;                          
   U8  NumSect;                           
   U16 NumCyl;                            
   U16 BootRecSec;                        
} DEVPAR; 
 
  
#line 164 "C:\\Keil\\\\ARM\\RV31\\INC\\File_Config.h" 
 
  
 
 
  
 
 
 
 
 
  
 
 
 
 
 
 
  
typedef struct fcache { 
   U32 sect; 
   U8  *buf; 
   BIT dirty; 
} FCACHE; 
 
  
typedef struct dcache { 
   U32 sect; 
   U32 csect; 
   U8  *buf; 
   U8  *cbuf; 
   U8  nwr; 
   U8  nrd; 
} DCACHE; 
 
  
typedef struct mmcfg { 
   U32 sernum; 
   U32 blocknr; 
   U16 read_blen; 
   U16 write_blen; 
} MMCFG; 
 
  
extern struct iob _iob[]; 
extern U32    mc_cache[]; 
 
  
extern struct DevConf const FlashDev []; 
extern struct DevConf const SpiDev[]; 
extern struct DevConf const RamDev []; 
extern U16 const _FlashNumSect; 
extern U16 const _SpiNumSect; 
extern U16 const _RamNumSect; 
extern U32 const _BlockFREE; 
extern U32 const _SpiBlFREE; 
extern U16 const _NFILE; 
extern U16 const _DEF_DRIVE; 
extern U16 const _MC_CSIZE; 
 
  
extern int  _fdelete (IOB *fcb); 
extern int  _fcreate (const char *fname, IOB *fcb); 
extern int  _frename (const char *filename, IOB *fcb); 
extern BOOL _ffind (FINFO *info, IOB *fcb); 
 
  
extern int  __fopen (const char *fname, int openmode); 
extern int  __fclose (int handle); 
extern int  __write (int handle, const U8 *buf, U32 len); 
extern int  __flushbuf (int handle); 
extern int  __read (int handle, U8 *buf, U32 len); 
extern int  __setfpos (int handle, U32 pos); 
extern U32  __getfsize (IOB *fcb, BOOL set_fidx); 
 
 
  
extern U16  fs_get_freeID (U32 maxID, IOB *fcb); 
extern U32  fs_get_freeMem (U32 block, IOB *fcb); 
extern BOOL fs_check_fwopen (U32 block, IOB *fcb); 
extern void fs_mark_freeMem (IOB *fcb); 
extern BOOL fs_mark_fileMem (IOB *fcb); 
extern U32  fs_Find_File (const char *name, IOB *fcb); 
extern BOOL fs_BlockFull (IOB *fcb); 
extern BOOL fs_AllocBlock (IOB *fcb); 
extern BOOL fs_BlockInvalid (U32 block, IOB *fcb); 
extern BOOL fs_InitBlock (U32 block, IOB *fcb); 
extern BOOL fs_WriteBlock (U32 adr, void *buf, U32 cnt, IOB *fcb); 
extern BOOL fs_ReadBlock (U32 adr, void *buf, U32 cnt, IOB *fcb); 
extern U32  fs_adr_sig (U32 bl, IOB *fcb); 
extern U32  fs_rd_alloc (U32 adr, FALLOC *fa); 
extern U32  fs_rd_sig (U32 adr, U32 *sig); 
 
  
extern BOOL fn_cmp (const char *sp, const char *fp); 
extern int  fs_strpos (const char *sp, const char ch); 
extern int  fs_get_drive (const char *fn); 
extern int  fs_find_iob (void); 
extern BOOL fs_set_params (IOB *fcb); 
extern int  fs_ReadData (U32 adr, U32 cnt, U8 *buf); 
extern int  fs_WriteData (U32 adr, U32 cnt, U8 *buf); 
 
  
extern int  fs_Init (U32 adr, U32 clk); 
extern int  fs_EraseSector (U32 adr); 
extern int  fs_ProgramPage (U32 adr, U32 sz, U8 *buf); 
 
  
extern int  fs_spi_Init (void); 
extern int  fs_spi_EraseSector (U32 adr); 
extern int  fs_spi_ProgramPage (U32 adr, U32 sz, U8 *buf); 
extern int  fs_spi_ReadData (U32 adr, U32 sz, U8 *buf); 
 
  
extern int  fat_init (void); 
extern BOOL fat_find_file (const char *fn, IOB *fcb); 
extern BOOL fat_set_fpos (IOB *fcb, U32 pos); 
extern U32  fat_read (IOB *fcb, U8 *buf, U32 len); 
extern BOOL fat_write (IOB *fcb, const U8 *buf, U32 len); 
extern U32  fat_free (void); 
extern BOOL fat_delete (const char *fn, IOB *fcb); 
extern BOOL fat_close_write (IOB *fcb); 
extern BOOL fat_rename (const char *old, const char *new, IOB *fcb); 
extern BOOL fat_create (const char *fn, IOB *fcb); 
extern BOOL fat_format (const char *label); 
extern BOOL fat_ffind  (const char *fn, FINFO *info, IOB *fcb); 
 
  
extern BOOL mmc_init (void); 
extern BOOL mmc_write_sect (U32 sect, U8 *buf, U32 cnt); 
extern BOOL mmc_read_sect (U32 sect, U8 *buf, U32 cnt); 
extern BOOL mmc_read_config (MMCFG *cfg); 
 
  
extern U32  fs_get_time (void); 
extern U32  fs_get_date (void); 
 
  
extern void spi_init (void); 
extern U8   spi_send (U8 outb); 
extern void spi_ss (U32 ss); 
extern void spi_hi_speed (BOOL on); 
extern void spi_command (U8 *cmd, U8 *tbuf, U8 *rbuf, U32 sz); 
 
  
#line 315 "C:\\Keil\\\\ARM\\RV31\\INC\\File_Config.h" 
 
  
__weak void _mutex_acquire (int *mutex); 
__weak void _mutex_release (int *mutex); 
__weak int  _stream_list_lock; 
#line 14 "SPI_LPC17xx.c" 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
  
 
void spi_init (void) { 
     
 
  ((LPC_SC_TypeDef *) ((0x40080000UL) + 0x7C000) )->PCONP        |= (1 << 21);            
 
    
  ((LPC_GPIO_TypeDef *) ((0x2009C000UL) + 0x00000) )->FIODIR  |=  (1<<16);               
  ((LPC_GPIO_TypeDef *) ((0x2009C000UL) + 0x00000) )->FIOPIN  |=  (1<<16);               
  ((LPC_PINCON_TypeDef *) ((0x40000000UL) + 0x2C000) )->PINSEL1 &= ~(3<<0);               
 
    
  ((LPC_PINCON_TypeDef *) ((0x40000000UL) + 0x2C000) )->PINSEL0 &= ~(3UL<<30);            
  ((LPC_PINCON_TypeDef *) ((0x40000000UL) + 0x2C000) )->PINSEL0 |=  (2UL<<30);            
  ((LPC_PINCON_TypeDef *) ((0x40000000UL) + 0x2C000) )->PINSEL1 &= ~((3<<2) | (3<<4));    
  ((LPC_PINCON_TypeDef *) ((0x40000000UL) + 0x2C000) )->PINSEL1 |=  ((2<<2) | (2<<4));    
 
  ((LPC_SC_TypeDef *) ((0x40080000UL) + 0x7C000) )->PCLKSEL1 &= ~(3<<10);                 
  ((LPC_SC_TypeDef *) ((0x40080000UL) + 0x7C000) )->PCLKSEL1 |=  (1<<10);                 
 
  ((LPC_SSP_TypeDef *) ((0x40080000UL) + 0x08000) )->CPSR = 180;                         
                                                    
  ((LPC_SSP_TypeDef *) ((0x40080000UL) + 0x08000) )->CR0  = 0x0007;                      
  ((LPC_SSP_TypeDef *) ((0x40080000UL) + 0x08000) )->CR1  = 0x0002;                      
} 
 
 
  
 
void spi_hi_speed (BOOL on) { 
     
 
   if (on == 1) { 
        
    ((LPC_SSP_TypeDef *) ((0x40080000UL) + 0x08000) )->CPSR =   6;                       
   } 
   else { 
        
    ((LPC_SSP_TypeDef *) ((0x40080000UL) + 0x08000) )->CPSR = 180;                       
   } 
} 
 
 
  
 
void spi_ss (U32 ss) { 
     
 
  if (ss) { 
    ((LPC_GPIO_TypeDef *) ((0x2009C000UL) + 0x00000) )->FIOPIN |= (1<<16);               
  } else { 
    ((LPC_GPIO_TypeDef *) ((0x2009C000UL) + 0x00000) )->FIOPIN &= ~(1<<16);              
  } 
} 
 
 
  
 
U8 spi_send (U8 outb) { 
     
 
  ((LPC_SSP_TypeDef *) ((0x40080000UL) + 0x08000) )->DR = outb; 
  while (((LPC_SSP_TypeDef *) ((0x40080000UL) + 0x08000) )->SR & 0x10);                   
  return (((LPC_SSP_TypeDef *) ((0x40080000UL) + 0x08000) )->DR);                        
 
}