forked from espressif/arduino-esp32
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUSBMSC.h
57 lines (46 loc) · 1.95 KB
/
USBMSC.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include"soc/soc_caps.h"
#if SOC_USB_OTG_SUPPORTED
#include<stdint.h>
#include<stdbool.h>
#include"sdkconfig.h"
#if CONFIG_TINYUSB_MSC_ENABLED
// Invoked when received Start Stop Unit command
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
typedefbool (*msc_start_stop_cb)(uint8_t power_condition, bool start, bool load_eject);
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
typedefint32_t (*msc_read_cb)(uint32_t lba, uint32_t offset, void *buffer, uint32_t bufsize);
// Process data in buffer to disk's storage and return number of written bytes
typedefint32_t (*msc_write_cb)(uint32_t lba, uint32_t offset, uint8_t *buffer, uint32_t bufsize);
classUSBMSC {
public:
USBMSC();
~USBMSC();
boolbegin(uint32_t block_count, uint16_t block_size);
voidend();
voidvendorID(constchar *vid); //max 8 chars
voidproductID(constchar *pid); //max 16 chars
voidproductRevision(constchar *ver); //max 4 chars
voidmediaPresent(bool media_present);
voidisWritable(bool is_writable);
voidonStartStop(msc_start_stop_cb cb);
voidonRead(msc_read_cb cb);
voidonWrite(msc_write_cb cb);
private:
uint8_t _lun;
};
#endif/* CONFIG_TINYUSB_MSC_ENABLED */
#endif/* SOC_USB_OTG_SUPPORTED */