예제 #1
0
파일: pios_usb.c 프로젝트: Crash1/TauLabs
int32_t PIOS_USB_Init(uint32_t * usb_id, const struct pios_usb_cfg * cfg)
{
	PIOS_Assert(usb_id);
	PIOS_Assert(cfg);

	struct pios_usb_dev * usb_dev;

	usb_dev = (struct pios_usb_dev *) PIOS_USB_alloc();
	if (!usb_dev) goto out_fail;

	/* Bind the configuration to the device instance */
	usb_dev->cfg = cfg;

	PIOS_USB_Reenumerate();

	/*
	 * This is a horrible hack to make this available to
	 * the interrupt callbacks.  This should go away ASAP.
	 */
	pios_usb_com_id = (uint32_t) usb_dev;

	/* Enable the USB Interrupts */
	NVIC_Init((NVIC_InitTypeDef*)&usb_dev->cfg->irq.init);

	/* Configure USB D-/D+ (DM/DP) pins */
	GPIO_InitTypeDef GPIO_InitStructure;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_14);
	GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14);

	/* Configure VBUS sense pin */
	if (usb_dev->cfg->vsense.gpio)
		GPIO_Init(usb_dev->cfg->vsense.gpio, (GPIO_InitTypeDef*)&usb_dev->cfg->vsense.init);

	/* Select USBCLK source */
	RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
	/* Enable the USB clock */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);

	USB_Init();
	USB_SIL_Init();

	*usb_id = (uint32_t) usb_dev;

	return 0;		/* No error */

out_fail:
	return(-1);
}
예제 #2
0
void HID_init(void)
{
  pInformation->Current_Configuration = 0;
  /* Connect the device */
  PowerOn();

  /* Perform basic device initialization operations */
  USB_SIL_Init();

  bDeviceState = UNCONNECTED;
}
예제 #3
0
파일: usb_prop.c 프로젝트: 9zigen/stm32
/*******************************************************************************
    Function Name  : USBdev_Init.
    Description    : USB device init routine.
    Input          : None.
    Output         : None.
    Return         : None.
*******************************************************************************/
void USBdev_Init() {
	// Update the serial number string descriptor with the data from the unique ID
	Get_SerialNum();
	// Initialize the current configuration
	pInformation->Current_Configuration = 0;
	// Connect the device
	PowerOn();
	// Perform basic device initialization operations
	USB_SIL_Init();
	bDeviceState = UNCONNECTED;
}
예제 #4
0
파일: usb_prop.c 프로젝트: kaaLabs15/LoRa
/******************************************************************************
 * @brief	CDC init routine.
 */
void CDC_Init(void)
{
	Get_SerialNum();		/* Update the serial number string descriptor with the data from the unique ID */
	pInformation->Current_Configuration = 0;

	USB_Config();

	PowerOn();				/* Connect the device */
	USB_SIL_Init();			/* Perform basic device initialization operations */

	pInformation->bDeviceState = UNCONNECTED;
}
예제 #5
0
파일: usb_prop.c 프로젝트: x893/OpenBLT
/************************************************************************************//**
** \brief     USB device initialization function.
** \return    none.
**
****************************************************************************************/
void Bulk_Init(void)
{
  /* update the serial number string descriptor with the data from the unique ID*/
  UsbGetSerialNum();
  /* set default configuration */
  pInformation->Current_Configuration = 0;
  /* connect the device */
  PowerOn();
  /* perform basic device initialization operations */
  USB_SIL_Init();
  /* set default state */
  bDeviceState = UNCONNECTED;
} /*** end of Bulk_Init ***/
예제 #6
0
/*******************************************************************************
* Function Name  : USB_init
* Description    : USB init routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void USB_init()
{
  usb_InitDescriptors();

  pInformation->Current_Configuration = 0;

  /* Connect the device */
  PowerOn();

  /* Perform basic device initialization operations */
  USB_SIL_Init();

  bDeviceState = UNCONNECTED;
}
/*******************************************************************************
* Function Name  : CustomHID_init.
* Description    : Custom HID init routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
static void composite_cdc_hid_init(void)
{
  /* Update the serial number string descriptor with the data from the unique 
  ID*/
  Get_SerialNum();
    
  pInformation->Current_Configuration = 0;
  /* Connect the device */
  PowerOn();

  /* Perform basic device initialization operations */
  USB_SIL_Init();

  bDeviceState = UNCONNECTED;
}
/**
  * @brief  Joystick Mouse init routine.
  * @param  None
  * @retval None
  */
void Joystick_init(void)
{

    /* Update the serial number string descriptor with the data from the unique
    ID*/
    Get_SerialNum();

    pInformation->Current_Configuration = 0;
    /* Connect the device */
    PowerOn();

    /* Perform basic device initialization operations */
    USB_SIL_Init(wInterrupt_Mask = IMR_MSK);

    bDeviceState = UNCONNECTED;
}
예제 #9
0
// Инициализация USB-девайса
void SomeDev_init()
{
	// Получаем серийный номер
	Get_SerialNum();
	
	// Задаем текущую конфигурацию
	pInformation->Current_Configuration = 0;
	
	// Подключение 
	PowerOn();
	
	// Основные инициализации
	USB_SIL_Init();
	
	bDeviceState = UNCONNECTED;
}
예제 #10
0
/*******************************************************************************
* Function Name  : Speaker_init.
* Description    : Speaker init routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Speaker_init()
{
  /* Update the serial number string descriptor with the data from the unique
  ID*/
  Get_SerialNum();

  /* Initialize the current configuration */
  pInformation->Current_Configuration = 0;

  /* Connect the device */
  PowerOn();

  /* Perform basic device initialization operations */
  USB_SIL_Init();

  bDeviceState = UNCONNECTED;
}
예제 #11
0
/*******************************************************************************
 * Function Name  : Virtual_Com_Port_init.
 * Description    : Virtual COM Port Mouse init routine.
 * Input          : None.
 * Output         : None.
 * Return         : None.
 *******************************************************************************/
void Virtual_Com_Port_init(void) {

	/* Update the serial number string descriptor with the data from the unique
	 ID*/
	Get_SerialNum();

	pInformation->Current_Configuration = 0;

	/* Connect the device */
	PowerOn();

	/* Perform basic device initialization operations */
	USB_SIL_Init();

	/* configure the USART to the default settings */
	//USART_Config_Default();
	bDeviceState = UNCONNECTED;
}
예제 #12
0
/*******************************************************************************
* Function Name  : DFU_init.
* Description    : DFU init routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void DFU_init(void)
{
  DEVICE_INFO *pInfo = &Device_Info;

  /* Update the serial number string descriptor with the data from the unique ID*/
  Get_SerialNum();

  pInfo->Current_Configuration = 0;

  /* Connect the device */
  PowerOn();

  /* Perform basic device initialization operations */
  USB_SIL_Init();

  /* Enable USB interrupts */
  USB_Interrupts_Config();

  bDeviceState = UNCONNECTED;
}
예제 #13
0
int32_t PIOS_USB_Init(uint32_t *usb_id, const struct pios_usb_cfg *cfg)
{
    PIOS_Assert(usb_id);
    PIOS_Assert(cfg);

    struct pios_usb_dev *usb_dev;

    usb_dev = (struct pios_usb_dev *)PIOS_USB_alloc();
    if (!usb_dev) {
        goto out_fail;
    }

    /* Bind the configuration to the device instance */
    usb_dev->cfg = cfg;

    PIOS_USB_Reenumerate();

    /*
     * This is a horrible hack to make this available to
     * the interrupt callbacks.  This should go away ASAP.
     */
    pios_usb_com_id = (uint32_t)usb_dev;

    /* Enable the USB Interrupts */
    NVIC_Init(&usb_dev->cfg->irq.init);

    /* Select USBCLK source */
    RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
    /* Enable the USB clock */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);

    USB_Init();
    USB_SIL_Init();

    *usb_id = (uint32_t)usb_dev;

    return 0; /* No error */

out_fail:
    return -1;
}