/******************************************************************************* * Function Name : main. * Description : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { int i; Reset_GC3355(); Set_System(); Set_USBClock(); USB_Interrupts_Config(); #ifdef USE_USB_AS_HOST_IF USB_Init(); #endif USART_Config_Default(); btc_ltc_uart_config(115200); delay_init(72); //gpio_init(); Timerx_Init(100,7200-1); USART_Config_Default(); rx_cx_buffers_init(); while (1) { dispatch_host_cmd(); report_nonce_to_host(); if(timer_count > 100) { timer_count = 0; //PR_DEBUG("GPIOB8 = %d\n",GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_8)); led1_revert(); //PR_DEBUG("%02X\n",get_next_n_out(&usb_trans_buffer,152)); //PR_DEBUG("has cmd length = %d\n",trans_buffer_has_cmd(&usb_trans_buffer)); } //delay_ms(1000); //PR_DEBUG("delay 1000ms \n"); } }
/** * @brief Configure the USB in CDC mode. * @retval None */ void initUSB_CDC(void) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init_Dynamic(&Device_Property_CDC, &User_Standard_Requests_CDC); // now device state is UNCONNECTED }
/******************************************************************************* * Function Name : main. * Descriptioan : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { int i; /* Set the Vector Table base adress at 0x8004000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000); // Disable JTAG not the SWD RCC_APB2PeriphClockCmd( RCC_APB2Periph_AFIO , ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); for(i = 0; i < 27; i++) TestBuffer[i] = i % 9; while (1) { if (bDeviceState == CONFIGURED) { //CDC_Send_DATA ((unsigned char*)TestBuffer,27); //Delay(0xFFF); CDC_Receive_DATA(); // Check to see if we have data yet if (Receive_length != 0) { if (packet_sent == 1) CDC_Send_DATA ((unsigned char*)Receive_Buffer,Receive_length); Receive_length = 0; } } } }
void cliInit(void) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); }
int main() { SysTick_Config(SystemCoreClock/1000); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); /* * GPIO_Config(); * * GPIOA->BSRR = GPIO_Pin_15; * * while (1) * { * if (bDeviceState == CONFIGURED) { * CDC_Receive_DATA(); * [>Check to see if we have data yet <] * if (Receive_length != 0) { * if (packet_sent == 1) * CDC_Send_DATA((unsigned char*) Receive_Buffer, Receive_length); * Receive_length = 0; * } * } * } */ while(1); }
void board::usbVcomHwConfigInit() { if (!bInitialized) { bInitialized = true; Set_USBClock(); Set_USBPullUp(); PowerOff(); for (unsigned int i = 500000; i--;) { continue; } Set_USBInterrupt(false); // Wait a bit to let the Host disconnect the device for (unsigned int i = 500000; i--;) { continue; } // USB_Cable_Config(ENABLE); // for (unsigned int i = 500000; i--;) { continue; } Set_USBInterrupt(true); USB_Init(); for (unsigned int i = 500000; i--;) { continue; } for (unsigned int i = 500000; i--;) { continue; } } }
int main(void) { /* USART1 config */ USART1_Config(); LED_GPIO_Config(); /*初始化SD卡*/ Set_System(); /*设置USB时钟为48M*/ Set_USBClock(); /*配置USB中断(包括SDIO中断)*/ USB_Interrupts_Config(); /*USB初始化*/ USB_Init(); while (bDeviceState != CONFIGURED); //等待配置完成 printf("\r\n 野火 ISO STM32 USB MASS STORAGE 实验\r\n"); while (1) { LED1_TOGGLE; USB_Delay(0x0FFFFF); } }
/******************************************************************************* * Function Name : main. * Description : main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { DFU_Button_Config(); /* Check if the Key push-button on STM3210x-EVAL Board is pressed */ if (DFU_Button_Read()) { /* 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; Set_System(); Set_USBClock(); USB_Init(); /* turn on LED */ GPIOB->BSRR = GPIO_Pin_5; /* Main loop */ while (1) {} }
void USB_Config(void) { Set_USBClock(); USB_Interrupts_Config(); USB_Init(); // while (bDeviceState != CONFIGURED) {} }
int main() { InitGPIO(); //InitTIM3(); //InitTIM4(); InitIWDG(); // Init Watch Dog InitBKP(); #ifdef DEBUG_OUTPUT_USB Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); #else rtc_init(); #endif RTC_t date; date.year = 2015; date.month = 10; date.mday = 24; date.hour = 23; date.min = 20; date.sec = 0; rtc_settime(&date); // Start Task // xTaskCreate(vLcdPcf, "vLcdPcf", configMINIMAL_STACK_SIZE * 2, NULL, tskIDLE_PRIORITY + 1, &xHandlevLcdPcfTask); xTaskCreate(vDebugTask, "vDebugTask", configMINIMAL_STACK_SIZE * 2, NULL, tskIDLE_PRIORITY + 1, &xHandleDebugTask); // Start scheduler // osKernelStart(NULL, NULL); }
/******************************************************************************* * Function Name : main. * Description : main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { GPIO_InitTypeDef GPIO_InitStructure; NAND_IDTypeDef NAND_Id; NAND_ADDRESS NAND_Address; int i=0; #ifdef DEBUG debug(); #endif Set_System(); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); Serial_Init(); NAND_Init(); NAND_Reset(); NAND_ReadID(&NAND_Id); Get_Medium_Characteristics(); Set_USBClock(); USB_Interrupts_Config(); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; GPIO_Init(GPIOC, &GPIO_InitStructure); USB_Init(); while (1) { } }
int main() { InitGPIO(); InitBKP(); Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); rtc_init(); /* RTC_t date; date.year = 2015; date.month = 10; date.mday = 24; date.hour = 23; date.min = 20; date.sec = 0; rtc_settime(&date); */ // Start Task // xTaskCreate(vLcdTask, "vLcdTask", configMINIMAL_STACK_SIZE * 1, NULL, tskIDLE_PRIORITY + 1, &xHandleLcdTask); xTaskCreate(vDebugTask, "vDebugTask", configMINIMAL_STACK_SIZE * 1, NULL, tskIDLE_PRIORITY + 1, &xHandleDebugTask); // Start scheduler // osKernelStart(NULL, NULL); }
int main(void) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); GPIOA->CRH &= !(GPIO_CRH_CNF8_0 | GPIO_CRH_CNF8_1); GPIOA->CRH = GPIO_CRH_MODE8_1; GPIOA->BSRR = GPIO_BSRR_BS8; Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); while (1) { packet_buffer_to_rx_fifo(); rx_fifo_to_tx_fifo(); tx_fifo_to_packet_buffer(); // if(GPIO_ReadInputDataBit (GPIOA, GPIO_Pin_8)) // { // GPIO_ResetBits(GPIOA, GPIO_Pin_8); // } // else // { // GPIO_SetBits(GPIOA, GPIO_Pin_8); // } } }
/** * @brief 串口打印输出 * @param None * @retval None */ int main(void) { uint8_t data[64]; uint32_t i=0,ret=0; Set_System();//系统时钟初始化 USART_Configuration();//串口1初始化 printf("\x0c\0");printf("\x0c\0");//超级终端清屏 printf("\033[1;40;32m");//设置超级终端背景为黑色,字符为绿色 printf("\r\n*******************************************************************************"); printf("\r\n************************ Copyright 2009-2012, ViewTool ************************"); printf("\r\n*************************** http://www.viewtool.com ***************************"); printf("\r\n***************************** All Rights Reserved *****************************"); printf("\r\n*******************************************************************************"); printf("\r\n"); USB_Interrupts_Config(); Set_USBClock(); USB_Init(); while(1) { if(USB_Received_Flag){ USB_Received_Flag=0; ret = USB_GetData(data,sizeof(data)); printf("usb get data %d byte data\n\r",ret); for(i=0;i<ret;i++){ printf("0x%02X ",data[i]); } printf("\n\r"); USB_SendData(data,sizeof(data)); } } }
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(); } }
/******************************************************************************* * Function Name : main. * Description : main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); USB_Interrupts_Config(); Set_USBClock(); USB_Init(); uint16_t counter = 0; while (1) { TheReport.SAX = 32768; TheReport.SAY = counter; ++counter; if (bDeviceState == CONFIGURED) { if (PrevXferComplete) { RHIDCheckState(); } } } }
void USB_Configs() { RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); USB_Cable_Config(ENABLE); USB_Interrupts_Config(); Set_USBClock(); USB_Init(); }
void uart_init() { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); }
/********************************************************************************************* Function name : VCP_Init Author : Grant Phillips Date Modified : 10/04/2014 Compiler : Keil ARM-MDK (uVision V4.70.0.0) Description : Initializes the Virtual COM Port module Special Note(s) : NONE Parameters : NONE Return value : NONE *********************************************************************************************/ void VCP_Init(void) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); packet_sent=1; }
serialPort_t *usbVcpOpen(void) { vcpPort_t *s; IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0); IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0); #if defined(STM32F4) usbGenerateDisconnectPulse(); switch (usbDevConfig()->type) { #ifdef USE_USB_CDC_HID case COMPOSITE: USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_CDC_cb, &USR_cb); break; #endif default: USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb); break; } #elif defined(STM32F7) usbGenerateDisconnectPulse(); /* Init Device Library */ USBD_Init(&USBD_Device, &VCP_Desc, 0); /* Add Supported Class */ switch (usbDevConfig()->type) { #ifdef USE_USB_CDC_HID case COMPOSITE: USBD_RegisterClass(&USBD_Device, USBD_HID_CDC_CLASS); break; #endif default: USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS); break; } /* HID Interface doesn't have any callbacks... */ /* Add CDC Interface Class */ USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops); /* Start Device Process */ USBD_Start(&USBD_Device); #else Set_System(); Set_USBClock(); USB_Init(); USB_Interrupts_Config(); #endif s = &vcpPort; s->port.vTable = usbVTable; return (serialPort_t *)s; }
void vUSBTask(void *pvParameters) { uint16 usbsize; uint8 usbbuf[256]; //uint8 usbbufsizes[100]; CONTENTS stru[100]; uint16 usbbufsizesCounter=0; bool st = false; /* The parameters are not used. */ (void) pvParameters; /* uint16_t bufff[20]; bufff[0] = 0x555; bufff[1] = 0x444; bufff[2] = 0x333; bufff[3] = 0x222; bufff[4] = 0x111; FLASH_ErasePage(DEVICE_FLASHMEM_LOCATION); //FLASH_ProgramHalfWord(DEVICE_FLASHMEM_LOCATION,bufff[0]); //FLASH_ProgramHalfWord(DEVICE_FLASHMEM_LOCATION+0x02,bufff[1]); //FLASH_ProgramHalfWord(DEVICE_FLASHMEM_LOCATION+0x04,bufff[2]); //FLASH_ProgramHalfWord(DEVICE_FLASHMEM_LOCATION+0x06,bufff[3]); //FLASH_ProgramHalfWord(DEVICE_FLASHMEM_LOCATION+0x08,bufff[4]); WriteFlash( bufff,(void*)(DEVICE_FLASHMEM_LOCATION), 10);*/ //vTaskDelay(15000); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); int heapSize = 0; while (1) { heapSize = xPortGetFreeHeapSize(); heapSize +=0; usbsize = UsbReceiveData(usbbuf,256); if(usbsize > 0) { stru[usbbufsizesCounter].buf[0]=usbbuf[0]; stru[usbbufsizesCounter].buf[1]=usbbuf[1]; stru[usbbufsizesCounter].buf[2]=usbbuf[2]; stru[usbbufsizesCounter].buf[3]=usbbuf[3]; stru[usbbufsizesCounter].size = usbsize; usbbufsizesCounter++; if(usbbufsizesCounter>=100) usbbufsizesCounter = 0; usbsize = RVnetSlaveProcess(usbbuf,usbsize,1); if(usbsize > 0) { UsbSendData(usbbuf,usbsize); } } vTaskDelay(1); } }
/******************************************************************************* * Function Name : main. * Description : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); Set_USBClock(); USB_Config(); USB_Init(); Speaker_Config(); while (1) {} }
/******************************************************************************* * Function Name : main. * Description : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); while (1) { } }
void USB_HID_Init(void) { bDeviceState=UNCONNECTED; USB_HID_RecData_Ready = 0; USB_HID_RecData_Len = 0; Set_System(); USB_Interrupts_Config(); Set_USBClock(); USB_Init(); }
/** * @brief Configure the usb serial communication. * Blocking function. * @param Void * @return Void */ void usbCommInit( void ) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); while (USB_GetState() != CONFIGURED) {} // Wait USB is ready usbCommInitPeriodicSending(); }
void ResetUSB(void) { delay_ms(500); // Reset USB usb_port_set(0); delay_ms(500); usb_port_set(1); USB_Interrupts_Config(); Set_USBClock(); USB_Init(); }
/******************************************************************************* * Function Name : main. * Description : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); while (bDeviceState != CONFIGURED); while (1) {} }
/******************************************************************************* * Function Name : main. * Description : Main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { #ifdef DEBUG debug(); #endif Set_System(); Set_USBClock(); USB_Config(); USB_Init(); InitialIO(); InitialADC(); #ifdef JOYSTICK SSD1303_Init(); InitialSSD1306_controller(); #endif InitialProcTask(); //WaitConfig(); InitialDevice(&dev,&SSD1303_Prop,SongSmall5_DrawChar); SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); SysTick_SetReload(72000000/20); SysTick_CounterCmd(SysTick_Counter_Enable); SysTick_ITConfig(ENABLE); CurrentProcess = JoystickProcess; CurrentSystick = JoystickSystick; JoystickUIInit(); void HidProcess(void); while (1) { HidProcess(); continue; static u8 lastCamOn = 0; if(lastCamOn != bCameraOn) { if(bCameraOn) { CurrentProcess = TetrisProcess; CurrentSystick = TetrisSystick; TetrisUIInit(); } else { CurrentProcess = JoystickProcess; CurrentSystick = JoystickSystick; JoystickUIInit(); } } lastCamOn = bCameraOn; CurrentProcess(); } }
/** * @brief Configure the USB. * @param None * @retval None */ void Demo_USB (void) { Set_System(); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); while ((bDeviceState != CONFIGURED)&&(USBConnectTimeOut != 0)) {} }
void PCUsart_Init(void) { Set_USBClock(); USB_Interrupts_Config(); USB_Init(); //g_pcCommand.CmdBuffer = g_receive_buff; //g_com_handle_flag = 0; //reset_command(); }