/******************************************************************************* * 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) {} }
/** * @brief Main program. * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f10x_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f10x.c file */ DFU_Button_Config(); #ifdef Enable_SW_Mode /* Check if the Key push-button on iNEMO Board is pressed or the Option Byte is 0*/ if ( (DFU_Button_Read() != 0x00) && (Option_Byte_Read() != 0x01)) #else /* Check if the Key push-button on iNEMO Board is pressed */ if (DFU_Button_Read() != 0x00) #endif { /* 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 */ #ifdef Enable_SW_Mode /*Delete the Option Byte*/ if(Option_Byte_Read()==0x01) { Leave_DFU_SW_Mode(); } #endif /* Enter DFU mode */ DeviceState = STATE_dfuERROR; DeviceStatus[0] = STATUS_ERRFIRMWARE; DeviceStatus[4] = DeviceState; Set_System(); Set_USBClock(); USB_Init(); /* Main loop */ while (1) {} }
/******************************************************************************* * 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) {} }
/******************************************************************************* * 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) {} }
/******************************************************************************* * Function Name : main. * Description : main routine. * Input : None. * Output : None. * Return : None. *******************************************************************************/ int main(void) { #if defined (USE_STM32L152D_EVAL) FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_OPTVERRUSR); #endif DFU_Button_Config(); /* Check if the Key push-button on STM32-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; Set_System(); Set_USBClock(); USB_Init(); /* Main loop */ while (1) {} }