usb hostlite fat32 impplementation

i am currently using lpc2468 usbhostlite code and getting the required results.
can anyone please help me make the necessary changes in the code to use it with fat32 formatted pendrives also

Parents Reply
  • I'm surprised you don't get it yet :-)
    Maybe, my explanation was not so clear for you..

    > I tried a lot to make changes to Hostlite..

    You don't need to change so much.

    1) Download THOMAS's FatFs/USBHostLite (LPC17xx) example, first.
    www.siwawi.arubi.uni-kl.de/.../lpc17xx_chanfat_mthomas_20100715c_pub.zip

    2) Copy diskio.c, fattime.c (under \lpc17xx_chanfat_mthomas 2\project\Libraries\fat_sd\) from THOMAS's to your project.

    3) Modify this diskio.c
    I'll show you the first part of modification.
    Like this disk_initialize(), modify disk_status(), disk_read(), disk_write() and disk_ioctl(), too
    That is, strip down the routines, so that the code in "case USB:" is left.

    /*-----------------------------------------------------------------------*/
    /* Low level disk I/O module skeleton for FatFs                          */
    /* (C)ChaN, 2007                                                         */
    /* Copyright (c) 2010, Martin Thomas                                     */
    /*-----------------------------------------------------------------------*/
    /* This is a stub disk I/O module that acts as front end of the existing */
    /* disk I/O modules and attach it to FatFs module with common interface. */
    /*-----------------------------------------------------------------------*/
    
    #include "diskio.h"
    // #include "spi_sd_lpc17xx.h"      // <---- delete this line
    
    // in makefile #define WITH_USB_MS   1
    
    // #if ( WITH_USB_MS == 1 )         // <---- delete this line
    
    #include "usbhost_lpc2468.h"        // <---- add this line
    #include "usbhost_ms.h"
    
    USB_INT32U numBlks, blkSize;
    USB_INT08U inquiryResult[INQUIRY_LENGTH];
    DSTATUS usb_status = STA_NOINIT;
    
    // #endif                           // <---- delete this line
    
    /*-----------------------------------------------------------------------*/
    /* Correspondence between physical drive number and physical drive.      */
    /*-----------------------------------------------------------------------*/
    
    /*                                  // <---- delete these lines
    #define MMC     0
    #define USB     1
    #define ATA     2
    */
    
    /*-----------------------------------------------------------------------*/
    /* disk-timer - forwarded to low-level drivers                           */
    /*-----------------------------------------------------------------------*/
    
    /*                                  // <---- delete these lines
    void disk_timerproc(void)
    {
        MMC_disk_timerproc();
    }
    */
    
    /*-----------------------------------------------------------------------*/
    /* Initialize a Drive                                                    */
    /*-----------------------------------------------------------------------*/
    
    DSTATUS disk_initialize(BYTE drv /* Physical drive nmuber (0..) */
    )
    {
    /*                                  // <---- delete these lines
        DSTATUS stat;
        int result;
    
        (void) result;
    
        switch (drv)
        {
        case ATA:
            // result = ATA_disk_initialize();
            stat = STA_NOINIT;
            // translate the result code here
            return stat;
    
        case MMC:
            stat = MMC_disk_initialize();
            return stat;
    
        case USB:
    #if WITH_USB_MS
    */
    
        if ( drv != 0)  return STA_NOINIT;      // <---- add this line
    
            /* USB host init and enumeration */
            if ( usb_status & STA_NOINIT ) {
                Host_Init();
                if ( Host_EnumDev() == OK ) {
                    /* mass-storage init */
                    if ( MS_Init(&blkSize, &numBlks, inquiryResult) == OK ) {
                        usb_status &= ~STA_NOINIT;
    
                        return usb_status;  // <---- add this line
    
                    } else {
                        /* MS init fail */
                    }
                } else {
                    /* host init and/or enum fail */
                }
            }
    /*                                  // <---- delete these lines
            return usb_status;
    #else
            stat = STA_NOINIT;
            return stat;
    #endif
    
        }
    */
    
        return STA_NOINIT;
    }
    

    4) Copy diskio.h, ff.c, ff.h, ffconf.h, integer.h from ChaN's FatFs to your project
    elm-chan.org/.../ff9.zip

    5) In your source code,
    - include integer.h, ff.h
    - replace USBHostLite's FAT/Filesystem routines (FILE_Open(), etc) into FatFs's Application Interface (f_open(), etc)
    elm-chan.org/.../00index_e.html

    That's all

    Tsuneo

Children
More questions in this forum