![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
USB Host Lite downloaded from NXP web site. Untested! Compiled, dropped on MBED, booted up, and get the console message that it is initializing the stack. I however do not have the ability to connect a USB Memory device to test it.
Fat/usbhost_fat.h@0:0826fcc5d020, 2010-01-13 (annotated)
- Committer:
- mshoemaker
- Date:
- Wed Jan 13 01:29:30 2010 +0000
- Revision:
- 0:0826fcc5d020
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mshoemaker | 0:0826fcc5d020 | 1 | /* |
mshoemaker | 0:0826fcc5d020 | 2 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 3 | * NXP USB Host Stack |
mshoemaker | 0:0826fcc5d020 | 4 | * |
mshoemaker | 0:0826fcc5d020 | 5 | * (c) Copyright 2008, NXP SemiConductors |
mshoemaker | 0:0826fcc5d020 | 6 | * (c) Copyright 2008, OnChip Technologies LLC |
mshoemaker | 0:0826fcc5d020 | 7 | * All Rights Reserved |
mshoemaker | 0:0826fcc5d020 | 8 | * |
mshoemaker | 0:0826fcc5d020 | 9 | * www.nxp.com |
mshoemaker | 0:0826fcc5d020 | 10 | * www.onchiptech.com |
mshoemaker | 0:0826fcc5d020 | 11 | * |
mshoemaker | 0:0826fcc5d020 | 12 | * File : usbhost_fat.h |
mshoemaker | 0:0826fcc5d020 | 13 | * Programmer(s) : Ravikanth.P |
mshoemaker | 0:0826fcc5d020 | 14 | * Version : |
mshoemaker | 0:0826fcc5d020 | 15 | * |
mshoemaker | 0:0826fcc5d020 | 16 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 17 | */ |
mshoemaker | 0:0826fcc5d020 | 18 | |
mshoemaker | 0:0826fcc5d020 | 19 | #ifndef USBHOST_FAT_H |
mshoemaker | 0:0826fcc5d020 | 20 | #define USBHOST_FAT_H |
mshoemaker | 0:0826fcc5d020 | 21 | |
mshoemaker | 0:0826fcc5d020 | 22 | /* |
mshoemaker | 0:0826fcc5d020 | 23 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 24 | * INCLUDE HEADER FILES |
mshoemaker | 0:0826fcc5d020 | 25 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 26 | */ |
mshoemaker | 0:0826fcc5d020 | 27 | |
mshoemaker | 0:0826fcc5d020 | 28 | #include "usbhost_inc.h" |
mshoemaker | 0:0826fcc5d020 | 29 | |
mshoemaker | 0:0826fcc5d020 | 30 | /* |
mshoemaker | 0:0826fcc5d020 | 31 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 32 | * FAT DEFINITIONS |
mshoemaker | 0:0826fcc5d020 | 33 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 34 | */ |
mshoemaker | 0:0826fcc5d020 | 35 | |
mshoemaker | 0:0826fcc5d020 | 36 | #define FAT_16 1 |
mshoemaker | 0:0826fcc5d020 | 37 | |
mshoemaker | 0:0826fcc5d020 | 38 | #define LAST_ENTRY 1 |
mshoemaker | 0:0826fcc5d020 | 39 | #define FREE_ENTRY 2 |
mshoemaker | 0:0826fcc5d020 | 40 | #define LFN_ENTRY 3 |
mshoemaker | 0:0826fcc5d020 | 41 | #define SFN_ENTRY 4 |
mshoemaker | 0:0826fcc5d020 | 42 | |
mshoemaker | 0:0826fcc5d020 | 43 | #define RDONLY 1 |
mshoemaker | 0:0826fcc5d020 | 44 | #define RDWR 2 |
mshoemaker | 0:0826fcc5d020 | 45 | |
mshoemaker | 0:0826fcc5d020 | 46 | /* |
mshoemaker | 0:0826fcc5d020 | 47 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 48 | * TYPE DEFINITIONS |
mshoemaker | 0:0826fcc5d020 | 49 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 50 | */ |
mshoemaker | 0:0826fcc5d020 | 51 | |
mshoemaker | 0:0826fcc5d020 | 52 | typedef struct boot_sec { |
mshoemaker | 0:0826fcc5d020 | 53 | USB_INT32U BootSecOffset; /* Offset of the boot sector from sector 0 */ |
mshoemaker | 0:0826fcc5d020 | 54 | USB_INT16U BytsPerSec; /* Bytes per sector */ |
mshoemaker | 0:0826fcc5d020 | 55 | USB_INT08U SecPerClus; /* Sectors per cluster */ |
mshoemaker | 0:0826fcc5d020 | 56 | USB_INT32U BytsPerClus; /* Bytes per cluster */ |
mshoemaker | 0:0826fcc5d020 | 57 | USB_INT16U RsvdSecCnt; /* Reserved sector count */ |
mshoemaker | 0:0826fcc5d020 | 58 | USB_INT08U NumFATs; /* Number of FAT copies */ |
mshoemaker | 0:0826fcc5d020 | 59 | USB_INT16U RootEntCnt; /* Root entry count */ |
mshoemaker | 0:0826fcc5d020 | 60 | USB_INT16U TotSec16; /* Total sectors in the disk. !=0 if TotSec32 = 0 */ |
mshoemaker | 0:0826fcc5d020 | 61 | USB_INT32U TotSec32; /* Total sectors in the disk. !=0 if TotSec16 = 0 */ |
mshoemaker | 0:0826fcc5d020 | 62 | USB_INT16U FATSz16; /* Sectors occupied by single FAT table */ |
mshoemaker | 0:0826fcc5d020 | 63 | USB_INT08U FATType; /* File system type */ |
mshoemaker | 0:0826fcc5d020 | 64 | USB_INT32U RootDirSec; /* Sectors occupied by root directory */ |
mshoemaker | 0:0826fcc5d020 | 65 | USB_INT32U RootDirStartSec; /* Starting sector of the root directory */ |
mshoemaker | 0:0826fcc5d020 | 66 | USB_INT32U FirstDataSec; /* Starting sector of the first data cluster */ |
mshoemaker | 0:0826fcc5d020 | 67 | } BOOT_SEC; |
mshoemaker | 0:0826fcc5d020 | 68 | |
mshoemaker | 0:0826fcc5d020 | 69 | typedef struct file_entry { |
mshoemaker | 0:0826fcc5d020 | 70 | USB_INT32U FileSize; /* Total size of the file */ |
mshoemaker | 0:0826fcc5d020 | 71 | USB_INT16U CurrClus; /* Current cluster of the cluster offset */ |
mshoemaker | 0:0826fcc5d020 | 72 | USB_INT32U CurrClusOffset; /* Current cluster offset */ |
mshoemaker | 0:0826fcc5d020 | 73 | USB_INT32U EntrySec; /* Sector where the file entry is located */ |
mshoemaker | 0:0826fcc5d020 | 74 | USB_INT32U EntrySecOffset; /* Offset in the entry sector from where the file is located */ |
mshoemaker | 0:0826fcc5d020 | 75 | USB_INT08U FileStatus; /* File's open status */ |
mshoemaker | 0:0826fcc5d020 | 76 | } FILE_ENTRY; |
mshoemaker | 0:0826fcc5d020 | 77 | |
mshoemaker | 0:0826fcc5d020 | 78 | /* |
mshoemaker | 0:0826fcc5d020 | 79 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 80 | * FUNCTION PROTOTYPES |
mshoemaker | 0:0826fcc5d020 | 81 | ************************************************************************************************************** |
mshoemaker | 0:0826fcc5d020 | 82 | */ |
mshoemaker | 0:0826fcc5d020 | 83 | |
mshoemaker | 0:0826fcc5d020 | 84 | USB_INT32S FAT_Init (void); |
mshoemaker | 0:0826fcc5d020 | 85 | |
mshoemaker | 0:0826fcc5d020 | 86 | USB_INT08U FAT_GetFATType (void); |
mshoemaker | 0:0826fcc5d020 | 87 | void PrintBootSec (void); |
mshoemaker | 0:0826fcc5d020 | 88 | |
mshoemaker | 0:0826fcc5d020 | 89 | USB_INT32S FILE_Open ( USB_INT08U *file_name, |
mshoemaker | 0:0826fcc5d020 | 90 | USB_INT08U flags); |
mshoemaker | 0:0826fcc5d020 | 91 | |
mshoemaker | 0:0826fcc5d020 | 92 | USB_INT32S FAT_FindEntry ( USB_INT08U *ent_name_given, |
mshoemaker | 0:0826fcc5d020 | 93 | FILE_ENTRY *entry); |
mshoemaker | 0:0826fcc5d020 | 94 | |
mshoemaker | 0:0826fcc5d020 | 95 | void FAT_GetSFN (volatile USB_INT08U *entry, |
mshoemaker | 0:0826fcc5d020 | 96 | USB_INT08U *name); |
mshoemaker | 0:0826fcc5d020 | 97 | |
mshoemaker | 0:0826fcc5d020 | 98 | void FAT_GetSfnName (volatile USB_INT08U *entry, |
mshoemaker | 0:0826fcc5d020 | 99 | USB_INT08U *name); |
mshoemaker | 0:0826fcc5d020 | 100 | |
mshoemaker | 0:0826fcc5d020 | 101 | void FAT_GetSfnExt (volatile USB_INT08U *entry, |
mshoemaker | 0:0826fcc5d020 | 102 | USB_INT08U *ext_ptr); |
mshoemaker | 0:0826fcc5d020 | 103 | |
mshoemaker | 0:0826fcc5d020 | 104 | USB_INT32S FAT_StrCaseCmp ( USB_INT08U *str1, |
mshoemaker | 0:0826fcc5d020 | 105 | USB_INT08U *str2); |
mshoemaker | 0:0826fcc5d020 | 106 | |
mshoemaker | 0:0826fcc5d020 | 107 | USB_INT32U FAT_ChkEntType (volatile USB_INT08U *ent); |
mshoemaker | 0:0826fcc5d020 | 108 | |
mshoemaker | 0:0826fcc5d020 | 109 | USB_INT32U FAT_ClusRead ( USB_INT16U curr_clus, |
mshoemaker | 0:0826fcc5d020 | 110 | USB_INT32U clus_offset, |
mshoemaker | 0:0826fcc5d020 | 111 | volatile USB_INT08U *buffer, |
mshoemaker | 0:0826fcc5d020 | 112 | USB_INT32U num_bytes); |
mshoemaker | 0:0826fcc5d020 | 113 | |
mshoemaker | 0:0826fcc5d020 | 114 | USB_INT32U FILE_Read ( USB_INT32S fd, |
mshoemaker | 0:0826fcc5d020 | 115 | volatile USB_INT08U *buffer, |
mshoemaker | 0:0826fcc5d020 | 116 | USB_INT32U num_bytes); |
mshoemaker | 0:0826fcc5d020 | 117 | USB_INT16U FAT_GetNextClus ( USB_INT16U clus_no); |
mshoemaker | 0:0826fcc5d020 | 118 | |
mshoemaker | 0:0826fcc5d020 | 119 | USB_INT32U FAT_ClusWrite ( USB_INT16U curr_clus, |
mshoemaker | 0:0826fcc5d020 | 120 | USB_INT32U clus_offset, |
mshoemaker | 0:0826fcc5d020 | 121 | volatile USB_INT08U *buffer, |
mshoemaker | 0:0826fcc5d020 | 122 | USB_INT32U num_bytes); |
mshoemaker | 0:0826fcc5d020 | 123 | USB_INT32U FILE_Write ( USB_INT32S fd, |
mshoemaker | 0:0826fcc5d020 | 124 | volatile USB_INT08U *buffer, |
mshoemaker | 0:0826fcc5d020 | 125 | USB_INT32U num_bytes); |
mshoemaker | 0:0826fcc5d020 | 126 | |
mshoemaker | 0:0826fcc5d020 | 127 | void FAT_UpdateEntry ( FILE_ENTRY *entry); |
mshoemaker | 0:0826fcc5d020 | 128 | |
mshoemaker | 0:0826fcc5d020 | 129 | void FAT_UpdateFAT ( USB_INT16U curr_clus, |
mshoemaker | 0:0826fcc5d020 | 130 | USB_INT16U value); |
mshoemaker | 0:0826fcc5d020 | 131 | |
mshoemaker | 0:0826fcc5d020 | 132 | USB_INT16U FAT_GetFreeClus (void); |
mshoemaker | 0:0826fcc5d020 | 133 | |
mshoemaker | 0:0826fcc5d020 | 134 | USB_INT32S FAT_GetFreeEntry( FILE_ENTRY *entry); |
mshoemaker | 0:0826fcc5d020 | 135 | |
mshoemaker | 0:0826fcc5d020 | 136 | void FAT_PutSFN ( USB_INT08U *ent_name_given, |
mshoemaker | 0:0826fcc5d020 | 137 | FILE_ENTRY *entry); |
mshoemaker | 0:0826fcc5d020 | 138 | |
mshoemaker | 0:0826fcc5d020 | 139 | USB_INT32S FAT_CreateEntry ( USB_INT08U *ent_name_given, |
mshoemaker | 0:0826fcc5d020 | 140 | FILE_ENTRY *entry); |
mshoemaker | 0:0826fcc5d020 | 141 | |
mshoemaker | 0:0826fcc5d020 | 142 | void FILE_Close ( USB_INT32S fd); |
mshoemaker | 0:0826fcc5d020 | 143 | |
mshoemaker | 0:0826fcc5d020 | 144 | USB_INT16U FAT_GetEndClus ( USB_INT16U clus_no); |
mshoemaker | 0:0826fcc5d020 | 145 | |
mshoemaker | 0:0826fcc5d020 | 146 | #endif |