forked from arpruss/USBComposite_stm32f1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
USBMassStorage.cpp
44 lines (36 loc) · 1.08 KB
/
USBMassStorage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "USBComposite.h"
#include "usb_mass.h"
#include "usb_mass_mal.h"
#include "usb_composite_serial.h"
#include <string.h>
void USBMassStorage::begin() {
if(!enabled) {
USBComposite.clear();
registerComponent();
USBComposite.begin();
enabled = true;
}
}
void USBMassStorage::end() {
USBComposite.end();
}
void USBMassStorage::loop() {
usb_mass_loop();
}
bool USBMassStorage::registerComponent() {
return USBComposite.add(&usbMassPart, this);
}
void USBMassStorage::setDriveData(uint32 driveNumber, uint32 numSectors, MassStorageReader reader,
MassStorageWriter writer, MassStorageStatuser statuser, MassStorageInitializer initializer) {
if (driveNumber >= USB_MASS_MAX_DRIVES)
return;
usb_mass_drives[driveNumber].blockCount = numSectors;
usb_mass_drives[driveNumber].read = reader;
usb_mass_drives[driveNumber].write = writer;
usb_mass_drives[driveNumber].status = statuser;
usb_mass_drives[driveNumber].init = initializer;
usb_mass_drives[driveNumber].format = initializer;
}
void USBMassStorage::clearDrives() {
memset(usb_mass_drives, 0, sizeof(usb_mass_drives));
}