Exemple #1
0
void VCP_Init()
{
    USBD_Init(&handleUSBD, &VCP_Desc, 0);
    USBD_RegisterClass(&handleUSBD, &USBD_CDC);
    USBD_CDC_RegisterInterface(&handleUSBD, &USBD_CDC_fops);
    USBD_Start(&handleUSBD);
} 
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F469xx HAL library initialization */
  HAL_Init();

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

  /* Initialize IO expander (MFX) */
  BSP_IO_Init();

  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);

  /* Initialize IO expander */
  BSP_IO_Init();

  /* Initialize Joystick */
  if (BSP_JOY_Init(JOY_MODE_GPIO) == 0)
  {
    JoyButtonInitialized = 1;
  }

  /* Init CDC Application */
  USBD_Init(&USBD_Device_HS, &VCP_Desc, 1);

  /* Init HID Application */
  USBD_Init(&USBD_Device_FS, &HID_Desc, 0);

  /* Add Supported Classes */
  USBD_RegisterClass(&USBD_Device_HS, &USBD_CDC);
  USBD_RegisterClass(&USBD_Device_FS, &USBD_HID);

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

  /* Start Device Process */
  USBD_Start(&USBD_Device_FS);
  USBD_Start(&USBD_Device_HS);

  /* Run Application (Interrupt mode) */
  while (1)
  {
    Toggle_Leds();
    if(HID_SendReport == 1)
    {
      HID_SendReport = 0;
      GetPointerData(HID_Buffer);

      /* Send data though IN endpoint*/
      if((HID_Buffer[1] != 0) || (HID_Buffer[2] != 0))
      {
        USBD_HID_SendReport(&USBD_Device_FS, HID_Buffer, 4);
      }
    }
  }
}
Exemple #3
0
void usb_device_init(void)
{
	USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);
	USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC);
	USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);
	USBD_Start(&hUsbDeviceFS);
}
Exemple #4
0
void startup_task (void *pvParameters)
{

   (void) pvParameters;
   MX_GPIO_Init();

   /* Init Device Library */
   USBD_Init(&hUsbDeviceFS, &VCP_Desc, 0);
   /* Add Supported Class */
   USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC);
   /* Add CDC Interface Class */
   USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);
   /* Start Device Process */
   USBD_Start(&hUsbDeviceFS);

   xdev_out(putchar);


   MX_SDIO_SD_Init();
   FATFS_LinkDriver(&SD_Driver, SD_Path);
   fsInit();


   vTaskDelete(NULL);
}
Exemple #5
0
/* USER CODE BEGIN 0 */
void usb_init(void)
{
	USBD_Init(&USBD_Device, &VCP_Desc, 0);
	USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS);
	USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops);
	USBD_Start(&USBD_Device);
}
Exemple #6
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F446xx HAL library initialization */
  HAL_Init();
  
  /* Configure the system clock to 180 MHz */
  SystemClock_Config();
    
  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);
  
  /* 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);
  
  /* Start Device Process */
  USBD_Start(&USBD_Device);
  
  /* Run Application (Interrupt mode) */
  while (1)
  {
    Toggle_Leds();
  }
}
Exemple #7
0
bool pyb_usb_dev_init(uint16_t vid, uint16_t pid, usb_device_mode_t mode, USBD_HID_ModeInfoTypeDef *hid_info) {
#ifdef USE_DEVICE_MODE
    if (!(pyb_usb_flags & PYB_USB_FLAG_DEV_ENABLED)) {
        // only init USB once in the device's power-lifetime
        USBD_SetVIDPIDRelease(vid, pid, 0x0200, mode == USBD_MODE_CDC);
        if (USBD_SelectMode(mode, hid_info) != 0) {
            return false;
        }
        USBD_Init(&hUSBDDevice, (USBD_DescriptorsTypeDef*)&USBD_Descriptors, 0);
        USBD_RegisterClass(&hUSBDDevice, &USBD_CDC_MSC_HID);
        USBD_CDC_RegisterInterface(&hUSBDDevice, (USBD_CDC_ItfTypeDef*)&USBD_CDC_fops);
        switch (pyb_usb_storage_medium) {
#if MICROPY_HW_HAS_SDCARD
            case PYB_USB_STORAGE_MEDIUM_SDCARD:
                USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_SDCARD_STORAGE_fops);
                break;
#endif
            default:
                USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
                break;
        }
        USBD_Start(&hUSBDDevice);
    }
    pyb_usb_flags |= PYB_USB_FLAG_DEV_ENABLED;
#endif

    return true;
}
void serviceUSBWrite()
{
    if (usbTransferHasCompleted)
    {
        //printf("USB Transfer Completed\r\n");
        // Set USB as no longer active
        usbIsActive = 0;

        usbTransmitBufferLengths[activeUsbBuffer] = 0;

        // Set the active USB buffer to the next buffer
        activeUsbBuffer++;
        if (activeUsbBuffer >= USB_SEND_BUFFER_NUM)
        {
            activeUsbBuffer = 0;
        }

        // Clear the overrun status
        usbBufferOverrun = 0;

        usbTransferHasCompleted = 0;
    }

    // If usb in inactive and
    // the active buffer has data and
    // we can start another transfer
    if (usbIsActive == 0 &&
        usbTransmitBufferLengths[activeUsbBuffer] > 0)
    {
        // Mark USB as active to not overwrite buffer
        usbIsActive = 1;

        // Increase the nextBuffer ptr
        if (nextUsbBuffer == activeUsbBuffer)
        {
            nextUsbBuffer++;
            if (nextUsbBuffer >= USB_SEND_BUFFER_NUM)
            {
                nextUsbBuffer = 0;
            }
        }

        //printf("Writing %lu bytes to USB stack\r\n", usbTransmitBufferLengths[activeUsbBuffer]);

        // Transmit the current active buffer across USB
        // Actual transmission will take place in a later USB IRQ
        USBD_CDC_SetTxBuffer(&USBD_Device,
                             usbTransmitBuffers[activeUsbBuffer],
                             usbTransmitBufferLengths[activeUsbBuffer]);

        USBD_CDC_TransmitPacket(&USBD_Device);
    }

    if (reinitUSB)
    {
        reinitUSB = 0;

        USBD_CDC_RegisterInterface(&USBD_Device, &cdcInterface);
    }
}
Exemple #9
0
void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
#ifdef USE_DEVICE_MODE
    if (!dev_is_enabled) {
        // only init USB once in the device's power-lifetime
        // Windows needs a different PID to distinguish different device
        // configurations, so we set it here depending on mode.
        if (mode == USB_DEVICE_MODE_CDC_MSC) {
            USBD_SelectMode(USBD_MODE_CDC_MSC);
            USBD_SetPID(0x9800);
        } else {
            USBD_SelectMode(USBD_MODE_CDC_HID);
            USBD_SetPID(0x9801);
        }
        USBD_Init(&hUSBDDevice, (USBD_DescriptorsTypeDef*)&VCP_Desc, 0);
        USBD_RegisterClass(&hUSBDDevice, &USBD_CDC_MSC_HID);
        USBD_CDC_RegisterInterface(&hUSBDDevice, (USBD_CDC_ItfTypeDef*)&USBD_CDC_fops);
#if MICROPY_HW_HAS_SDCARD
        if (medium == USB_STORAGE_MEDIUM_FLASH) {
            USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
        } else {
            USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_SDCARD_STORAGE_fops);
        }
#else
        USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
#endif
        USBD_Start(&hUSBDDevice);
    }
    dev_is_enabled = 1;
#endif
}
Exemple #10
0
void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
#ifdef USE_DEVICE_MODE
    if (!dev_is_enabled) {
        // only init USB once in the device's power-lifetime
        if (mode == USB_DEVICE_MODE_CDC_MSC) {
            USBD_SelectMode(USBD_MODE_CDC_MSC);
        } else {
            USBD_SelectMode(USBD_MODE_CDC_HID);
        }
        USBD_Init(&hUSBDDevice, (USBD_DescriptorsTypeDef*)&VCP_Desc, 0);
        USBD_RegisterClass(&hUSBDDevice, &USBD_CDC_MSC_HID);
        USBD_CDC_RegisterInterface(&hUSBDDevice, (USBD_CDC_ItfTypeDef*)&USBD_CDC_fops);
#if MICROPY_HW_HAS_SDCARD
        if (medium == USB_STORAGE_MEDIUM_FLASH) {
            USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
        } else {
            USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_SDCARD_STORAGE_fops);
        }
#else
        USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
#endif
        USBD_Start(&hUSBDDevice);
    }
    dev_is_enabled = 1;

    // create an exception object for interrupting by VCP
    mp_const_vcp_interrupt = mp_obj_new_exception_msg(&mp_type_OSError, "VCPInterrupt");
#endif
}
Exemple #11
0
void USB_CDC_Confg(void)
{
	USBD_Init(&USBD_Device, &VCP_Desc, 0);
	USBD_RegisterClass(&USBD_Device, &USBD_CDC);
	USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_HomeRobot_fops);
	USBD_Start(&USBD_Device);
}
Exemple #12
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_CDC);
  USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS);
  USBD_Start(&hUsbDeviceFS);
}
void USB_CDC_Init()
{
	USBD_Init(&USBD_Device, &VCP_Desc, 0);

	USBD_RegisterClass(&USBD_Device, &USBD_CDC);
	USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_Template_fops);

	USBD_Start(&USBD_Device);
}
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 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);
}
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 );
}
Exemple #17
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 the LEDs */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
    /*Initialize Joystick */
  BSP_JOY_Init(JOY_MODE_GPIO);
  
  /* Init MSC Application */
  USBD_Init(&USBD_Device_HS, &VCP_Desc, 1);
    
  /* Init HID Application */
  USBD_Init(&USBD_Device_FS, &HID_Desc, 0);
  
  /* Add Supported Classes */
  USBD_RegisterClass(&USBD_Device_HS, &USBD_CDC);
  USBD_RegisterClass(&USBD_Device_FS, &USBD_HID);
  
    /* Add CDC Interface Class */
  USBD_CDC_RegisterInterface(&USBD_Device_HS, &USBD_CDC_fops);
  
  /* Start Device Process */
  USBD_Start(&USBD_Device_FS);
  USBD_Start(&USBD_Device_HS);
  
  /* Run Application (Interrupt mode)*/
  while (1)
  {
  }
}
Exemple #18
0
int main(void)
{
	HAL_Init();
	SystemClock_Config();
	USBD_Init(&USBD_Device, &VCP_Desc, 0);

	USBD_RegisterClass(&USBD_Device, &USBD_CDC);
	USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_$$PROJECTNAME$$_fops);
	USBD_Start(&USBD_Device);

	char byte;
	for (;;)
	{
		if (VCP_read(&byte, 1) != 1)
			continue;
		VCP_write("\r\nYou typed ", 12);
		VCP_write(&byte, 1);
		VCP_write("\r\n", 2);
	}
}
serialPort_t *usbVcpOpen(void)
{
    vcpPort_t *s;
    
    /* 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);
    
    /* Start Device Process */
    USBD_Start(&USBD_Device);

    s = &vcpPort;
    s->port.vTable = usbVTable;

    return (serialPort_t *)s;
}
Exemple #20
0
void pyb_usb_dev_init(usbd_device_kind_t device_kind, usbd_storage_medium_kind_t medium_kind) {
#ifdef USE_DEVICE_MODE
    if (!dev_is_enabled) {
        // only init USB once in the device's power-lifetime
        switch (device_kind) {
            case USBD_DEVICE_CDC:
                // XXX USBD_CDC_Init (called by one of these functions below) uses malloc,
                // so the memory is invalid after a soft reset (which resets the GC).
                USBD_Init(&hUSBDDevice, &VCP_Desc, 0);
                USBD_RegisterClass(&hUSBDDevice, &USBD_CDC);
                USBD_CDC_RegisterInterface(&hUSBDDevice, (USBD_CDC_ItfTypeDef*)&USBD_CDC_fops);
                USBD_Start(&hUSBDDevice);
                //USBD_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_PYB_cb, &USR_cb);
                break;

            case USBD_DEVICE_MSC:
                // XXX USBD_CDC_Init (called by one of these functions below) uses malloc,
                // so the memory is invalid after a soft reset (which resets the GC).
                USBD_Init(&hUSBDDevice, &MSC_Desc, 0);
                USBD_RegisterClass(&hUSBDDevice, &USBD_MSC);
                if (medium_kind == USBD_STORAGE_MEDIUM_FLASH) {
                    USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_FLASH_STORAGE_fops);
                } else {
                    USBD_MSC_RegisterStorage(&hUSBDDevice, (USBD_StorageTypeDef*)&USBD_SDCARD_STORAGE_fops);
                }
                USBD_Start(&hUSBDDevice);
                break;

            case USBD_DEVICE_HID:
                //USBD_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_PYB_HID_cb, &USR_cb);
                // TODO
                break;
        }
    }
    dev_is_enabled = 1;

    // create an exception object for interrupting by VCP
    mp_const_vcp_interrupt = mp_obj_new_exception_msg(&mp_type_OSError, "VCPInterrupt");
#endif
}
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
  

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

  GPIO_InitTypeDef init_str;

  init_str.Pin = GPIO_PIN_0;
  init_str.Mode = GPIO_MODE_OUTPUT_PP;
  init_str.Pull = 0;
  init_str.Speed = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOB, &init_str);

  /* 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);
  
  /* Start Device Process */
  USBD_Start(&USBD_Device);
  
  /* Infinite loop */
  while (1)
  {
	  HAL_Delay(500);
	  HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
  }
}
Exemple #22
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();
  
  /* Configure the system clock to 72 Mhz */
  SystemClock_Config();

  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED_GREEN);
  BSP_LED_Init(LED_ORANGE);
  BSP_LED_Init(LED_RED);
  BSP_LED_Init(LED_BLUE);
  
  /* Init Device Library */
  USBD_Init(&hUSBDDevice, &VCP_Desc, 0);
  
  /* Add Supported Class */
  USBD_RegisterClass(&hUSBDDevice, &USBD_CDC);
  
  /* Add CDC Interface Class */
  USBD_CDC_RegisterInterface(&hUSBDDevice, &USBD_CDC_fops);
  
  /* Start Device Process */
  USBD_Start(&hUSBDDevice);
  
  while (1)
  {
  }
}
Exemple #23
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Enable the CPU Cache */
  CPU_CACHE_Enable();
  
  /* STM32F7xx HAL library initialization:
       - Configure the Flash ART accelerator on ITCM interface
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();
  
  /* Configure the System clock to have a frequency of 216 MHz */
  SystemClock_Config();
    
  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);
  
  /* 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);
  
  /* Start Device Process */
  USBD_Start(&USBD_Device);
  
  /* Run Application (Interrupt mode) */
  while (1)
  {
    Toggle_Leds();
  }
}
Exemple #24
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 LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* 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);
  
  /* Start Device Process */
  USBD_Start(&USBD_Device);
  
  /* Run Application (Interrupt mode) */
  while (1)
  {
    Toggle_Leds();
  }
}
Exemple #25
0
/* Setup Function --------------------------*/
void setup(){
	HAL_Init();
	//Initializze board's led
	BSP_LED_Init(0);
	BSP_LED_Init(1);
	BSP_LED_Init(2);
	BSP_LED_Init(3);
	//Initializze board's accelerometer
    BSP_ACCELERO_Init();
	//Initializze USB device
	BSP_LED_On(LED3);
	USBD_Init(&USBD_Device, &VCP_Desc, 0);
	USBD_RegisterClass(&USBD_Device, &USBD_CDC);
	USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_Template_fops);
	USBD_Start(&USBD_Device);
	HAL_Delay(4000);
	BSP_LED_Off(LED3);
	//Initializze ADC conv
	MX_ADC1_Init();

	//Initializze logical variable and memory areas
	memset(request, '\0',256);
	memset(response,'\0',256);
}
Exemple #26
0
static void HW_Init(void)
{
  GPIO_InitTypeDef  GPIO_InitStruct;

  /* Init STM32F401 discovery LEDs */
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  BSP_LED_Init(LED5);
  BSP_LED_Init(LED6);

  /* Init SPI and I2C */
  GYRO_IO_Init();
  COMPASSACCELERO_IO_Init();

  /* Init on-board AccelMag */
  BSP_ACCELERO_Init();

  /* Init BlueNRG CS, Reset, and IRQ pin */
  BLUENRG_CS_GPIO_CLK_ENABLE();
  GPIO_InitStruct.Pin   = BLUENRG_CS_PIN;
  GPIO_InitStruct.Mode  = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull  = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  HAL_GPIO_Init(BLUENRG_CS_GPIO_PORT, &GPIO_InitStruct);
  HAL_GPIO_WritePin(BLUENRG_CS_GPIO_PORT, BLUENRG_CS_PIN, GPIO_PIN_SET);

  BLUENRG_RESET_GPIO_CLK_ENABLE();
  GPIO_InitStruct.Pin   = BLUENRG_RESET_PIN;
  GPIO_InitStruct.Mode  = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull  = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  HAL_GPIO_Init(BLUENRG_RESET_GPIO_PORT, &GPIO_InitStruct);

  BLUENRG_IRQ_GPIO_CLK_ENABLE();
  GPIO_InitStruct.Pin   = BLUENRG_IRQ_PIN;
  GPIO_InitStruct.Mode  = GPIO_MODE_IT_RISING;
  GPIO_InitStruct.Pull  = GPIO_NOPULL;
  HAL_GPIO_Init(BLUENRG_IRQ_GPIO_PORT, &GPIO_InitStruct);

#ifdef WITH_USART
  /* Init USART port */
  UsartHandle.Instance        = USART2;
  UsartHandle.Init.BaudRate   = 9600;
  UsartHandle.Init.WordLength = USART_WORDLENGTH_8B;
  UsartHandle.Init.StopBits   = USART_STOPBITS_1;
  UsartHandle.Init.Parity     = USART_PARITY_NONE;
  UsartHandle.Init.Mode       = USART_MODE_TX_RX;
  if (HAL_USART_Init(&UsartHandle) != HAL_OK)
  {
    ColorfulRingOfDeath();
  }
#endif

#ifdef WITH_VCP
  /* Init Device Library */
  USBD_Init(&hUSBDDevice, &VCP_Desc, 0);

  /* Add Supported Class */
  USBD_RegisterClass(&hUSBDDevice, &USBD_CDC);

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

  /* Start Device Process */
  USBD_Start(&hUSBDDevice);
#endif
}