|
@ -117,6 +117,17 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev) { |
|
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; |
|
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; |
|
|
GPIO_Init(GPIOA, &GPIO_InitStructure); |
|
|
GPIO_Init(GPIOA, &GPIO_InitStructure); |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
// Configure ID pin (only in host mode)
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; |
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; |
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; |
|
|
|
|
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; |
|
|
|
|
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ; |
|
|
|
|
|
GPIO_Init(GPIOA, &GPIO_InitStructure); |
|
|
|
|
|
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_OTG_FS); |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); |
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); |
|
|
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE); |
|
|
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE); |
|
|
} |
|
|
} |
|
@ -137,6 +148,84 @@ void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev) { |
|
|
NVIC_Init(&NVIC_InitStructure); |
|
|
NVIC_Init(&NVIC_InitStructure); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief BSP_Drive_VBUS |
|
|
|
|
|
* Drives the Vbus signal through IO |
|
|
|
|
|
* @param state : VBUS states |
|
|
|
|
|
* @retval None |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev, uint8_t state) { |
|
|
|
|
|
//printf("DriveVBUS %p %u\n", pdev, state);
|
|
|
|
|
|
/*
|
|
|
|
|
|
On-chip 5 V VBUS generation is not supported. For this reason, a charge pump |
|
|
|
|
|
or, if 5 V are available on the application board, a basic power switch, must |
|
|
|
|
|
be added externally to drive the 5 V VBUS line. The external charge pump can |
|
|
|
|
|
be driven by any GPIO output. When the application decides to power on VBUS |
|
|
|
|
|
using the chosen GPIO, it must also set the port power bit in the host port |
|
|
|
|
|
control and status register (PPWR bit in OTG_FS_HPRT). |
|
|
|
|
|
|
|
|
|
|
|
Bit 12 PPWR: Port power |
|
|
|
|
|
The application uses this field to control power to this port, and the core |
|
|
|
|
|
clears this bit on an overcurrent condition. |
|
|
|
|
|
*/ |
|
|
|
|
|
#if 0 // not implemented
|
|
|
|
|
|
#ifndef USE_USB_OTG_HS |
|
|
|
|
|
if (0 == state) { |
|
|
|
|
|
/* DISABLE is needed on output of the Power Switch */ |
|
|
|
|
|
GPIO_SetBits(HOST_POWERSW_PORT, HOST_POWERSW_VBUS); |
|
|
|
|
|
} else { |
|
|
|
|
|
/*ENABLE the Power Switch by driving the Enable LOW */ |
|
|
|
|
|
GPIO_ResetBits(HOST_POWERSW_PORT, HOST_POWERSW_VBUS); |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief USB_OTG_BSP_ConfigVBUS |
|
|
|
|
|
* Configures the IO for the Vbus and OverCurrent |
|
|
|
|
|
* @param None |
|
|
|
|
|
* @retval None |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev) { |
|
|
|
|
|
//printf("ConfigVBUS %p\n", pdev);
|
|
|
|
|
|
#if 0 // not implemented
|
|
|
|
|
|
#ifdef USE_USB_OTG_FS |
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_STM3210C_EVAL |
|
|
|
|
|
RCC_APB2PeriphClockCmd(HOST_POWERSW_PORT_RCC, ENABLE); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Configure Power Switch Vbus Pin */ |
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = HOST_POWERSW_VBUS; |
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; |
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; |
|
|
|
|
|
GPIO_Init(HOST_POWERSW_PORT, &GPIO_InitStructure); |
|
|
|
|
|
#else |
|
|
|
|
|
#ifdef USE_USB_OTG_FS |
|
|
|
|
|
RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOH , ENABLE); |
|
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = HOST_POWERSW_VBUS; |
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; |
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; |
|
|
|
|
|
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; |
|
|
|
|
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; |
|
|
|
|
|
GPIO_Init(HOST_POWERSW_PORT,&GPIO_InitStructure); |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/* By Default, DISABLE is needed on output of the Power Switch */ |
|
|
|
|
|
GPIO_SetBits(HOST_POWERSW_PORT, HOST_POWERSW_VBUS); |
|
|
|
|
|
|
|
|
|
|
|
USB_OTG_BSP_mDelay(200); /* Delay is need for stabilising the Vbus Low
|
|
|
|
|
|
in Reset Condition, when Vbus=1 and Reset-button is pressed by user */ |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* @brief USB_OTG_BSP_uDelay |
|
|
* @brief USB_OTG_BSP_uDelay |
|
|
* This function provides delay time in micro sec |
|
|
* This function provides delay time in micro sec |
|
|