Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
usbStorage.c File Reference
#include <ch.h>
#include <hal.h>
#include "usb_msd.h"
#include "usbStorage.h"
#include "modules/loggers/sdlog_chibios.h"
#include <stdio.h>
#include <string.h>
#include "main_chibios.h"
#include "mcu_periph/sdio.h"
+ Include dependency graph for usbStorage.c:

Go to the source code of this file.

Macros

#define USB_MS_DATA_EP   1
 
#define MCU_RESTART()   {*((unsigned long *)0x0E000ED0C) = 0x05FA0004;}
 

Functions

static uint8_t nibbleToHex (uint8_t nibble)
 
static void populateSerialNumberDescriptorData (void)
 
static void thdUsbStorage (void *arg)
 
static const USBDescriptor * getDescriptor (USBDriver *usbp, uint8_t type, uint8_t index, uint16_t lang)
 
static void usbEvent (USBDriver *usbp, usbevent_t event)
 
static void usbActivity (bool active)
 
static THD_WORKING_AREA (waThdUsbStorage, 1024)
 
void usbStorageStartPolling (void)
 
void usbStorageWaitForDeconnexion (void)
 
void usbStorageStop (void)
 
bool usbStorageIsItRunning (void)
 

Variables

static thread_t * usbStorageThreadPtr = NULL
 
static USBMassStorageDriver UMSD1
 
static bool isRunning = false
 
static const uint8_t deviceDescriptorData []
 
static const USBDescriptor deviceDescriptor
 
static const uint8_t configurationDescriptorData []
 
static const USBDescriptor configurationDescriptor
 
static const uint8_t languageDescriptorData []
 
static const USBDescriptor languageDescriptor
 
static const uint8_t vendorDescriptorData []
 
static const USBDescriptor vendorDescriptor
 
static const uint8_t productDescriptorData []
 
static const USBDescriptor productDescriptor
 
uint8_t serialNumberDescriptorData [50]
 
static const USBDescriptor serialNumberDescriptor
 
const USBConfig usbConfig
 
static USBMassStorageConfig msdConfig
 

Macro Definition Documentation

#define MCU_RESTART ( )    {*((unsigned long *)0x0E000ED0C) = 0x05FA0004;}

Definition at line 48 of file usbStorage.c.

Referenced by thdUsbStorage().

#define USB_MS_DATA_EP   1

Definition at line 46 of file usbStorage.c.

Function Documentation

static const USBDescriptor* getDescriptor ( USBDriver *  usbp,
uint8_t  type,
uint8_t  index,
uint16_t  lang 
)
static
static uint8_t nibbleToHex ( uint8_t  nibble)
static

Definition at line 344 of file usbStorage.c.

Referenced by populateSerialNumberDescriptorData().

+ Here is the caller graph for this function:

static void populateSerialNumberDescriptorData ( void  )
static

Definition at line 351 of file usbStorage.c.

References nibbleToHex().

Referenced by usbStorageStartPolling().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static THD_WORKING_AREA ( waThdUsbStorage  ,
1024   
)
static
static void thdUsbStorage ( void *  arg)
static

Definition at line 269 of file usbStorage.c.

References USBMassStorageDriver::evt_connected, GPIOA, GPIOA_OTG_FS_VBUS, isRunning, MCU_RESTART, msdInit(), msdStart(), msdStop(), pprz_terminate_autopilot_threads(), sdio_connect(), sdio_disconnect(), and sdlog_chibios_finish().

Referenced by usbStorageStartPolling().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void usbActivity ( bool  active)
static

Definition at line 224 of file usbStorage.c.

References GPIOC, and GPIOC_LED4.

static void usbEvent ( USBDriver *  usbp,
usbevent_t  event 
)
static

Definition at line 194 of file usbStorage.c.

References msdConfigureHookI().

+ Here is the call graph for this function:

bool usbStorageIsItRunning ( void  )

Definition at line 339 of file usbStorage.c.

References isRunning.

Referenced by thd_startlog().

+ Here is the caller graph for this function:

void usbStorageStartPolling ( void  )

Definition at line 242 of file usbStorage.c.

References populateSerialNumberDescriptorData(), thdUsbStorage(), and usbStorageThreadPtr.

Referenced by sdlog_chibios_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void usbStorageStop ( void  )

Definition at line 259 of file usbStorage.c.

References usbStorageThreadPtr.

void usbStorageWaitForDeconnexion ( void  )

Definition at line 251 of file usbStorage.c.

References usbStorageThreadPtr.

Variable Documentation

const USBDescriptor configurationDescriptor
static
Initial value:
= {
}
static const uint8_t configurationDescriptorData[]
Definition: usbStorage.c:74

Definition at line 116 of file usbStorage.c.

Referenced by getDescriptor().

const uint8_t configurationDescriptorData[]
static

Definition at line 74 of file usbStorage.c.

const USBDescriptor deviceDescriptor
static
Initial value:
= {
}
static const uint8_t deviceDescriptorData[]
Definition: usbStorage.c:51

Definition at line 68 of file usbStorage.c.

Referenced by getDescriptor().

const uint8_t deviceDescriptorData[]
static
Initial value:
= {
USB_DESC_DEVICE
(
0x0200,
0x00,
0x00,
0x00,
64,
0x0483,
0x5740,
0x0100,
1,
2,
3,
1
)
}

Definition at line 51 of file usbStorage.c.

bool isRunning = false
static

Definition at line 43 of file usbStorage.c.

Referenced by thdUsbStorage(), and usbStorageIsItRunning().

const USBDescriptor languageDescriptor
static
Initial value:
= {
}
static const uint8_t languageDescriptorData[]
Definition: usbStorage.c:122

Definition at line 127 of file usbStorage.c.

Referenced by getDescriptor().

const uint8_t languageDescriptorData[]
static
Initial value:
= {
USB_DESC_BYTE(4),
USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
USB_DESC_WORD(0x0409)
}

Definition at line 122 of file usbStorage.c.

USBMassStorageConfig msdConfig
static
Initial value:
= {
&USBD1,
(BaseBlockDevice *) &SDCD1,
"DPprz_sd",
"DApogee",
"0.1"
}
static void usbActivity(bool active)
Definition: usbStorage.c:224
#define USB_MS_DATA_EP
Definition: usbStorage.c:46

Definition at line 230 of file usbStorage.c.

const USBDescriptor productDescriptor
static
Initial value:
= {
}
static const uint8_t productDescriptorData[]
Definition: usbStorage.c:144

Definition at line 149 of file usbStorage.c.

Referenced by getDescriptor().

const uint8_t productDescriptorData[]
static
Initial value:
= {
USB_DESC_BYTE(20),
USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
'A', 0, 'u', 0, 't', 0, 'o', 0, 'p', 0, 'i', 0, 'l', 0, 'o', 0, 't', 0
}

Definition at line 144 of file usbStorage.c.

const USBDescriptor serialNumberDescriptor
static
Initial value:
= {
}
uint8_t serialNumberDescriptorData[50]
Definition: usbStorage.c:158

Definition at line 163 of file usbStorage.c.

Referenced by getDescriptor().

uint8_t serialNumberDescriptorData[50]
Initial value:
= {
USB_DESC_BYTE(50),
USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
0
}

Definition at line 158 of file usbStorage.c.

USBMassStorageDriver UMSD1
static

Definition at line 42 of file usbStorage.c.

const USBConfig usbConfig
Initial value:
= {
0
}
static void usbEvent(USBDriver *usbp, usbevent_t event)
Definition: usbStorage.c:194
static const USBDescriptor * getDescriptor(USBDriver *usbp, uint8_t type, uint8_t index, uint16_t lang)
Definition: usbStorage.c:169
bool msdRequestsHook(USBDriver *usbp)
Default requests hook.
Definition: usb_msd.c:188

Definition at line 216 of file usbStorage.c.

thread_t* usbStorageThreadPtr = NULL
static
const USBDescriptor vendorDescriptor
static
Initial value:
= {
}
static const uint8_t vendorDescriptorData[]
Definition: usbStorage.c:133

Definition at line 138 of file usbStorage.c.

Referenced by getDescriptor().

const uint8_t vendorDescriptorData[]
static
Initial value:
= {
USB_DESC_BYTE(20),
USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
'P', 0, 'a', 0, 'p', 0, 'a', 0, 'r', 0, 'a', 0, 'z', 0, 'z', 0, 'i', 0
}

Definition at line 133 of file usbStorage.c.