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


#line 1 "SD_File.c" 
 
 
 
 
 
  
 
#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 9 "SD_File.c" 
 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\ctype.h" 
  
  
  
  
 
 
 
 
 
  
 
 
 
 
 
 
  
 
 
 
 
 
 
 
#line 32 "C:\\Keil\\\\ARM\\RV31\\INC\\ctype.h" 
 
 
 
 
 
 
#line 46 "C:\\Keil\\\\ARM\\RV31\\INC\\ctype.h" 
 
  
#line 56 "C:\\Keil\\\\ARM\\RV31\\INC\\ctype.h" 
 
  
  
 
 
 
 
 
 
 
 
 
  
#line 78 "C:\\Keil\\\\ARM\\RV31\\INC\\ctype.h" 
 
 
 
 
 
#line 130 "C:\\Keil\\\\ARM\\RV31\\INC\\ctype.h" 
 
extern __declspec(__nothrow) __pure unsigned char **__rt_ctype_table(void); 
 
 
 
 
 
 
 
    extern int (isalnum)(int  ); 
 
      
 
 
 
 
 
    extern int (isalpha)(int  ); 
 
      
 
 
 
 
 
    extern int (iscntrl)(int  ); 
 
      
      
 
  
 
 
 
 
    extern int (isdigit)(int  ); 
 
      
 
    extern int (isblank)(int  ); 
      
      
      
 
 
 
 
 
    extern int (isgraph)(int  ); 
 
      
 
 
 
 
 
    extern int (islower)(int  ); 
 
      
 
 
 
 
 
    extern int (isprint)(int  ); 
 
      
      
 
 
 
 
 
    extern int (ispunct)(int  ); 
 
      
 
 
 
 
 
    extern int (isspace)(int  ); 
 
      
 
 
 
 
 
    extern int (isupper)(int  ); 
 
      
 
  
  
 
__inline int __isxdigit_helper(int __t) { return (__t ^ (__t << 2)); } 
 
 
 
 
    extern int (isxdigit)(int  ); 
 
      
 
 
 
extern int tolower(int  ); 
      
      
 
extern int toupper(int  ); 
      
      
 
 
 
 
 
 
 
#line 269 "C:\\Keil\\\\ARM\\RV31\\INC\\ctype.h" 
 
 
 
  
#line 11 "SD_File.c" 
 
 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\stdio.h" 
  
  
  
 
 
 
 
 
  
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
#line 34 "C:\\Keil\\\\ARM\\RV31\\INC\\stdio.h" 
 
 
   
  typedef unsigned int size_t;     
 
 
 
 
 
 
 
 
  
  
 
  
  typedef struct __va_list __va_list; 
 
 
 
 
 
    
 
 
 
 
  
 
 
 
 
typedef struct __fpos_t_struct { 
    unsigned __int64 __pos; 
     
 
 
 
  
    struct { 
        unsigned int __state1, __state2; 
    } __mbstate; 
} fpos_t; 
    
 
 
  
 
 
    
 
  
 
typedef struct __FILE FILE; 
    
 
 
 
 
 
 
  
 
extern FILE __stdin, __stdout, __stderr; 
extern FILE *__aeabi_stdin, *__aeabi_stdout, *__aeabi_stderr; 
 
#line 125 "C:\\Keil\\\\ARM\\RV31\\INC\\stdio.h" 
     
 
     
 
     
 
 
 
 
 
      
 
 
 
    
 
 
  
 
 
    
 
 
  
 
    
 
 
 
  
 
    
 
 
  
 
 
 
 
    
 
 
  
 
 
 
 
 
     
 
 
  
 
 
 
 
 
 
extern __declspec(__nothrow) int remove(const char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
  
extern __declspec(__nothrow) int rename(const char *  , const char *  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) FILE *tmpfile(void); 
    
 
 
 
 
  
extern __declspec(__nothrow) char *tmpnam(char *  ); 
    
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) int fclose(FILE *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int fflush(FILE *  ); 
    
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) FILE *fopen(const char * __restrict  , 
                           const char * __restrict  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) FILE *freopen(const char * __restrict  , 
                    const char * __restrict  , 
                    FILE * __restrict  ) __attribute__((__nonnull__(2,3))); 
    
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) void setbuf(FILE * __restrict  , 
                    char * __restrict  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
  
extern __declspec(__nothrow) int setvbuf(FILE * __restrict  , 
                   char * __restrict  , 
                   int  , size_t  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
#pragma __printf_args 
extern __declspec(__nothrow) int fprintf(FILE * __restrict  , 
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
#pragma __printf_args 
extern __declspec(__nothrow) int _fprintf(FILE * __restrict  , 
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2))); 
    
 
 
 
  
#pragma __printf_args 
extern __declspec(__nothrow) int printf(const char * __restrict  , ...) __attribute__((__nonnull__(1))); 
    
 
 
 
 
  
#pragma __printf_args 
extern __declspec(__nothrow) int _printf(const char * __restrict  , ...) __attribute__((__nonnull__(1))); 
    
 
 
 
  
#pragma __printf_args 
extern __declspec(__nothrow) int sprintf(char * __restrict  , const char * __restrict  , ...) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
  
#pragma __printf_args 
extern __declspec(__nothrow) int _sprintf(char * __restrict  , const char * __restrict  , ...) __attribute__((__nonnull__(1,2))); 
    
 
 
 
  
 
#pragma __printf_args 
extern __declspec(__nothrow) int snprintf(char * __restrict  , size_t  , 
                     const char * __restrict  , ...) __attribute__((__nonnull__(3))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
#pragma __printf_args 
extern __declspec(__nothrow) int _snprintf(char * __restrict  , size_t  , 
                      const char * __restrict  , ...) __attribute__((__nonnull__(3))); 
    
 
 
 
  
#pragma __scanf_args 
extern __declspec(__nothrow) int fscanf(FILE * __restrict  , 
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
#pragma __scanf_args 
extern __declspec(__nothrow) int _fscanf(FILE * __restrict  , 
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2))); 
    
 
 
 
  
#pragma __scanf_args 
extern __declspec(__nothrow) int scanf(const char * __restrict  , ...) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
  
#pragma __scanf_args 
extern __declspec(__nothrow) int _scanf(const char * __restrict  , ...) __attribute__((__nonnull__(1))); 
    
 
 
 
  
#pragma __scanf_args 
extern __declspec(__nothrow) int sscanf(const char * __restrict  , 
                    const char * __restrict  , ...) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
  
#pragma __scanf_args 
extern __declspec(__nothrow) int _sscanf(const char * __restrict  , 
                     const char * __restrict  , ...) __attribute__((__nonnull__(1,2))); 
    
 
 
 
  
 
  
extern __declspec(__nothrow) int vfscanf(FILE * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) int vscanf(const char * __restrict  , __va_list) __attribute__((__nonnull__(1))); 
extern __declspec(__nothrow) int vsscanf(const char * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2))); 
 
extern __declspec(__nothrow) int _vfscanf(FILE * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) int _vscanf(const char * __restrict  , __va_list) __attribute__((__nonnull__(1))); 
extern __declspec(__nothrow) int _vsscanf(const char * __restrict  , const char * __restrict  , __va_list) __attribute__((__nonnull__(1,2))); 
 
extern __declspec(__nothrow) int vprintf(const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
  
extern __declspec(__nothrow) int _vprintf(const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1))); 
    
 
 
 
  
extern __declspec(__nothrow) int vfprintf(FILE * __restrict  , 
                    const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
  
extern __declspec(__nothrow) int vsprintf(char * __restrict  , 
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) int vsnprintf(char * __restrict  , size_t  , 
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(3))); 
    
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) int _vsprintf(char * __restrict  , 
                      const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
  
extern __declspec(__nothrow) int _vfprintf(FILE * __restrict  , 
                     const char * __restrict  , __va_list  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
  
extern __declspec(__nothrow) int _vsnprintf(char * __restrict  , size_t  , 
                      const char * __restrict  , __va_list  ) __attribute__((__nonnull__(3))); 
    
 
 
 
  
extern __declspec(__nothrow) int fgetc(FILE *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) char *fgets(char * __restrict  , int  , 
                    FILE * __restrict  ) __attribute__((__nonnull__(1,3))); 
    
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int fputc(int  , FILE *  ) __attribute__((__nonnull__(2))); 
    
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int fputs(const char * __restrict  , FILE * __restrict  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
  
extern __declspec(__nothrow) int getc(FILE *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
  
 
 
 
 
    extern __declspec(__nothrow) int (getchar)(void); 
 
    
 
 
 
 
 
  
extern __declspec(__nothrow) char *gets(char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int putc(int  , FILE *  ) __attribute__((__nonnull__(2))); 
    
 
 
 
 
 
  
 
 
 
 
    extern __declspec(__nothrow) int (putchar)(int  ); 
 
    
 
 
 
  
extern __declspec(__nothrow) int puts(const char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
  
extern __declspec(__nothrow) int ungetc(int  , FILE *  ) __attribute__((__nonnull__(2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) size_t fread(void * __restrict  , 
                    size_t  , size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,4))); 
    
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) size_t __fread_bytes_avail(void * __restrict  , 
                    size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,3))); 
    
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) size_t fwrite(const void * __restrict  , 
                    size_t  , size_t  , FILE * __restrict  ) __attribute__((__nonnull__(1,4))); 
    
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) int fgetpos(FILE * __restrict  , fpos_t * __restrict  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int fseek(FILE *  , long int  , int  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int fsetpos(FILE * __restrict  , const fpos_t * __restrict  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) long int ftell(FILE *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) void rewind(FILE *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
  
 
extern __declspec(__nothrow) void clearerr(FILE *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
  
 
extern __declspec(__nothrow) int feof(FILE *  ) __attribute__((__nonnull__(1))); 
    
 
 
  
extern __declspec(__nothrow) int ferror(FILE *  ) __attribute__((__nonnull__(1))); 
    
 
 
  
extern __declspec(__nothrow) void perror(const char *  ); 
    
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) int _fisatty(FILE *   ) __attribute__((__nonnull__(1))); 
     
  
 
extern __declspec(__nothrow) void __use_no_semihosting_swi(void); 
extern __declspec(__nothrow) void __use_no_semihosting(void); 
     
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
#line 944 "C:\\Keil\\\\ARM\\RV31\\INC\\stdio.h" 
 
 
 
  
#line 14 "SD_File.c" 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
  
  
  
 
 
 
 
  
  
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
   
 
 
  
 
 
 
 
 
 
 
 
#line 45 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
 
 
   
  typedef unsigned int size_t; 
 
 
 
 
 
 
 
 
 
 
     
 
 
 
    typedef unsigned short wchar_t;   
#line 74 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
 
typedef struct div_t { int quot, rem; } div_t; 
     
typedef struct ldiv_t { long int quot, rem; } ldiv_t; 
     
 
typedef struct lldiv_t { __int64 quot, rem; } lldiv_t; 
     
 
 
#line 95 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
    
 
 
 
  
 
    
 
 
 
 
  
#line 114 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
    
 
 
  
extern __declspec(__nothrow) int __aeabi_MB_CUR_MAX(void); 
 
    
 
 
 
 
  
 
    
 
 
 
 
  
 
 
 
 
extern __declspec(__nothrow) double atof(const char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
  
extern __declspec(__nothrow) int atoi(const char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
  
extern __declspec(__nothrow) long int atol(const char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
  
 
extern __declspec(__nothrow) __int64 atoll(const char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
  
 
 
extern __declspec(__nothrow) double strtod(const char * __restrict  , char ** __restrict  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) float strtof(const char * __restrict  , char ** __restrict  ) __attribute__((__nonnull__(1))); 
extern __declspec(__nothrow) long double strtold(const char * __restrict  , char ** __restrict  ) __attribute__((__nonnull__(1))); 
    
 
  
 
extern __declspec(__nothrow) long int strtol(const char * __restrict  , 
                        char ** __restrict  , int  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) unsigned long int strtoul(const char * __restrict  , 
                                       char ** __restrict  , int  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
  
extern __declspec(__nothrow) __int64 strtoll(const char * __restrict  , 
                               char ** __restrict  , int  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
  
extern __declspec(__nothrow) unsigned __int64 strtoull(const char * __restrict  , 
                                         char ** __restrict  , int  ) __attribute__((__nonnull__(1))); 
    
 
 
 
  
 
extern __declspec(__nothrow) int rand(void); 
    
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) void srand(unsigned int  ); 
    
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) void *calloc(size_t  , size_t  ); 
    
 
 
 
  
extern __declspec(__nothrow) void free(void *  ); 
    
 
 
 
 
 
  
extern __declspec(__nothrow) void *malloc(size_t  ); 
    
 
 
 
  
extern __declspec(__nothrow) void *realloc(void *  , size_t  ); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
  
typedef int (*__heapprt)(void *, char const *, ...); 
extern __declspec(__nothrow) void __heapstats(int (*  )(void *  , 
                                           char const *  , ...), 
                        void *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int __heapvalid(int (*  )(void *  , 
                                           char const *  , ...), 
                       void *  , int  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) __declspec(__noreturn) void abort(void); 
    
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) int atexit(void (*  )(void)) __attribute__((__nonnull__(1))); 
    
 
 
 
 
  
#line 389 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
 
 
extern __declspec(__nothrow) __declspec(__noreturn) void exit(int  ); 
    
 
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) __declspec(__noreturn) void _Exit(int  ); 
    
 
 
 
 
 
 
 
       
 
extern __declspec(__nothrow) char *getenv(const char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) int  system(const char *  ); 
    
 
 
 
 
 
 
 
 
 
  
 
extern  void *bsearch(const void *  , const void *  , 
              size_t  , size_t  , 
              int (*  )(const void *, const void *)) __attribute__((__nonnull__(1,2,5))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
  
#line 477 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
 
 
extern  void qsort(void *  , size_t  , size_t  , 
           int (*  )(const void *, const void *)) __attribute__((__nonnull__(1,4))); 
    
 
 
 
 
 
 
 
 
 
  
 
#line 506 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
 
extern __declspec(__nothrow) __pure int abs(int  ); 
    
 
 
 
  
 
extern __declspec(__nothrow) __pure div_t div(int  , int  ); 
    
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) __pure long int labs(long int  ); 
    
 
 
 
  
 
 
 
 
extern __declspec(__nothrow) __pure ldiv_t ldiv(long int  , long int  ); 
    
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
extern __declspec(__nothrow) __pure __int64 llabs(__int64  ); 
    
 
 
 
  
 
 
 
 
extern __declspec(__nothrow) __pure lldiv_t lldiv(__int64  , __int64  ); 
    
 
 
 
 
 
 
 
 
 
 
 
  
#line 587 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
 
 
 
  
typedef struct __sdiv32by16 { int quot, rem; } __sdiv32by16; 
typedef struct __udiv32by16 { unsigned int quot, rem; } __udiv32by16; 
     
typedef struct __sdiv64by32 { int rem, quot; } __sdiv64by32; 
 
__value_in_regs extern __declspec(__nothrow) __pure __sdiv32by16 __rt_sdiv32by16( 
     int  , 
     short int  ); 
    
 
  
__value_in_regs extern __declspec(__nothrow) __pure __udiv32by16 __rt_udiv32by16( 
     unsigned int  , 
     unsigned short  ); 
    
 
  
__value_in_regs extern __declspec(__nothrow) __pure __sdiv64by32 __rt_sdiv64by32( 
     int  , unsigned int  , 
     int  ); 
    
 
  
 
 
 
  
extern __declspec(__nothrow) unsigned int __fp_status(unsigned int  , unsigned int  ); 
    
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int mblen(const char *  , size_t  ); 
    
 
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int mbtowc(wchar_t * __restrict  , 
                   const char * __restrict  , size_t  ); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) int wctomb(char *  , wchar_t  ); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
  
extern __declspec(__nothrow) size_t mbstowcs(wchar_t * __restrict  , 
                      const char * __restrict  , size_t  ) __attribute__((__nonnull__(2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) size_t wcstombs(char * __restrict  , 
                      const wchar_t * __restrict  , size_t  ) __attribute__((__nonnull__(2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) void __use_realtime_heap(void); 
extern __declspec(__nothrow) void __use_realtime_division(void); 
extern __declspec(__nothrow) void __use_two_region_memory(void); 
extern __declspec(__nothrow) void __use_no_heap(void); 
extern __declspec(__nothrow) void __use_no_heap_region(void); 
 
extern __declspec(__nothrow) char const *__C_library_version_string(void); 
extern __declspec(__nothrow) int __C_library_version_number(void); 
 
 
 
 
 
 
 
 
 
 
 
#line 832 "C:\\Keil\\\\ARM\\RV31\\INC\\stdlib.h" 
 
 
  
#line 15 "SD_File.c" 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\string.h" 
  
  
  
  
 
 
 
 
  
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
#line 37 "C:\\Keil\\\\ARM\\RV31\\INC\\string.h" 
 
 
   
  typedef unsigned int size_t; 
 
 
 
 
 
 
 
 
extern __declspec(__nothrow) void *memcpy(void * __restrict  , 
                    const void * __restrict  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
  
extern __declspec(__nothrow) void *memmove(void *  , 
                    const void *  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
  
extern __declspec(__nothrow) char *strcpy(char * __restrict  , const char * __restrict  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
  
extern __declspec(__nothrow) char *strncpy(char * __restrict  , const char * __restrict  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
  
 
extern __declspec(__nothrow) char *strcat(char * __restrict  , const char * __restrict  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
  
extern __declspec(__nothrow) char *strncat(char * __restrict  , const char * __restrict  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
  
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) int memcmp(const void *  , const void *  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
  
extern __declspec(__nothrow) int strcmp(const char *  , const char *  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
  
extern __declspec(__nothrow) int strncmp(const char *  , const char *  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
  
extern __declspec(__nothrow) int strcasecmp(const char *  , const char *  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
  
extern __declspec(__nothrow) int strncasecmp(const char *  , const char *  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
  
extern __declspec(__nothrow) int strcoll(const char *  , const char *  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) size_t strxfrm(char * __restrict  , const char * __restrict  , size_t  ) __attribute__((__nonnull__(2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
#line 184 "C:\\Keil\\\\ARM\\RV31\\INC\\string.h" 
extern __declspec(__nothrow) void *memchr(const void *  , int  , size_t  ) __attribute__((__nonnull__(1))); 
 
    
 
 
 
 
 
  
 
#line 200 "C:\\Keil\\\\ARM\\RV31\\INC\\string.h" 
extern __declspec(__nothrow) char *strchr(const char *  , int  ) __attribute__((__nonnull__(1))); 
 
    
 
 
 
 
  
 
extern __declspec(__nothrow) size_t strcspn(const char *  , const char *  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
  
 
#line 223 "C:\\Keil\\\\ARM\\RV31\\INC\\string.h" 
extern __declspec(__nothrow) char *strpbrk(const char *  , const char *  ) __attribute__((__nonnull__(1,2))); 
 
    
 
 
 
 
  
 
#line 238 "C:\\Keil\\\\ARM\\RV31\\INC\\string.h" 
extern __declspec(__nothrow) char *strrchr(const char *  , int  ) __attribute__((__nonnull__(1))); 
 
    
 
 
 
 
 
  
 
extern __declspec(__nothrow) size_t strspn(const char *  , const char *  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
  
 
#line 261 "C:\\Keil\\\\ARM\\RV31\\INC\\string.h" 
extern __declspec(__nothrow) char *strstr(const char *  , const char *  ) __attribute__((__nonnull__(1,2))); 
 
    
 
 
 
 
 
  
 
extern __declspec(__nothrow) char *strtok(char * __restrict  , const char * __restrict  ) __attribute__((__nonnull__(2))); 
extern __declspec(__nothrow) char *_strtok_r(char *  , const char *  , char **  ) __attribute__((__nonnull__(2,3))); 
 
extern __declspec(__nothrow) char *strtok_r(char *  , const char *  , char **  ) __attribute__((__nonnull__(2,3))); 
 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) void *memset(void *  , int  , size_t  ) __attribute__((__nonnull__(1))); 
    
 
 
 
  
extern __declspec(__nothrow) char *strerror(int  ); 
    
 
 
 
 
 
  
extern __declspec(__nothrow) size_t strlen(const char *  ) __attribute__((__nonnull__(1))); 
    
 
 
 
  
 
extern __declspec(__nothrow) size_t strlcpy(char *  , const char *  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) size_t strlcat(char *  , const char *  , size_t  ) __attribute__((__nonnull__(1,2))); 
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
extern __declspec(__nothrow) void _membitcpybl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitcpybb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitcpyhl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitcpyhb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitcpywl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitcpywb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitmovebl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitmovebb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitmovehl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitmovehb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitmovewl(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
extern __declspec(__nothrow) void _membitmovewb(void *  , const void *  , int  , int  , size_t  ) __attribute__((__nonnull__(1,2))); 
     
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
#line 493 "C:\\Keil\\\\ARM\\RV31\\INC\\string.h" 
 
 
 
  
#line 16 "SD_File.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 19 "SD_File.c" 
 
#line 1 "C:\\Keil\\\\ARM\\RV31\\INC\\File_Config.h" 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
#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 21 "SD_File.c" 
#line 1 "SD_File.h" 
 
 
 
 
 
 
 
 
 
  
 
#line 19 "SD_File.h" 
 
  
typedef struct scmd { 
   char val[8]; 
   void (*func)(char *par); 
} SCMD; 
 
  
extern BOOL getline (char *, U32); 
extern void init_serial (void); 
extern int  getkey (void); 
 
 
 
  
#line 22 "SD_File.c" 
#line 1 "Serial.h" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
extern void SER_init      (int uart); 
extern int  SER_getChar   (int uart); 
extern int  SER_getChar_nb(int uart); 
extern int  SER_putChar   (int uart, int c); 
extern void SER_putString (int uart, unsigned char *s); 
 
#line 23 "SD_File.c" 
 
 
  
static void cmd_capture (char *par); 
static void cmd_type (char *par); 
static void cmd_rename (char *par); 
static void cmd_copy (char *par); 
static void cmd_delete (char *par); 
static void cmd_dir (char *par); 
static void cmd_format (char *par); 
static void cmd_help (char *par); 
static void cmd_fill (char *par); 
 
  
static const char intro[] = 
   "\n\n\n\n\n\n\n\n" 
   "+-----------------------------------------------------------------------+\n" 
   "|                SD/MMC Card File Manipulation example                  |\n"; 
static const char help[] =  
   "+ command ------------------+ function ---------------------------------+\n" 
   "| CAP \"fname\" [/A]          | captures serial data to a file            |\n" 
   "|                           |  [/A option appends data to a file]       |\n" 
   "| FILL \"fname\" [nnnn]       | create a file filled with text            |\n" 
   "|                           |  [nnnn - number of lines, default=1000]   |\n" 
   "| TYPE \"fname\"              | displays the content of a text file       |\n" 
   "| REN \"fname1\" \"fname2\"     | renames a file 'fname1' to 'fname2'       |\n" 
   "| COPY \"fin\" [\"fin2\"] \"fout\"| copies a file 'fin' to 'fout' file        |\n" 
   "|                           |  ['fin2' option merges 'fin' and 'fin2']  |\n" 
   "| DEL \"fname\"               | deletes a file                            |\n" 
   "| DIR \"[mask]\"              | displays a list of files in the directory |\n" 
   "| FORMAT [label [/FAT32]]   | formats Flash Memory Card                 |\n" 
   "|                           | [/FAT32 option selects FAT32 file system] |\n" 
   "| HELP  or  ?               | displays this help                        |\n" 
   "+---------------------------+-------------------------------------------+\n"; 
 
static const SCMD cmd[] = { 
   "CAP",    cmd_capture, 
   "TYPE",   cmd_type, 
   "REN",    cmd_rename, 
   "COPY",   cmd_copy, 
   "DEL",    cmd_delete, 
   "DIR",    cmd_dir, 
   "FORMAT", cmd_format, 
   "HELP",   cmd_help, 
   "FILL",   cmd_fill, 
   "?",      cmd_help }; 
 
 
 
  
static char in_line[160]; 
static char outBuf[26]; 
 
 
  
 
static void dot_format (U32 val, char *sp); 
static char *get_entry (char *cp, char **pNext); 
static void init_card (void); 
 
 
 
 
  
static char *get_entry (char *cp, char **pNext) { 
   char *sp, lfn = 0, sep_ch = ' '; 
 
   if (cp == 0) {                            
      *pNext = cp; 
      return (cp); 
   } 
 
   for ( ; *cp == ' ' || *cp == '\"'; cp++) {   
      if (*cp == '\"') { sep_ch = '\"'; lfn = 1; } 
      *cp = 0; 
   } 
  
   for (sp = cp; *sp != 0x0D && *sp != 0x0A; sp++) { 
      if ( lfn && *sp == '\"') break; 
      if (!lfn && *sp == ' ' ) break; 
   } 
 
   for ( ; *sp == sep_ch || *sp == 0x0D || *sp == 0x0A; sp++) { 
      *sp = 0; 
      if ( lfn && *sp == sep_ch) { sp ++; break; } 
   } 
 
   *pNext = (*sp) ? sp : 0;                  
   return (cp); 
} 
 
 
 
  
static void dot_format (U32 val, char *sp) { 
 
   if (val >= (U32)1e9) { 
      sp += sprintf (sp,"%d.",val/(U32)1e9); 
      val %= (U32)1e9; 
      sp += sprintf (sp,"%03d.",val/(U32)1e6); 
      val %= (U32)1e6; 
      sprintf (sp,"%03d.%03d",val/1000,val%1000); 
      return; 
   } 
   if (val >= (U32)1e6) { 
      sp += sprintf (sp,"%d.",val/(U32)1e6); 
      val %= (U32)1e6; 
      sprintf (sp,"%03d.%03d",val/1000,val%1000); 
      return; 
   } 
   if (val >= 1000) { 
      sprintf (sp,"%d.%03d",val/1000,val%1000); 
      return; 
   } 
   sprintf (sp,"%d",val); 
} 
 
 
 
  
static void cmd_capture (char *par) { 
   char *fname,*next; 
   BOOL append,retv; 
   FILE *f; 
 
   fname = get_entry (par, &next); 
   if (fname == 0) { 
      printf ("\nFilename missing.\n"); 
      return; 
   } 
   append = 0; 
   if (next) { 
      par = get_entry (next, &next); 
      if ((strcmp (par, "/A") == 0) ||(strcmp (par, "/a") == 0)) { 
         append = 1; 
      } 
      else { 
         printf ("\nCommand error.\n"); 
         return; 
      } 
   } 
   printf ((append) ? "\nAppend data to file %s" : 
                      "\nCapture data to file %s", fname); 
   printf("\nPress ESC to stop.\n"); 
   f = fopen (fname,append ? "a" : "w");  
   if (f == 0) { 
      printf ("\nCan not open file!\n");  
      return; 
   }  
   do { 
      retv = getline (in_line, sizeof (in_line)); 
      fputs (in_line, f); 
   } while (retv == 1); 
   fclose (f);                          
   printf ("\nFile closed.\n"); 
} 
 
 
 
  
static void cmd_fill (char *par) { 
   char *fname, *next; 
   FILE *f; 
   int i,cnt = 1000; 
 
   fname = get_entry (par, &next); 
   if (fname == 0) { 
      printf ("\nFilename missing.\n"); 
      return; 
   } 
   if (next) { 
      par = get_entry (next, &next); 
      if (sscanf (par,"%d", &cnt) == 0) { 
         printf ("\nCommand error.\n"); 
         return; 
      } 
   } 
 
   f = fopen (fname, "w");                
   if (f == 0) { 
      printf ("\nCan not open file!\n");  
      return; 
   }  
   for (i = 0; i < cnt; i++)  { 
      fprintf (f, "This is line # %d in file %s\n", i, fname); 
   } 
   fclose (f);                          
   printf ("\nFile closed.\n"); 
} 
 
 
 
 
  
static void cmd_type (char *par) { 
   char *fname,*next; 
   FILE *f; 
   int ch; 
 
   fname = get_entry (par, &next); 
   if (fname == 0) { 
      printf ("\nFilename missing.\n"); 
      return; 
   } 
   printf("\nRead data from file %s\n",fname); 
   f = fopen (fname,"r");               
   if (f == 0) { 
      printf ("\nFile not found!\n"); 
      return; 
   } 
   
   while ((ch = fgetc (f)) != (-1)) {    
      putc(ch, (& __stdout));                     
   } 
   fclose (f);                          
   printf ("\nFile closed.\n"); 
} 
 
 
 
  
static void cmd_rename (char *par) { 
   char *fname,*fnew,*next,dir; 
 
   fname = get_entry (par, &next); 
   if (fname == 0) { 
      printf ("\nFilename missing.\n"); 
      return; 
   } 
   fnew = get_entry (next, &next); 
   if (fnew == 0) { 
      printf ("\nNew Filename missing.\n"); 
      return; 
   } 
   if (strcmp (fname,fnew) == 0) { 
      printf ("\nNew name is the same.\n"); 
      return; 
   } 
 
   dir = 0; 
   if (*(fname + strlen(fname) - 1) == '\\') { 
      dir = 1; 
   } 
 
   if (frename (fname, fnew) == 0) { 
      if (dir) { 
         printf ("\nDirectory %s renamed to %s\n",fname,fnew); 
      } 
      else { 
         printf ("\nFile %s renamed to %s\n",fname,fnew); 
      } 
   } 
   else { 
      if (dir) { 
         printf ("\nDirectory rename error.\n"); 
      } 
      else { 
         printf ("\nFile rename error.\n"); 
      } 
   } 
} 
 
 
 
  
static void cmd_copy (char *par) { 
   char *fname,*fnew,*fmer,*next; 
   FILE *fin,*fout; 
   U32 cnt,total; 
   char buf[512]; 
   BOOL merge; 
 
   fname = get_entry (par, &next); 
   if (fname == 0) { 
      printf ("\nFilename missing.\n"); 
      return; 
   } 
   fmer = get_entry (next, &next); 
   if (fmer == 0) { 
      printf ("\nNew Filename missing.\n"); 
      return; 
   } 
   fnew = get_entry (next, &next); 
   if (fnew != 0) { 
      merge = 1; 
   } 
   else { 
      merge = 0; 
      fnew = fmer; 
   } 
   if ((strcmp (fname,fnew) == 0)        || 
       (merge && strcmp (fmer,fnew) == 0)) { 
      printf ("\nNew name is the same.\n"); 
      return; 
   } 
 
   fin = fopen (fname,"r");             
   if (fin == 0) { 
      printf ("\nFile %s not found!\n",fname); 
      return; 
   } 
 
   if (merge == 0) { 
      printf ("\nCopy file %s to %s\n",fname,fnew); 
   } 
   else { 
      printf ("\nCopy file %s, %s to %s\n",fname,fmer,fnew); 
   } 
   fout = fopen (fnew,"w");             
   if (fout == 0) { 
      printf ("\nFailed to open %s for writing!\n",fnew); 
      fclose (fin); 
      return; 
   } 
 
   total = 0; 
   while ((cnt = fread (&buf, 1, 512, fin)) != 0) { 
      fwrite (&buf, 1, cnt, fout); 
      total += cnt; 
   } 
   fclose (fin);                        
 
   if (merge == 1) { 
      fin = fopen (fmer,"r");           
      if (fin == 0) { 
         printf ("\nFile %s not found!\n",fmer); 
      } 
      else { 
         while ((cnt = fread (&buf, 1, 512, fin)) != 0) { 
            fwrite (&buf, 1, cnt, fout); 
            total += cnt; 
         } 
         fclose (fin); 
      } 
   } 
   fclose (fout); 
   dot_format (total, &buf[0]); 
   printf ("\n%s bytes copied.\n", &buf[0]); 
} 
 
 
 
  
static void cmd_delete (char *par) { 
   char *fname,*next,dir; 
 
   fname = get_entry (par, &next); 
   if (fname == 0) { 
      printf ("\nFilename missing.\n"); 
      return; 
   } 
 
   dir = 0; 
   if (*(fname + strlen(fname) - 1) == '\\') { 
      dir = 1; 
   } 
 
   if (fdelete (fname) == 0) { 
      if (dir) { 
         printf ("\nDirectory %s deleted.\n",fname); 
      } 
      else { 
         printf ("\nFile %s deleted.\n",fname); 
      } 
   } 
   else { 
      if (dir) { 
         printf ("\nDirectory %s not found or not empty.\n",fname); 
      } 
      else { 
         printf ("\nFile %s not found.\n",fname); 
      } 
   } 
} 
 
 
 
  
static void cmd_dir (char *par) { 
   U32 fsize,files,dirs,i; 
   char temp[32],*mask,*next,ch; 
   FINFO info; 
 
   mask = get_entry (par, &next); 
   if (mask == 0) { 
      mask = "*.*"; 
   } 
 
   printf ("\nFile System Directory..."); 
   files = 0; 
   dirs  = 0; 
   fsize = 0; 
   info.fileID  = 0; 
   while (ffind (mask,&info) == 0) { 
      if (info.attrib & 0x10) { 
         i = 0; 
         while (strlen((const char *)info.name+i) > 41) { 
            ch = info.name[i+41]; 
            info.name[i+41] = 0; 
            printf ("\n%-41s", &info.name[i]); 
            info.name[i+41] = ch; 
            i += 41; 
         } 
         printf ("\n%-41s    <DIR>       ", &info.name[i]); 
         printf ("  %02d.%02d.%04d  %02d:%02d", 
                  info.time.day, info.time.mon, info.time.year, 
                  info.time.hr, info.time.min); 
         dirs++; 
      } 
      else { 
         dot_format (info.size, &temp[0]); 
         i = 0; 
         while (strlen((const char *)info.name+i) > 41) { 
            ch = info.name[i+41]; 
            info.name[i+41] = 0; 
            printf ("\n%-41s", &info.name[i]); 
            info.name[i+41] = ch; 
            i += 41; 
         } 
         printf ("\n%-41s %14s ", &info.name[i], temp); 
         printf ("  %02d.%02d.%04d  %02d:%02d", 
                  info.time.day, info.time.mon, info.time.year, 
                  info.time.hr, info.time.min); 
         fsize += info.size; 
         files++; 
      } 
   } 
   if (info.fileID == 0) { 
      printf ("\nNo files..."); 
   } 
   else { 
      dot_format (fsize, &temp[0]); 
      printf ("\n              %9d File(s)    %21s bytes", files, temp); 
   } 
   dot_format (ffree(""), &temp[0]); 
   if (dirs) { 
      printf ("\n              %9d Dir(s)     %21s bytes free.\n", dirs, temp); 
   } 
   else { 
      printf ("\n%56s bytes free.\n",temp); 
   } 
} 
 
 
 
  
static void cmd_format (char *par) { 
   char *label,*next,*opt; 
   char arg[20]; 
   U32 retv; 
 
   label = get_entry (par, &next); 
   if (label == 0) { 
      label = "KEIL"; 
   } 
   strcpy (arg, label); 
   opt = get_entry (next, &next); 
   if (opt != 0) { 
      if ((strcmp (opt, "/FAT32") == 0) ||(strcmp (opt, "/fat32") == 0)) { 
         strcat (arg, "/FAT32"); 
      } 
   } 
   printf ("\nFormat Flash Memory Card? [Y/N]\n"); 
   retv = getkey(); 
   if (retv == 'y' || retv == 'Y') { 
        
      if (fformat (arg) == 0) { 
         printf ("Memory Card Formatted.\n"); 
         printf ("Card Label is %s\n",label); 
      } 
      else { 
         printf ("Formatting failed.\n"); 
      } 
   } 
} 
 
 
 
  
static void cmd_help (char *par) { 
   printf (help); 
} 
 
 
 
  
static void init_card (void) { 
   U32 retv; 
   MMCFG SDCardCfg; 
 
 
 
   while ((retv = finit ()) != 0) {             
      if (retv == 1) { 
         printf ("\nSD/MMC Init Failed"); 
         printf ("\nInsert Memory card and press key...\n"); 
         getkey (); 
      } 
      else { 
         printf ("\nSD/MMC Card is Unformatted"); 
         strcpy (&in_line[0], "KEIL\r\n"); 
         cmd_format (&in_line[0]); 
      } 
   } 
 
   mmc_read_config (&SDCardCfg); 
 
   outBuf[0] = 0; 
   sprintf(&outBuf[0], " SerNr:  0x%08X", SDCardCfg.sernum); 
 
   sprintf(&outBuf[0], " BlockNr:0x%08X", SDCardCfg.blocknr); 
  
   sprintf(&outBuf[0], " RdLen:  0x%04X", SDCardCfg.read_blen); 
  
   sprintf(&outBuf[0], " WrLen:  0x%04X", SDCardCfg.write_blen); 
  
 
} 
 
 
 
  
int main (void) { 
   char *sp,*cp,*next; 
   U32 i; 
 
   SystemInit();                                
 
   SER_init (0);                                
 
   printf (intro);                              
   printf (help); 
 
   init_card (); 
   while (1) { 
      printf ("\nCmd> ");                       
      fflush ((& __stdout)); 
                                                
      if (getline (in_line, sizeof (in_line)) == 0) { 
         continue; 
      } 
 
      sp = get_entry (&in_line[0], &next); 
      if (*sp == 0) { 
         continue; 
      } 
      for (cp = sp; *cp && *cp != ' '; cp++) { 
         *cp = toupper (*cp);                   
      } 
      for (i = 0; i < (sizeof (cmd) / sizeof (cmd[0])); i++) { 
         if (strcmp (sp, (const char *)&cmd[i].val)) { 
            continue; 
         } 
         init_card();                           
         cmd[i].func (next);                    
         break; 
      } 
      if (i == (sizeof (cmd) / sizeof (cmd[0]))) { 
        printf ("\nCommand error\n"); 
      } 
   } 
}