Exemplo n.º 1
0
/**
  * @brief  Initializes the USB for the demonstration application.
  * @param  None
  * @retval None
  */
static uint32_t Demo_USBConfig(void)
{
  /* Init Device Library */
  USBD_Init(&hUSBDDevice, &HID_Desc, 0);
  
  /* Add Supported Class */
  USBD_RegisterClass(&hUSBDDevice, USBD_HID_CLASS);
  
  /* Start Device Process */
  USBD_Start(&hUSBDDevice);
  
  return 0;
}
Exemplo n.º 2
0
void usb_serial_init(void)
{
	USBD_Init(&USB_OTG_dev,
#ifdef USE_USB_OTG_HS 
			USB_OTG_HS_CORE_ID,
#else            
			USB_OTG_FS_CORE_ID,
#endif  
			&USR_desc, 
			&USBD_CDC_cb, 
			&USR_cb);

}
Exemplo n.º 3
0
/**
  * @brief  Start USBD
  * @param  None.
  * @retval USBD status.
  */
USBD_ErrorTypdef  USBDSTOR_Start(void)
{ 
  /* Init MSC Application */
  USBD_Init(&USBD_Device, &MSC_Desc, 0);
  
  /* Add Supported Class */
  USBD_RegisterClass(&USBD_Device, &USBD_MSC);
  
  /* Add Storage callbacks for MSC Class */
  USBD_MSC_RegisterStorage(&USBD_Device, &USBD_DISK_fops);
    
  return USBD_ERROR_NONE;
}
Exemplo n.º 4
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 168 MHz */
  SystemClock_Config();
  
  /* Configure Key Button */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);
  
  /* Check if the KEY Button is pressed */
  if(BSP_PB_GetState(BUTTON_KEY) != 0x00)
  {
    /* Test if user code is programmed starting from address 0x0800C000 */
    if(((*(__IO uint32_t*)USBD_DFU_APP_DEFAULT_ADD) & 0x2FFE0000 ) == 0x20000000)
    {
      /* Jump to user application */
      JumpAddress = *(__IO uint32_t*) (USBD_DFU_APP_DEFAULT_ADD + 4);
      JumpToApplication = (pFunction) JumpAddress;
      
      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) USBD_DFU_APP_DEFAULT_ADD);
      JumpToApplication();
    }
  }
  
  /* Otherwise enters DFU mode to allow user programing his application */
  /* Init Device Library */
  USBD_Init(&USBD_Device, &DFU_Desc, 0);
  
  /* Add Supported Class */
  USBD_RegisterClass(&USBD_Device, USBD_DFU_CLASS);
  
  /* Add DFU Media interface */
  USBD_DFU_RegisterMedia(&USBD_Device, &USBD_DFU_Flash_fops);

  /* Start Device Process */
  USBD_Start(&USBD_Device);
  
  /* Run Application (Interrupt mode) */
  while (1)
  {
  }
}
int USB_CDC_device_init(const int priority)
{
    vcp_setup();

    /* Initialize the USB hardware */
    USBD_Init(&USB_OTG_dev,
              USB_OTG_FS_CORE_ID,
              &USR_desc,
              &USBD_CDC_cb,
              &USR_cb);
    _init_flag = 1;

    return 0;
}
Exemplo n.º 6
0
/* init function */				        
void MX_USB_DEVICE_Init(void)
{
  /* Init Device Library,Add Supported Class and Start the library*/
  USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);
  USBD_RegisterClass(&hUsbDeviceFS, &USBD_MSC);
  USBD_MSC_RegisterStorage(&hUsbDeviceFS, &USBD_Storage_Interface_fops_FS);
  /* Verify if the Battery Charging Detection mode (BCD) is used : */
  /* If yes, the USB device is started in the HAL_PCDEx_BCD_Callback */
  /* upon reception of PCD_BCD_DISCOVERY_COMPLETED message. */
  /* If no, the USB device is started now. */
  if (USBD_LL_BatteryCharging(&hUsbDeviceFS) != USBD_OK) {
  USBD_Start(&hUsbDeviceFS);
  }
}
Exemplo n.º 7
0
void usbInit(void)
{
  USBD_Init(&USB_OTG_dev,
            USB_OTG_FS_CORE_ID,
            &USR_desc,
            &cf_usb_cb,
            &USR_cb);

  // This should probably be reduced to a CRTP packet size
  usbDataRx = xQueueCreate(5, sizeof(USBPacket)); /* Buffer USB packets (max 64 bytes) */
  usbDataTx = xQueueCreate(1, sizeof(USBPacket)); /* Buffer USB packets (max 64 bytes) */

  isInit = true;
}
Exemplo n.º 8
0
//-----------------------------------------------------------------------------
/// Initializes the USB device composite device driver.
//-----------------------------------------------------------------------------
void MULTIDriver_Initialize(void)
{

    CDCDFunctionDriver_Initialize();

	/* CCID nees no initialization */

    // Initialize the standard USB driver
    USBDDriver_Initialize(&usbdDriver,
                          &multiDriverDescriptors,
                          multiDriverInterfaces);

    // Initialize the USB driver
    USBD_Init();
}
Exemplo n.º 9
0
int main(void)
{
	fpu_enable();
	system_init();
	pll_start(CRYSTAL, FREQUENCY);

	gpio_pin_cfg(GPIOD, 12, GPIO_OUT_PP_25MHz);
	gpio_pin_cfg(GPIOD, 13, GPIO_OUT_PP_25MHz);
	gpio_pin_cfg(GPIOD, 14, GPIO_OUT_PP_25MHz);
	gpio_pin_cfg(GPIOD, 15, GPIO_OUT_PP_25MHz);

	USBD_Init(&USB_Dev, USB_OTG_FS_CORE_ID, &USR_desc, &AUDIO_cb, &USR_cb);

	while(1);
}
Exemplo n.º 10
0
//------------------------------------------------------------------------------
Usb::Error UsbStm32f4xx::driverEnable(const bool enable)
{
    if (enable)
    {
        USBD_Init(&USB_OTG_dev,
                  USB_OTG_FS_CORE_ID,
                  &USR_desc,
                  &USBD_CDC_cb,
                  &USR_cb);

        VCP_SetDataRxCallback(rxCallback);
    }

    return ERROR_NONE;
}
Exemplo n.º 11
0
void init() {
	SystemInit();

	// ---------- SysTick timer -------- //
	if (SysTick_Config(SystemCoreClock / 1000)) {
		// Capture error
		while (1){};
	}

	// ------------- USB -------------- //
	USBD_Init(&USB_OTG_dev,
	            USB_OTG_FS_CORE_ID,
	            &USR_desc,
	            &USBD_CDC_cb,
	            &USR_cb);
}
Exemplo n.º 12
0
void pyb_usb_dev_init(void) {
#ifdef USE_DEVICE_MODE
    if (!dev_is_enabled) {
        // only init USB once in the device's power-lifetime
        USBD_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_PYB_cb, &USR_cb);
        //USBD_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_PYB_HID_cb, &USR_cb);
    }
    rx_buf_in = 0;
    rx_buf_out = 0;
    interrupt_char = VCP_CHAR_NONE;
    dev_is_enabled = 1;

    // create an exception object for interrupting by VCP
    mp_const_vcp_interrupt = mp_obj_new_exception(qstr_from_str("VCPInterrupt"));
#endif
}
Exemplo n.º 13
0
int main(void)
{	
	int8_t i = 0;
	LED_Init();
	Usart2_Init(9600);
	Myprintf_Init(0x00,myputc);
	Timer3_Interrupt_Init(50,84);
	USBD_Init(&USB_OTG_dev,USB_OTG_FS_CORE_ID,&USR_desc,&USBD_CDC_cb,&USR_cb);
	
	while(1) 
	{	
		LED_loop();
	}

	return 0;
}
Exemplo n.º 14
0
/**
 * @brief This function handles the setup of the USB device:
 *         - Assigns endpoints to USB interfaces
 *         - Mounts the interfaces on the device
 *         - Sets up the USB device
 *         - Determines the USB port type
 *         - Establishes logical connection with the host
 */
void UsbDevice_Init() {
	/* Initialize the device */
	USBD_Init(UsbDevice, dev_cfg);

	/* All fields of Config have to be properly set up */
	ps2controller_if->Config.InEp.Num = 0x81;
	configurator_if->Config.InEp.Num = 0x82;
	configurator_if->Config.OutEp.Num = 0x02;

	// Mount the interfaces to the device
	USBD_HID_MountInterface(ps2controller_if, UsbDevice);
	USBD_HID_MountInterface(configurator_if, UsbDevice);

	// connection can be made
	USBD_Connect(UsbDevice);
}
Exemplo n.º 15
0
int main(void)
{
  /* Chip errata */
  CHIP_Init();
  
  /* Enable HFXO */
  CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);
    
  /* Enable deboug output over UART */
  RETARGET_SerialInit();                     
  RETARGET_SerialCrLf(1); 
  
  /* Enable the segment LCD */
  SegmentLCD_Init(false);
  SegmentLCD_Write("USB");
  
  printf("\nStarting USB Device...\n");
  
  /* Set up GPIO interrupts */
  gpioInit();
  
  /* Start USB stack. Callback routines in callbacks.c will be called
   * when connected to a host.  */
  USBD_Init(&initstruct);;

  /*
   * When using a debugger it is pratical to uncomment the following three
   * lines to force host to re-enumerate the device.
   */
  /* USBD_Disconnect(); */
  /* USBTIMER_DelayMs( 1000 ); */
  /* USBD_Connect(); */
    
  while(1)
  {
    if ( USBD_SafeToEnterEM2() )
    {
      /* Enter EM2 when in suspend or disconnected */
      EMU_EnterEM2(true);
    } 
    else
    {
      /* When USB is active we can sleep in EM1. */
      EMU_EnterEM1();
    }
  } 
}
Exemplo n.º 16
0
/**
  * @brief  Program entry point
  * @param  None
  * @retval None
  */
int main(void)
{
  RCC_ClocksTypeDef RCC_Clocks;
  __IO uint32_t i = 0;  

  /*!< At this stage the microcontroller clock setting is already configured, 
  this is done through SystemInit() function which is called from startup
  file (startup_stm32fxxx_xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32fxxx.c file
  */  
 
  /* SysTick end of count event each 1ms */
  RCC_GetClocksFreq(&RCC_Clocks);

  SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);

  USART3_Configuration(); // Debug via RS232

puts("T2 VCP Demo");

  USART6_Configuration(Uart6); // Modem for USB

  Uart_ModemOn(Uart6, TELIT_TIME_ON);

  USBD_Init(&USB_OTG_dev,
#ifdef USE_USB_OTG_HS 
            USB_OTG_HS_CORE_ID,
#else            
            USB_OTG_FS_CORE_ID,
#endif  
            &USR_desc, 
            &USBD_CDC_cb, 
            &USR_cb);
  
  /* Main loop */
  while (1)
  {
    if (i++ == 0x100000)
    {
      STM_EVAL_LEDToggle(LED1);
      STM_EVAL_LEDToggle(LED2);
      STM_EVAL_LEDToggle(LED3);
      i = 0;
    }
  }
} 
Exemplo n.º 17
0
/**
 * Initializes the USB device composite device driver.
 */
void HIDAUDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
	USBDDriver *pUsbd = USBD_GetDriver();

	/* Initialize the standard USB driver */
	USBDDriver_Initialize(pUsbd,
						  pDescriptors,
						  bAltInterfaces);

	/* HID */
	HIDDKeyboard_Initialize(pUsbd, HIDAUDDDriverDescriptors_HID_INTERFACE);
	/* Audio */
	AUDDFunction_Initialize(pUsbd, HIDAUDDDriverDescriptors_AUD_INTERFACE);

	/* Initialize the USB driver */
	USBD_Init();
}
Exemplo n.º 18
0
/**
 * Initializes the USB device composite device driver.
 */
void CDCHIDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
	USBDDriver *pUsbd = USBD_GetDriver();

	/* Initialize the standard USB driver */
	USBDDriver_Initialize(pUsbd,
						  pDescriptors,
						  0);

	/* CDC */
	CDCDSerial_Initialize(pUsbd, CDCHIDDDriverDescriptors_CDC_INTERFACE);
	/* HID */
	HIDDKeyboard_Initialize(pUsbd, CDCHIDDDriverDescriptors_HID_INTERFACE);

	/* Initialize the USB driver */
	USBD_Init();
}
Exemplo n.º 19
0
/**
 * Initializes the USB device composite device driver.
 */
void CDCAUDDDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
{
    USBDDriver *pUsbd = USBD_GetDriver();

    /* Initialize the standard USB driver */
    USBDDriver_Initialize(pUsbd,
                          pDescriptors,
                          bAltInterfaces);

    /* CDC */
    CDCDSerial_Initialize(pUsbd, CDCAUDDDriverDescriptors_CDC_INTERFACE);
    /* Audio */
    AUDDFunction_Initialize(pUsbd, CDCAUDDDriverDescriptors_AUD_INTERFACE);

    /* Initialize the USB driver */
    USBD_Init();
}
Exemplo n.º 20
0
void MX_USB_OTG_FS_USB_Init(void)
{
    /* Init Device Library */
    USBD_Init(&USBD_Device, &VCP_Desc, 0);

    /* Add Supported Class */
    USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS);

    /* Add CDC Interface Class */
    //USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);
    USBD_CDC_RegisterInterface(&USBD_Device, &cdcInterface);

    USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;

    /* Start Device Process */
    USBD_Start(&USBD_Device);
}
Exemplo n.º 21
0
int main(void)
{
	 SystemInit();
	 Leds_Init();


	 USBD_Init(&USB_OTG_dev,
			  	USB_OTG_FS_CORE_ID,
	            &USR_desc,
	            &USBD_MSC_cb,
	            &USR_cb);

    while(1)
    {

    }
}
Exemplo n.º 22
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F469xx HAL library initialization */
  HAL_Init();

  /* Configure the System clock to have a frequency of 180 MHz */
  SystemClock_Config();

  /* Configure Key Button */
  BSP_PB_Init(BUTTON_WAKEUP, BUTTON_MODE_GPIO);

  /* Check if the KEY Button is pressed */
  if(BSP_PB_GetState(BUTTON_WAKEUP) == 0x00)
  {
    /* Test if user code is programmed starting from USBD_DFU_APP_DEFAULT_ADD address */
    if(((*(__IO uint32_t*)USBD_DFU_APP_DEFAULT_ADD) & 0x2FFE0000 ) == 0x20000000)
    {
      /* Jump to user application */
      JumpAddress = *(__IO uint32_t*) (USBD_DFU_APP_DEFAULT_ADD + 4);
      JumpToApplication = (pFunction) JumpAddress;

      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) USBD_DFU_APP_DEFAULT_ADD);
      JumpToApplication();
    }
  }

  /* Otherwise enters DFU mode to allow user programming his application */
  /* Init Device Library */
  USBD_Init(&USBD_Device, &DFU_Desc, 0);

  /* Add Supported Class */
  USBD_RegisterClass(&USBD_Device, USBD_DFU_CLASS);

  /* Add DFU Media interface */
  USBD_DFU_RegisterMedia(&USBD_Device, &USBD_DFU_Flash_fops);

  /* Start Device Process */
  USBD_Start(&USBD_Device);

  /* Run Application (Interrupt mode) */
  while (1)
  {
  }
}
Exemplo n.º 23
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* MCU configure */
  SCB->VTOR = FLASH_BASE | 0x20000;
  
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
	
  /* Configure the system clock to 168 MHz */
  SystemClock_Config();
  
  /* Convert version string */
  uint32_t len =0;
  len += sprintf(&version[len],"%s ",FIRMWARE_NAME);
  len += sprintf(&version[len],"%s ",FIRMWARE_VERSION);
  len += sprintf(&version[len],"%s ",FIRMWARE_TIME);
  version[len]=0;
  
  /* Init USART1 for debug */
  MX_USART1_UART_Init();
  printf("%s\n",version);
  
  /* Configure */
	itouch_init();
	
  /* Init MSC Application */
  USBD_Init(&USBD_Device, &MSC_Desc, 0);
  
  /* Add Supported Class */
  USBD_RegisterClass(&USBD_Device, USBD_MSC_CLASS);
  
  /* Start Device Process */
  USBD_Start(&USBD_Device);

  /* Run Application (Interrupt mode) */
  while (1)
  {
    itouch_run();
  }
}
Exemplo n.º 24
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F3xx HAL library initialization:
       - Configure the Flash prefetch
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();

  /* Initialize LEDs */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);

  /* Configure the system clock to 72 MHz */
  SystemClock_Config();

  /* Change Systick priority: should be higher than Key button interrupt */
  HAL_NVIC_SetPriority(SysTick_IRQn,0,0);

  /* Initialize Joystick */
  BSP_JOY_Init(JOY_MODE_GPIO);

  /* Configure Key button for remote wakeup */
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);

  /* Init Device Library */
  USBD_Init(&USBD_Device, &HID_Desc, 0);

  /* Register the HID class */
  USBD_RegisterClass(&USBD_Device, &USBD_HID);

  /* Start Device Process */
  USBD_Start(&USBD_Device);

  while (1)
  {
  }
}
Exemplo n.º 25
0
void USB_power(unsigned char enabled) {
  os_memset(&USBD_Device, 0, sizeof(USBD_Device));

  if (enabled) {
    os_memset(&USBD_Device, 0, sizeof(USBD_Device));
    /* Init Device Library */
    USBD_Init(&USBD_Device, (USBD_DescriptorsTypeDef*)&HID_Desc, 0);
    
    /* Register the HID class */
    USBD_RegisterClass(&USBD_Device, (USBD_ClassTypeDef*)&USBD_HID);

    /* Start Device Process */
    USBD_Start(&USBD_Device);
  }
  else {
    USBD_DeInit(&USBD_Device);
  }
}
Exemplo n.º 26
0
void UartUsbInit( Uart_t *obj, UartId_t uartId, PinNames tx, PinNames rx )
{
    obj->UartId = uartId;

    __HAL_RCC_COMP_CLK_ENABLE( );
    __HAL_RCC_SYSCFG_CLK_ENABLE( );

    CDC_Set_Uart_Obj( obj );

    /* Init Device Library, Add Supported Class and Start the library */
    USBD_Init( &hUsbDeviceFS, &FS_Desc, DEVICE_FS );

    USBD_RegisterClass( &hUsbDeviceFS, &USBD_CDC );

    USBD_CDC_RegisterInterface( &hUsbDeviceFS, &USBD_Interface_fops_FS );

    USBD_Start( &hUsbDeviceFS );
}
Exemplo n.º 27
0
void io_usb_enable(unsigned char enabled) {
  if (enabled) {
    os_memset(&USBD_Device, 0, sizeof(USBD_Device));
    /* Init Device Library */
    USBD_Init(&USBD_Device, &HID_Desc, 0);
    
    /* Register the HID class */
    USBD_RegisterClass(&USBD_Device, &USBD_CUSTOM_HID);

    USBD_CUSTOM_HID_RegisterInterface(&USBD_Device, &USBD_CustomHID_template_fops);
    
    /* Start Device Process */
    USBD_Start(&USBD_Device);
  }
  else {
    USBD_DeInit(&USBD_Device);
  }
}
Exemplo n.º 28
0
void BSP_USBD_CDC_Init(void)
{
#ifdef USB_OTG_FS_CORE
  RX_FIFO_FS_SIZE = RX_FIFO_FS_SIZE_CDC;
  TX0_FIFO_FS_SIZE = TX0_FIFO_FS_SIZE_CDC;
  TX1_FIFO_FS_SIZE = TX1_FIFO_FS_SIZE_CDC;
  TX2_FIFO_FS_SIZE = TX2_FIFO_FS_SIZE_CDC;
  TX3_FIFO_FS_SIZE = TX3_FIFO_FS_SIZE_CDC;
#endif

  USBD_Init(&USB_OTG_Core,
#ifdef USE_USB_OTG_HS
          USB_OTG_HS_CORE_ID,
#else
          USB_OTG_FS_CORE_ID,
#endif
          &USR_desc, &USBD_CDC_cb, &USR_cb);
}
Exemplo n.º 29
0
TM_USB_HIDDEVICE_Status_t TM_USB_HIDDEVICE_Init(void) {
	/* Initialize HID device */
	USBD_Init(&USB_OTG_dev,
	#ifdef USE_USB_OTG_HS 
			USB_OTG_HS_CORE_ID,
	#else            
			USB_OTG_FS_CORE_ID,
	#endif
			&USR_desc, 
			&USBD_HID_cb, 
			&USR_cb);
	
	/* Set not connected */
	TM_USB_HIDDEVICE_INT_Status = TM_USB_HIDDEVICE_Status_Disconnected;
	
	/* Device not connected */
	return TM_USB_HIDDEVICE_INT_Status;
}
Exemplo n.º 30
0
/*******************************************************************************
 * Function Name  : SPARK_USB_Setup
 * Description    : Spark USB Setup.
 * Input          : None.
 * Return         : None.
 *******************************************************************************/
void SPARK_USB_Setup(void)
{
    if (!USB_Configured)
        return;

    USB_Composite_Instance = USBD_Composite_Instance(&HAL_USB_Handle_Configuration);
    USBD_Init(&USB_OTG_dev,
#ifdef USE_USB_OTG_FS
            USB_OTG_FS_CORE_ID,
#elif defined USE_USB_OTG_HS
            USB_OTG_HS_CORE_ID,
#endif
            &USR_desc,
            //&USBD_CDC_cb,
            USB_Composite_Instance,
            &USR_cb);
    HAL_USB_Attach();
}