Files
edgetx-gx12/radio/src/targets/taranis/usb_driver.c
T
Kyle Manna da8160f1ff permissions: Remove execute bit from src files
* Remove the execute permission on all c, cpp, and header files.
* These files will never need to be executed.
2014-11-19 09:52:44 -08:00

93 lines
2.4 KiB
C

/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* opentx is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "board_taranis.h"
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h"
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_bsp.h"
int usbPlugged(void)
{
//debounce
static uint8_t debounced_state = 0;
static uint8_t last_state = 0;
if ( GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS) ) {
if (last_state) debounced_state = 1;
last_state = 1;
}
else {
if (!last_state) debounced_state = 0;
last_state = 0;
}
return debounced_state;
}
USB_OTG_CORE_HANDLE USB_OTG_dev;
void OTG_FS_IRQHandler(void)
{
USBD_OTG_ISR_Handler (&USB_OTG_dev);
}
void usbInit(void)
{
USB_OTG_BSP_Init(&USB_OTG_dev);
}
void usbStart(void)
{
#if !defined(BOOT)
#if defined(USB_JOYSTICK)
//intialize USB as HID device
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_cb, &USR_cb);
#elif defined(USB_MASS_STORAGE)
//intialize USB as MSC device
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
#endif
#else
//intialize USB as MSC device
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb);
#endif //!defined(BOOT)
}
#if defined(USB_JOYSTICK)
void usbStop(void)
{
USBD_DeInit(&USB_OTG_dev);
}
#endif