NetBurner 3.5.8
PDF Version
Toggle main menu visibility
usb_msd_host.h
1
/*
2
* USB Mass Storage Device Host Driver for SOMRT1061
3
*
4
* Public API header file
5
*
6
* This driver enables reading/writing USB flash drives using NetBurner's
7
* EFFS-FAT file system on the SOMRT1061 platform.
8
*/
9
10
#ifndef _USB_MSD_HOST_H_
11
#define _USB_MSD_HOST_H_
12
13
#include <nbrtos.h>
14
#include <effs_fat/fat.h>
15
16
#ifdef __cplusplus
17
extern
"C"
{
18
#endif
19
20
/* Maximum number of MSD drives supported */
21
#define MAX_MSD_DRIVES 1
22
23
/* MSD status codes - matches MCF5441X pattern */
24
typedef
enum
{
25
MSD_STAT_DEVICE_IDLE = 0,
/* No device connected */
26
MSD_STAT_DEVICE_ATTACHED,
/* Device detected, enumerating */
27
MSD_STAT_DEVICE_CONFIGURED,
/* USB configured */
28
MSD_STAT_DEVICE_SET_INTERFACE,
/* Set interface in progress */
29
MSD_STAT_DEVICE_INTERFACED,
/* Interface set complete */
30
MSD_STAT_DEVICE_DETACHED,
/* Device removed */
31
MSD_STAT_DEVICE_OTHER,
/* Other state */
32
MSD_STAT_DEVICE_UNKNOWN,
/* Unknown state */
33
MSD_STAT_VOLUME_INITIALIZED,
/* Ready for file operations */
34
MSD_STAT_DEVICE_POST_QUERY,
/* Querying device */
35
MSD_STAT_DRIVE_CHANGE_FAILED
/* Mount/init failed */
36
} MSD_STATES;
37
38
/*
39
* Initialize USB Host MSD subsystem
40
*
41
* This function initializes the USB Host controller on USB2 (OTG2) port
42
* and sets up the MSD class driver. It must be called before any other
43
* MSD functions.
44
*
45
* Parameters:
46
* psema - Pointer to semaphore that will be posted on device state changes
47
* iVolume - Pointer to receive the assigned volume number
48
*
49
* Returns:
50
* 0 on success, negative value on error
51
*/
52
int
MSDOpen(
OS_SEM
*psema,
int
*iVolume);
53
54
/*
55
* Get current device status
56
*
57
* Returns the current state of the MSD device connection.
58
*
59
* Returns:
60
* One of the MSD_STATES enum values
61
*/
62
int
GetMSDStatus(
void
);
63
64
/*
65
* Enable/disable 5V VBUS power
66
*
67
* Controls the VBUS power supply to the USB Host port.
68
* Must be enabled for USB devices to be detected and powered.
69
*
70
* Parameters:
71
* enable - true to enable VBUS power, false to disable
72
*/
73
void
VBUSEnable(
bool
enable);
74
75
/*
76
* EFFS-FAT driver initialization function
77
*
78
* This function is passed to f_initvolume() to initialize the MSD
79
* as a file system volume.
80
*
81
* Parameters:
82
* driver_param - Driver parameter (drive number, 0 to MAX_MSD_DRIVES-1)
83
*
84
* Returns:
85
* Pointer to F_DRIVER structure, or NULL on error
86
*/
87
F_DRIVER *msd_initfunc(
unsigned
long
driver_param);
88
89
/*
90
* Check if MSD device is ready for file operations
91
*
92
* Returns:
93
* true if device is ready, false otherwise
94
*/
95
bool
IsMSDReady(
void
);
96
97
/*
98
* Get the sector size of the connected MSD device
99
*
100
* Returns:
101
* Sector size in bytes (typically 512), or 0 if no device
102
*/
103
uint32_t GetMSDSectorSize(
void
);
104
105
/*
106
* Get the total number of sectors on the connected MSD device
107
*
108
* Returns:
109
* Number of sectors, or 0 if no device
110
*/
111
uint32_t GetMSDSectorCount(
void
);
112
113
/*
114
* Debug: Dump USB Host controller register status
115
*
116
* Prints USB2 controller registers, PHY status, and VBUS pin state
117
* to help diagnose USB Host issues.
118
*/
119
void
USB_HostDumpRegisters(
void
);
120
121
#ifdef __cplusplus
122
}
123
#endif
124
125
#endif
/* _USB_MSD_HOST_H_ */
OS_SEM
Semaphores are used to control access to shared resources or or to communicate between tasks in a mul...
Definition
nbrtos.h:407
examples
PlatformSpecific
SOMRT1061
USB
USB_MSD_Host
src
include
usb_msd_host.h
Generated by
1.18.0