예제 #1
0
/**
  * @brief  usbd_dfu_Init
  *         Initializes the DFU interface.
  * @param  pdev: device instance
  * @param  cfgidx: Configuration index
  * @retval status
  */
static uint8_t  usbd_dfu_Init (void  *pdev,
                               uint8_t cfgidx)
{
  /* Initilialize the MAL(Media Access Layer) */
  MAL_Init();

  /* Initialize the state of the DFU interface */
  DeviceState = STATE_dfuIDLE;
  DeviceStatus[4] = DeviceState;

  return USBD_OK;
}
예제 #2
0
파일: main.c 프로젝트: onelife/rt-thread
/*******************************************************************************
* Function Name  : main.
* Description    : main routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
int main(void)
{
    board_init();

    DFU_Button_Config();

    usb.bDeviceState = UNCONNECTED;
    usb.fSuspendEnabled = TRUE;

  /* 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*)AppAddress) & 0x2FFE0000 ) == 0x20000000)
    { /* Jump to user application */

      JumpAddress = *(__IO uint32_t*) (AppAddress + 4);
      Jump_To_Application = (pFunction) JumpAddress;
      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) AppAddress);
      Jump_To_Application();
    }
  } /* Otherwise enters DFU mode to allow user to program his application */


  /* Config and enable clock */
  RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);

  /* Enter DFU mode */
  dfu.bStatus = STATUS_ERRFIRMWARE;
  dfu.bState = STATE_dfuERROR;

  /* Unlock the internal flash */
  FLASH_Unlock();

  /* Init the media interface */
  MAL_Init();

  /* Select USBCLK source */
  RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);

  /* Enable the USB clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);

  USB_Init();

  /* Main loop */
  while (1)
  {}
}
예제 #3
0
파일: main.c 프로젝트: Farewellly/STM32
/*******************************************************************************
* 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)
  {}
}
예제 #4
0
/**
  * @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);

}
예제 #5
0
//void USB_Cable_Config (FunctionalState NewState)
//{
//  if (NewState != DISABLE)
//  {
//	LED1=1;
//  }
//  else
//  {
//	LED1=0;
//  }
//u16 MAL_Init(u8 lun)
//{
//  u16 status = MAL_OK;  
//  switch (lun)
//  {
//    case 0:			    
//      break;			   
//    case 1:					  
//      break;		  
//    default:
//      return MAL_FAIL;
//  }
//  return status;
//}
void MAL_Config(void)
{
	MAL_Init(0);	  
}