46 #define USB_MS_DATA_EP 1
48 #define MCU_RESTART() {*((unsigned long *)0x0E000ED0C) = 0x05FA0004;}
76 USB_DESC_CONFIGURATION
102 USB_EP_MODE_TYPE_BULK,
111 USB_EP_MODE_TYPE_BULK,
118 configurationDescriptorData
124 USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
125 USB_DESC_WORD(0x0409)
129 languageDescriptorData
135 USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
136 'P', 0,
'a', 0,
'p', 0,
'a', 0,
'r', 0,
'a', 0,
'z', 0,
'z', 0,
'i', 0
146 USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
147 'A', 0,
'u', 0,
't', 0,
'o', 0,
'p', 0,
'i', 0,
'l', 0,
'o', 0,
't', 0
151 productDescriptorData
160 USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
165 serialNumberDescriptorData
175 case USB_DESCRIPTOR_DEVICE:
178 case USB_DESCRIPTOR_CONFIGURATION:
181 case USB_DESCRIPTOR_STRING:
194 static void usbEvent(USBDriver *usbp, usbevent_t event)
199 case USB_EVENT_CONFIGURED:
202 chSysUnlockFromISR();
205 case USB_EVENT_RESET:
206 case USB_EVENT_ADDRESS:
207 case USB_EVENT_SUSPEND:
208 case USB_EVENT_WAKEUP:
209 case USB_EVENT_STALLED:
232 (BaseBlockDevice *) &SDCD1,
273 chRegSetThreadName(
"UsbStorage:polling");
275 event_listener_t connected;
282 while (!chThdShouldTerminateX() && antiBounce) {
290 chThdSleepMilliseconds(20);
293 chRegSetThreadName(
"UsbStorage:connected");
301 chThdExit(MSG_TIMEOUT);
311 usbDisconnectBus(&USBD1);
312 chThdSleepMilliseconds(1000);
313 usbStart(&USBD1, &usbConfig);
314 usbConnectBus(&USBD1);
317 chEvtRegisterMask(&UMSD1.
evt_connected, &connected, EVENT_MASK(1));
318 chEvtWaitOne(EVENT_MASK(1));
325 chThdSleepMilliseconds(10);
330 usbDisconnectBus(&USBD1);
331 chThdSleepMilliseconds(500);
347 return nibble < 10 ? nibble +
'0' : nibble +
'A' - 10;
354 const uint8_t UniqProcessorIdLen = 12;
356 uint8_t *baseDdPtr = &serialNumberDescriptorData[2];
357 for (
uint32_t i = 0; i < UniqProcessorIdLen; i++) {
358 *baseDdPtr++ =
nibbleToHex(UniqProcessorId[i] >> 4);
void msdStop(USBMassStorageDriver *msdp)
Stops a USB mass storage driver.
static void usbActivity(bool active)
void msdConfigureHookI(USBMassStorageDriver *msdp)
USB device configured handler.
arch independent SDIO API
static uint8_t nibbleToHex(uint8_t nibble)
void msdInit(USBMassStorageDriver *msdp)
Initializse a USB mass storage driver.
static void usbEvent(USBDriver *usbp, usbevent_t event)
bool sdio_disconnect(void)
Disconnect a SD card on SDIO peripheral.
static const USBDescriptor languageDescriptor
event_source_t evt_connected
static const USBDescriptor deviceDescriptor
static const uint8_t productDescriptorData[]
static const USBDescriptor serialNumberDescriptor
static thread_t * usbStorageThreadPtr
bool sdio_connect(void)
Connect a SD card on SDIO peripheral.
static const uint8_t languageDescriptorData[]
static const USBDescriptor configurationDescriptor
USB mass storage driver structure.
static void thdUsbStorage(void *arg)
Driver configuration structure.
void usbStorageStartPolling(void)
static void populateSerialNumberDescriptorData(void)
static USBMassStorageConfig msdConfig
uint8_t serialNumberDescriptorData[50]
static const uint8_t vendorDescriptorData[]
static USBMassStorageDriver UMSD1
void usbStorageWaitForDeconnexion(void)
static const USBDescriptor * getDescriptor(USBDriver *usbp, uint8_t type, uint8_t index, uint16_t lang)
bool usbStorageIsItRunning(void)
void sdlog_chibios_finish(bool flush)
void usbStorageStop(void)
static THD_WORKING_AREA(waThdUsbStorage, 1024)
static const USBDescriptor vendorDescriptor
static const USBDescriptor productDescriptor
void msdStart(USBMassStorageDriver *msdp, const USBMassStorageConfig *config)
Starts a USB mass storage driver.
void pprz_terminate_autopilot_threads(void)
Terminate all autopilot threads Wait until proper stop.
const USBConfig usbConfig
bool msdRequestsHook(USBDriver *usbp)
Default requests hook.
static const uint8_t configurationDescriptorData[]
static const uint8_t deviceDescriptorData[]
#define GPIOA_OTG_FS_VBUS