本文整理汇总了C++中USB_Cable_Config函数的典型用法代码示例。如果您正苦于以下问题:C++ USB_Cable_Config函数的具体用法?C++ USB_Cable_Config怎么用?C++ USB_Cable_Config使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USB_Cable_Config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f_usb_enable
static int f_usb_enable(int ena) {
if (_argc != 1) {
return -1;
}
if (ena) {
print("Enable usb\n");
USB_Cable_Config(ENABLE);
USB_ARC_init();
} else {
print("Disable usb\n");
USB_Cable_Config(DISABLE);
}
return 0;
}
示例2: PowerOn
/*******************************************************************************
* Function Name : PowerOn
* Description :
* Input : None.
* Output : None.
* Return : USB_SUCCESS.
*******************************************************************************/
RESULT PowerOn(void)
{
#ifndef STM32F10X_CL
uint16_t wRegVal;
/*** cable plugged-in ? ***/
/*while(!CablePluggedIn());*/
USB_Cable_Config(ENABLE);
/*** CNTR_PWDN = 0 ***/
wRegVal = CNTR_FRES;
_SetCNTR(wRegVal);
/*** CNTR_FRES = 0 ***/
wInterrupt_Mask = 0;
_SetCNTR(wInterrupt_Mask);
/*** Clear pending interrupts ***/
_SetISTR(0);
/*** Set interrupt mask ***/
wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
_SetCNTR(wInterrupt_Mask);
#endif /* STM32F10X_CL */
return USB_SUCCESS;
}
示例3: main
int main(void)
{
delay_init(); //延时函数初始化
uart_init(9600); //串口初始化为9600
LED_Init(); //初始化与LED连接的硬件接口
LED0=1;
LED1=1;
LED2=1;
USB_Cable_Config (ENABLE);
delay_ms(500);
USB_Port_Set(0);
delay_ms(500);
USB_Port_Set(1);
Set_USBClock();
USB_Interrupts_Config();
USB_Init();
SPI_IO_Init();
DMA_configuration();
spi_conf(SPI_DEFAULT_SPEED);
LED1=0;
LED2=0;
while(1)
{
/* Get command */
serprog_handle_command(usb_getc());
/* Flush output via USB */
usb_sync();
}
}
示例4: PowerOn
/*******************************************************************************
* Function Name : PowerOn
* Description :
* Input : None.
* Output : None.
* Return : USB_SUCCESS.
*******************************************************************************/
RESULT PowerOn(void)
{
#ifndef STM32F10X_CL
uint16_t wRegVal;
/*** cable plugged-in ? ***/
/*while(!CablePluggedIn());*/
USB_Cable_Config(ENABLE);//使能usb控制引脚 PD9 改为PA8
/*** CNTR_PWDN = 0 ***/
wRegVal = CNTR_FRES;
_SetCNTR(wRegVal);//清除CNTR寄存器上的PWDN P406
/*** CNTR_FRES = 0 ***/
wInterrupt_Mask = 0;
_SetCNTR(wInterrupt_Mask);//清除CNTR寄存器上的FRES
/*** Clear pending interrupts ***/
_SetISTR(0);
/*** Set interrupt mask ***/
wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;//P413
_SetCNTR(wInterrupt_Mask);//使能复位中断,唤醒中断,挂起中断 p412
#endif /* STM32F10X_CL */
return USB_SUCCESS;
}
示例5: USB_Configs
void USB_Configs()
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
USB_Cable_Config(ENABLE);
USB_Interrupts_Config();
Set_USBClock();
USB_Init();
}
示例6: PowerOff
/**
* @brief handles switch-off conditions
* @param None.
* @retval USB_SUCCESS.
*/
RESULT PowerOff()
{
_SetCNTR(CNTR_FRES); /* disable all interrupts and force USB reset */
_SetISTR(0); /* clear interrupt status register */
USB_Cable_Config(DISABLE); /* Disable the Pull-Up*/
_SetCNTR(CNTR_FRES + CNTR_PDWN);/* switch-off device */
return USB_SUCCESS;
}
示例7: USBDevice_Connect
void USBDevice_Connect()
{
DBG_MSG("called", 0);
if(!InitMemoryInfo())
return;
USB_Interrupts_Config(ENABLE);
USB_Cable_Config(ENABLE);
USB_Init();
}
示例8: Set_System
/**
* @brief Configures USB Cable.
* @param None
* @retval None
*/
void Set_System(void)
{
/* Unlock the internal flash */
FLASH_Unlock();
/* Configure the USB Disconnect Pin */
iNEMO_USB_Disconnet_Pin_Config();
/*Disable the USB Cable*/
USB_Cable_Config(DISABLE);
/* Init the media interface */
MAL_Init();
/*Enable the USB Cable*/
USB_Cable_Config(ENABLE);
}
示例9: USB_USART_Init
/*******************************************************************************
* Function Name : USB_USART_Init
* Description : Start USB-USART protocol.
* Input : baudRate (0 : disconnect usb else init usb only once).
* Return : None.
*******************************************************************************/
void USB_USART_Init(uint32_t baudRate)
{
if (linecoding.bitrate != baudRate)
{
if (!baudRate)
{
USB_Cable_Config(DISABLE);
}
else if (!linecoding.bitrate)
{
//Perform a Detach-Attach operation on USB bus
USB_Cable_Config(DISABLE);
USB_Cable_Config(ENABLE);
//Initialize USB device only once (if linecoding.bitrate==0)
SPARK_USB_Setup();
}
//linecoding.bitrate will be overwritten by USB Host
linecoding.bitrate = baudRate;
}
}
示例10: usb_config
void usb_config(void) {
GPIO_InitTypeDef gpioInitStructure;
EXTI_InitTypeDef extiInitStructure;
NVIC_InitTypeDef nvicInitStructure;
print_info("usb_config\n");
ring_buffer_init(&usb_tx_ring_buffer, usb_tx_buffer, USB_TX_BUFFER_SIZE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
/* Enable the USB disconnect GPIO clock */
RCC_APB2PeriphClockCmd(USB_DISCONNECT_RCC, ENABLE);
/* USB_DISCONNECT used as USB pull-up */
gpioInitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
gpioInitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
gpioInitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(USB_DISCONNECT, &gpioInitStructure);
/* Configure the EXTI line 18 connected internally to the USB IP */
EXTI_ClearITPendingBit(EXTI_Line18);
extiInitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
extiInitStructure.EXTI_Line = EXTI_Line18;
extiInitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
extiInitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&extiInitStructure);
USB_Cable_Config(DISABLE);
/* Enable USB clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
nvicInitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
nvicInitStructure.NVIC_IRQChannelPreemptionPriority = 2;
nvicInitStructure.NVIC_IRQChannelSubPriority = 0;
nvicInitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&nvicInitStructure);
/* Enable the USB Wake-up interrupt */
nvicInitStructure.NVIC_IRQChannel = USBWakeUp_IRQn;
nvicInitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_Init(&nvicInitStructure);
print_info("USB_Init\n");
USB_Init();
delay_ms(100); // TODO remove?
}
示例11: Set_USBPullUp
void Set_USBPullUp()
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIO clock */
RCC_APB2PeriphClockCmd(USB_PULLUP_RCC_APB2PERIPH, ENABLE);
/* Setup USB pull-up */
GPIO_InitStructure.GPIO_Pin = USB_PULLUP_GPIO_BIT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_Init(USB_PULLUP_GPIO_PORT, &GPIO_InitStructure);
USB_Cable_Config(DISABLE);
}
示例12: main
/*******************************************************************************
* Function Name : main.
* Description : main routine.
* Input : None.
* Output : None.
* Return : None.
*******************************************************************************/
int main(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
DFU_Button_Config();
/* Check if the Key push-button on STM3210x-EVAL Board is pressed */
if (DFU_Button_Read() != 0x00)
{ /* Test if user code is programmed starting from address 0x8003000 */
if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
{ /* Jump to user application */
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
Jump_To_Application();
}
} /* Otherwise enters DFU mode to allow user to program his application */
/* Enter DFU mode */
DeviceState = STATE_dfuERROR;
DeviceStatus[0] = STATUS_ERRFIRMWARE;
DeviceStatus[4] = DeviceState;
RCC_Configuration();
NVIC_Configuration();
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
GPIO_Configuration();
/* Init the media interface */
MAL_Init();
/* potrebne ? */
USB_Cable_Config(ENABLE);
//USB_Init();
USB_Init(&Device_Table, &Device_Property, &User_Standard_Requests);
/* Main loop */
while (1)
{}
}
示例13: PowerOff
/*******************************************************************************
* Function Name : PowerOff
* Description : handles switch-off conditions
* Input : None.
* Output : None.
* Return : USB_SUCCESS.
*******************************************************************************/
RESULT PowerOff()
{
#ifndef STM32F10X_CL
/* disable all interrupts and force USB reset */
_SetCNTR(CNTR_FRES);
/* clear interrupt status register */
_SetISTR(0);
/* Disable the Pull-Up*/
USB_Cable_Config(DISABLE);
/* switch-off device */
_SetCNTR(CNTR_FRES + CNTR_PDWN);
/* sw variables reset */
/* ... */
#endif /* STM32F10X_CL */
return USB_SUCCESS;
}
示例14: PowerOn
/**
* @brief PowerOn
* @param None.
* @retval USB_SUCCESS.
*/
RESULT PowerOn(void)
{
uint16_t wRegVal;
USB_Cable_Config(ENABLE); /*** cable plugged-in ? ***/
wRegVal = CNTR_FRES; /*** CNTR_PWDN = 0 ***/
_SetCNTR(wRegVal);
wInterrupt_Mask = 0; /*** CNTR_FRES = 0 ***/
_SetCNTR(wInterrupt_Mask);
_SetISTR(0); /*** Clear pending interrupts ***/
/*** Set interrupt mask ***/
wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
_SetCNTR(wInterrupt_Mask);
return USB_SUCCESS;
}
示例15: PowerOn
/*******************************************************************************
* Function Name : PowerOn
* Description :
* Input : None.
* Output : None.
* Return : USB_SUCCESS.
*******************************************************************************/
RESULT PowerOn(void)
{
u16 wRegVal;
USB_Cable_Init();
USB_Cable_Config(ENABLE);//使能1.5K上拉
/*** CNTR_PWDN = 0 ***/
wRegVal = CNTR_FRES;
_SetCNTR(wRegVal);
/*** CNTR_FRES = 0 ***/
wInterrupt_Mask = 0;
_SetCNTR(wInterrupt_Mask);
/*** Clear pending interrupts ***/
_SetISTR(0);
/*** Set interrupt mask ***/
wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
_SetCNTR(wInterrupt_Mask);
return USB_SUCCESS;
}