Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
usb_msd.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 Gautier Hattenberger, Alexandre Bustico
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22/*
23 * @file modules/loggers/sdlog_chibios/usb_msd.h
24 *
25 */
26
27#pragma once
28
29
30#include "ch.h"
31#include "hal.h"
32#include "chdebug.h"
34
35#define PACK_STRUCT_STRUCT __attribute__((packed))
36#define PACK_STRUCT_BEGIN
37#define PACK_STRUCT_END
38
39/* endpoint index */
40#define USB_MS_DATA_EP 1
41
42
43
44#define USBD USBD1
45
46#define SEM_TAKEN
47#define SEM_RELEASED
48
49#define EVT_USB_RESET (1 << 0)
50#define EVT_BOT_RESET (1 << 1)
51#define EVT_SEM_TAKEN (1 << 2)
52#define EVT_SEM_RELEASED (1 << 3)
53#define EVT_USB_CONFIGURED (1 << 4)
54#define EVT_SCSI_REQ_TEST_UNIT_READY (1 << 5)
55#define EVT_SCSI_REQ_READ_FMT_CAP (1 << 6)
56#define EVT_SCSI_REQ_SENSE6 (1 << 7)
57#define EVT_SCSI_REQ_SENSE10 (1 << 8)
58#define EVT_WAIT_FOR_COMMAND_BLOCK (1 << 9)
59#define EVT_SCSI_REQ_SEND_DIAGNOSTIC (1 << 10)
60#define EVT_SCSI_REQ_READ_CAP10 (1 << 11)
61#define EVT_SCSI_PROC_INQ (1 << 12)
62
66PACK_STRUCT_BEGIN typedef struct {
73 uint8_t scsi_cmd_data[16];
75
79PACK_STRUCT_BEGIN typedef struct {
80 uint32_t signature;
81 uint32_t tag;
85
89PACK_STRUCT_BEGIN typedef struct {
90 uint8_t byte[18];
92
96PACK_STRUCT_BEGIN typedef struct {
105 uint8_t vendor_id[8];
106 uint8_t product_id[16];
107 uint8_t product_rev[4];
109
119
123typedef struct {
128
133
138
145 void (*rw_activity_callback)(bool);
146
151 uint8_t short_vendor_id[8];
152
157 uint8_t short_product_id[16];
158
163 uint8_t short_product_version[4];
164
166
187
188#ifdef __cplusplus
189extern "C" {
190#endif
191
196
205
212
221
236bool msdRequestsHook(USBDriver *usbp);
237
238
240void deinit_msd_driver(void);
241
247
255
256
257#ifdef __cplusplus
258}
259#endif
uint16_t foo
Definition main_demo5.c:58
static const struct usb_config_descriptor config
Definition usb_ser_hw.c:200
Driver configuration structure.
Definition usb_msd.h:123
BaseBlockDevice * bbdp
Block device to use for storage.
Definition usb_msd.h:132
usbep_t bulk_ep
Index of the USB endpoint to use for transfers.
Definition usb_msd.h:137
USBDriver * usbp
USB driver to use for communication.
Definition usb_msd.h:127
static USBMassStorageConfig msdConfig
Definition usbStorage.c:64
const USBMassStorageConfig * config
Definition usb_msd.h:173
msd_scsi_sense_response_t sense
Definition usb_msd.h:181
bool reconfigured_or_reset_event
Definition usb_msd.h:183
uint32_t signature
Definition usb_msd.h:67
bool msdRequestsHook(USBDriver *usbp)
Default requests hook.
Definition usb_msd.c:205
void init_msd_driver(void *dbgThreadPtr, USBMassStorageConfig *msdConfig)
Definition usb_msd.c:1126
BlockDeviceInfo block_dev_info
Definition usb_msd.h:177
#define PACK_STRUCT_END
Definition usb_msd.h:37
msd_state_t state
Definition usb_msd.h:178
uint8_t response_data_format
Definition usb_msd.h:100
uint8_t peripheral
Definition usb_msd.h:97
uint8_t removable
Definition usb_msd.h:98
uint8_t version
Definition usb_msd.h:99
#define PACK_STRUCT_BEGIN
Definition usb_msd.h:36
void msdStart(USBMassStorageDriver *msdp, const USBMassStorageConfig *config)
Starts a USB mass storage driver.
Definition usb_msd.c:855
uint8_t scsi_cmd_len
Definition usb_msd.h:72
msd_scsi_inquiry_response_t inquiry
Definition usb_msd.h:182
void msdInit(USBMassStorageDriver *msdp)
Initializes a USB mass storage driver.
Definition usb_msd.c:815
void msdConfigureHookI(USBMassStorageDriver *msdp)
USB device configured handler.
Definition usb_msd.c:188
void msd_register_evt_connected(event_listener_t *elp, eventmask_t mask)
register connected event source in local event mask
Definition usb_msd.c:1144
void msd_register_evt_ejected(event_listener_t *elp, eventmask_t mask)
register ejected event source in local event mask
Definition usb_msd.c:1149
event_source_t evt_connected
Definition usb_msd.h:176
void msdStop(USBMassStorageDriver *msdp)
Stops a USB mass storage driver.
Definition usb_msd.c:900
uint8_t additional_length
Definition usb_msd.h:101
uint32_t data_residue
Definition usb_msd.h:82
thread_t * thread
Definition usb_msd.h:175
uint32_t data_len
Definition usb_msd.h:69
void deinit_msd_driver(void)
Definition usb_msd.c:1121
binary_semaphore_t bsem
Definition usb_msd.h:174
msd_state_t
Possible states for the USB mass storage driver.
Definition usb_msd.h:113
@ MSD_READ_COMMAND_BLOCK
Definition usb_msd.h:115
@ MSD_IDLE
Definition usb_msd.h:114
@ MSD_EJECTED
Definition usb_msd.h:116
@ MSD_BOT_RESET
Definition usb_msd.h:117
Response to a READ_CAPACITY_10 SCSI command.
Definition usb_msd.c:113
USB mass storage driver structure.
Definition usb_msd.h:172
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.