aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/os/hal/include/usbh/dev/msd.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/os/hal/include/usbh/dev/msd.h')
-rw-r--r--lib/chibios-contrib/os/hal/include/usbh/dev/msd.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/hal/include/usbh/dev/msd.h b/lib/chibios-contrib/os/hal/include/usbh/dev/msd.h
new file mode 100644
index 000000000..6b10b469e
--- /dev/null
+++ b/lib/chibios-contrib/os/hal/include/usbh/dev/msd.h
@@ -0,0 +1,105 @@
1/*
2 ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
3 Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail)
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16*/
17
18#ifndef USBH_MSD_H_
19#define USBH_MSD_H_
20
21#include "hal_usbh.h"
22
23#if HAL_USE_USBH && HAL_USBH_USE_MSD
24
25/* TODO:
26 *
27 * - Implement of conditional compilation of multiple-luns per instance.
28 *
29 */
30
31
32/*===========================================================================*/
33/* Driver pre-compile time settings. */
34/*===========================================================================*/
35
36
37/*===========================================================================*/
38/* Derived constants and error checks. */
39/*===========================================================================*/
40
41
42/*===========================================================================*/
43/* Driver data structures and types. */
44/*===========================================================================*/
45
46#define _usbhmsd_driver_methods \
47 _base_block_device_methods
48
49struct USBHMassStorageDriverVMT {
50 _usbhmsd_driver_methods
51};
52
53typedef struct USBHMassStorageLUNDriver USBHMassStorageLUNDriver;
54typedef struct USBHMassStorageDriver USBHMassStorageDriver;
55
56struct USBHMassStorageLUNDriver {
57 /* inherited from abstract block driver */
58 const struct USBHMassStorageDriverVMT *vmt;
59 _base_block_device_data
60
61 /* for serializing access to the LUN driver */
62 semaphore_t sem;
63
64 BlockDeviceInfo info;
65 USBHMassStorageDriver *msdp;
66
67 USBHMassStorageLUNDriver *next;
68};
69
70
71/*===========================================================================*/
72/* Driver macros. */
73/*===========================================================================*/
74
75/*===========================================================================*/
76/* External declarations. */
77/*===========================================================================*/
78
79extern USBHMassStorageLUNDriver MSBLKD[HAL_USBHMSD_MAX_LUNS];
80
81#ifdef __cplusplus
82extern "C" {
83#endif
84 /* Mass Storage LUN Driver (block driver) */
85// void usbhmsdLUNStart(USBHMassStorageLUNDriver *lunp);
86// void usbhmsdLUNStop(USBHMassStorageLUNDriver *lunp);
87 bool usbhmsdLUNConnect(USBHMassStorageLUNDriver *lunp);
88 bool usbhmsdLUNDisconnect(USBHMassStorageLUNDriver *lunp);
89 bool usbhmsdLUNRead(USBHMassStorageLUNDriver *lunp, uint32_t startblk,
90 uint8_t *buffer, uint32_t n);
91 bool usbhmsdLUNWrite(USBHMassStorageLUNDriver *lunp, uint32_t startblk,
92 const uint8_t *buffer, uint32_t n);
93 bool usbhmsdLUNSync(USBHMassStorageLUNDriver *lunp);
94 bool usbhmsdLUNGetInfo(USBHMassStorageLUNDriver *lunp, BlockDeviceInfo *bdip);
95 bool usbhmsdLUNIsInserted(USBHMassStorageLUNDriver *lunp);
96 bool usbhmsdLUNIsProtected(USBHMassStorageLUNDriver *lunp);
97
98 USBHDriver *usbhmsdLUNGetHost(const USBHMassStorageLUNDriver *lunp);
99#ifdef __cplusplus
100}
101#endif
102
103#endif
104
105#endif /* USBH_MSD_H_ */