| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
MassStorageHost.c File Reference
`#include "MassStorageHost.h"`
`#include "fsusb_cfg.h"`
`#include "ff.h"`

Go to the source code of this file.

## Functions
static void | die (FRESULT rc)
static void | SetupHardware (void)
static void | USB_ReadWriteFile (void)
int | main (void)
| Main program body.
void | EVENT_USB_Host_DeviceAttached (const uint8_t corenum)
void | EVENT_USB_Host_DeviceUnattached (const uint8_t corenum)
void | EVENT_USB_Host_DeviceEnumerationComplete (const uint8_t corenum)
void | EVENT_USB_Host_HostError (const uint8_t corenum, const uint8_t ErrorCode)
void | EVENT_USB_Host_DeviceEnumerationFailed (const uint8_t corenum, const uint8_t ErrorCode, const uint8_t SubErrorCode)
DISK_HANDLE_T * | FSUSB_DiskInit (void)
| Initialize the disk data structure.
int | FSUSB_DiskInsertWait (DISK_HANDLE_T *hDisk)
| Wait for the USB device to be inserted and ready.
int | FSUSB_DiskAcquire (DISK_HANDLE_T *hDisk)
| Enumerate and get the disk connected.
uint32_t | FSUSB_DiskGetSectorCnt (DISK_HANDLE_T *hDisk)
| Get the number of sectors in the disk.
uint32_t | FSUSB_DiskGetSectorSz (DISK_HANDLE_T *hDisk)
| Get number of bytes in a sector of the disk.
int | FSUSB_DiskReadSectors (DISK_HANDLE_T *hDisk, void *buff, uint32_t secStart, uint32_t numSec)
| Reads sectors from USB mass storage disk.
int | FSUSB_DiskWriteSectors (DISK_HANDLE_T *hDisk, void *buff, uint32_t secStart, uint32_t numSec)
| Write data to USB device sectors.
int | FSUSB_DiskReadyWait (DISK_HANDLE_T *hDisk, int tout)
| Wait for the USB Disk to be ready.

## Variables
static USB_ClassInfo_MS_Host_t | FlashDisk_MS_Interface
static SCSI_Capacity_t | DiskCapacity
static uint8_t | buffer [8 *1024]
STATIC FATFS | fatFS
STATIC FIL | fileObj

## Function Documentation

static void die | ( | FRESULT | rc | ) |
| static

Definition at line 71 of file MassStorageHost.c.

int FSUSB_DiskAcquire | ( | DISK_HANDLE_T * | hDisk | ) |

Enumerate and get the disk connected.

Parameters

  hDisk | : Handle to the USB Disk data structure

Returns
  1 on success, 0 on failure

Definition at line 331 of file MassStorageHost.c.

uint32_t FSUSB_DiskGetSectorCnt | ( | DISK_HANDLE_T * | hDisk | ) |

Get the number of sectors in the disk.

Parameters

  hDisk | : Handle to USB disk

Returns
  Number of sectors in the USB disk

Definition at line 361 of file MassStorageHost.c.

uint32_t FSUSB_DiskGetSectorSz | ( | DISK_HANDLE_T * | hDisk | ) |

Get number of bytes in a sector of the disk.

Parameters

  hDisk | : Handle to the USB Disk

Returns
  Number of bytes in a single sector of the disk

Definition at line 367 of file MassStorageHost.c.

DISK_HANDLE_T* FSUSB_DiskInit | ( | void |  | ) |

Initialize the disk data structure.

Returns
  Pointer to the disk data strucuture

Definition at line 315 of file MassStorageHost.c.

int FSUSB_DiskInsertWait | ( | DISK_HANDLE_T * | hDisk | ) |

Wait for the USB device to be inserted and ready.

Parameters

  hDisk | : Handle to USB Disk

Returns
  1 on success and 0 on failure

Definition at line 321 of file MassStorageHost.c.

int FSUSB_DiskReadSectors | ( | DISK_HANDLE_T * | hDisk,
|  | void * | buff,
|  | uint32_t | secStart,
|  | uint32_t | numSec
| ) |  |

Reads sectors from USB mass storage disk.

Parameters

  hDisk | : Handle to the USB disk
  buff | : Pointer to memory where the data read will be stored
  secStart | : Starting sector from which data be read
  numSec | : Number of sectors to be read

Returns
  1 on success and 0 on failure

Definition at line 373 of file MassStorageHost.c.

int FSUSB_DiskReadyWait | ( | DISK_HANDLE_T * | hDisk,
|  | int | tout
| ) |  |

Wait for the USB Disk to be ready.

Parameters

  hDisk | : Pointer to Disk Handle
  tout | : Time to wait, in milliseconds

Returns
  0 when operation failed 1 when successfully completed

Definition at line 394 of file MassStorageHost.c.

int FSUSB_DiskWriteSectors | ( | DISK_HANDLE_T * | hDisk,
|  | void * | buff,
|  | uint32_t | secStart,
|  | uint32_t | numSec
| ) |  |

Write data to USB device sectors.

Parameters

  hDisk | : Handle to the USB disk
  buff | : Pointer to memory where the data to be written, be stored
  secStart | : Starting sector from which data be written
  numSec | : Number of sectors to write

Returns
  1 on success and 0 on failure

Definition at line 384 of file MassStorageHost.c.

static void SetupHardware | ( | void |  | ) |
| static

Configures the board hardware and chip peripherals for the demo's functionality.

Definition at line 80 of file MassStorageHost.c.

static void USB_ReadWriteFile | ( | void |  | ) |
| static

Definition at line 92 of file MassStorageHost.c.

## Variable Documentation

uint8_t buffer[8 *1024]
| static

Definition at line 57 of file MassStorageHost.c.

SCSI_Capacity_t DiskCapacity
| static

Definition at line 56 of file MassStorageHost.c.

STATIC FATFS fatFS

Definition at line 59 of file MassStorageHost.c.

STATIC FIL fileObj

Definition at line 60 of file MassStorageHost.c.

USB_ClassInfo_MS_Host_t FlashDisk_MS_Interface
| static

Initial value:
= {
.Config = {
.DataINPipeNumber = 1,
.DataINPipeDoubleBank = false,
.DataOUTPipeNumber = 2,
.DataOUTPipeDoubleBank = false,
.PortNumber = 0,
},
}

LPCUSBlib Mass Storage Class driver interface configuration and state information. This structure is passed to all Mass Storage Class driver functions, so that multiple instances of the same class within a device can be differentiated from one another.

Definition at line 45 of file MassStorageHost.c.