2010-08-08 02:14:22 +02:00
|
|
|
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
|
|
|
* File Name : main.c
|
|
|
|
* Author : MCD Application Team
|
|
|
|
* Version : V3.2.1
|
|
|
|
* Date : 07/05/2010
|
2010-08-22 21:51:55 +02:00
|
|
|
* Description : Custom HID demo main file
|
2010-08-08 02:14:22 +02:00
|
|
|
********************************************************************************
|
|
|
|
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
|
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
|
|
|
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
|
|
|
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
|
|
|
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
#include "stm32f10x.h"
|
|
|
|
#include "usb_lib.h"
|
|
|
|
#include "hw_config.h"
|
2010-08-22 21:51:55 +02:00
|
|
|
#include "stm32_eval.h"
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
extern void FLASH_Download();
|
2010-08-08 02:14:22 +02:00
|
|
|
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
|
|
typedef void (*pFunction)(void);
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
pFunction Jump_To_Application;
|
|
|
|
uint32_t JumpAddress;
|
2010-08-22 21:51:55 +02:00
|
|
|
/* Extern variables ----------------------------------------------------------*/
|
|
|
|
uint8_t DeviceState;
|
|
|
|
uint8_t JumpToApp=0;
|
2010-08-08 02:14:22 +02:00
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
2010-08-22 21:51:55 +02:00
|
|
|
void Delay(__IO uint32_t nCount);
|
|
|
|
void DelayWithDown(__IO uint32_t nCount);
|
2010-08-08 02:14:22 +02:00
|
|
|
/* Private functions ---------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Function Name : main.
|
|
|
|
* Description : main routine.
|
|
|
|
* Input : None.
|
|
|
|
* Output : None.
|
|
|
|
* Return : None.
|
|
|
|
*******************************************************************************/
|
|
|
|
int main(void)
|
|
|
|
{
|
2010-08-22 21:51:55 +02:00
|
|
|
if (((*(__IO uint32_t*)StartOfUserCode) & 0x2FFE0000 ) == 0x20000000)
|
|
|
|
{ /* Jump to user application */
|
2010-08-08 02:14:22 +02:00
|
|
|
|
2010-08-22 21:51:55 +02:00
|
|
|
JumpAddress = *(__IO uint32_t*) (StartOfUserCode + 4);
|
|
|
|
Jump_To_Application = (pFunction) JumpAddress;
|
|
|
|
/* Initialize user application's Stack Pointer */
|
|
|
|
__set_MSP(*(__IO uint32_t*) StartOfUserCode);
|
|
|
|
Jump_To_Application();
|
|
|
|
}
|
|
|
|
Set_System();
|
2010-08-08 02:14:22 +02:00
|
|
|
|
2010-08-22 21:51:55 +02:00
|
|
|
USB_Interrupts_Config();
|
2010-08-08 02:14:22 +02:00
|
|
|
|
|
|
|
Set_USBClock();
|
2010-08-22 21:51:55 +02:00
|
|
|
|
2010-08-08 02:14:22 +02:00
|
|
|
USB_Init();
|
|
|
|
|
2010-08-22 21:51:55 +02:00
|
|
|
DeviceState=idle;
|
|
|
|
while (JumpToApp==0)
|
|
|
|
{
|
|
|
|
|
|
|
|
STM_EVAL_LEDToggle(LED1);
|
|
|
|
DelayWithDown(10);//1000000);
|
|
|
|
}
|
|
|
|
if (((*(__IO uint32_t*)StartOfUserCode) & 0x2FFE0000 ) == 0x20000000)
|
|
|
|
{ /* Jump to user application */
|
|
|
|
|
|
|
|
JumpAddress = *(__IO uint32_t*) (StartOfUserCode + 4);
|
|
|
|
Jump_To_Application = (pFunction) JumpAddress;
|
|
|
|
/* Initialize user application's Stack Pointer */
|
|
|
|
__set_MSP(*(__IO uint32_t*) StartOfUserCode);
|
|
|
|
Jump_To_Application();
|
|
|
|
}
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
STM_EVAL_LEDToggle(LED1);
|
|
|
|
STM_EVAL_LEDToggle(LED2);
|
|
|
|
Delay(1000000);
|
|
|
|
}
|
2010-08-08 02:14:22 +02:00
|
|
|
}
|
|
|
|
|
2010-08-22 21:51:55 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Function Name : Delay
|
|
|
|
* Description : Inserts a delay time.
|
|
|
|
* Input : nCount: specifies the delay time length.
|
|
|
|
* Output : None
|
|
|
|
* Return : None
|
|
|
|
*******************************************************************************/
|
|
|
|
void Delay(__IO uint32_t nCount)
|
|
|
|
{
|
|
|
|
for(; nCount!= 0;nCount--)
|
|
|
|
{
|
2010-08-08 02:14:22 +02:00
|
|
|
|
2010-08-22 21:51:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*******************************************************************************
|
|
|
|
* Function Name : Delay
|
|
|
|
* Description : Inserts a delay time.
|
|
|
|
* Input : nCount: specifies the delay time length.
|
|
|
|
* Output : None
|
|
|
|
* Return : None
|
|
|
|
*******************************************************************************/
|
|
|
|
void DelayWithDown(__IO uint32_t nCount)
|
|
|
|
{
|
|
|
|
for(; nCount!= 0;nCount--)
|
|
|
|
{
|
|
|
|
for(__IO uint32_t delay=DownloadDelay ; delay!=0 ; delay--){}
|
|
|
|
FLASH_Download();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef USE_FULL_ASSERT
|
2010-08-08 02:14:22 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Function Name : assert_failed
|
|
|
|
* Description : Reports the name of the source file and the source line number
|
|
|
|
* where the assert_param error has occurred.
|
|
|
|
* Input : - file: pointer to the source file name
|
|
|
|
* - line: assert_param error line source number
|
|
|
|
* Output : None
|
|
|
|
* Return : None
|
|
|
|
*******************************************************************************/
|
|
|
|
void assert_failed(uint8_t* file, uint32_t line)
|
2010-08-22 21:51:55 +02:00
|
|
|
{
|
2010-08-08 02:14:22 +02:00
|
|
|
/* User can add his own implementation to report the file name and line number,
|
|
|
|
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
|
|
|
|
|
|
|
/* Infinite loop */
|
2010-08-22 21:51:55 +02:00
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
}
|
2010-08-08 02:14:22 +02:00
|
|
|
}
|
|
|
|
#endif
|
2010-08-22 21:51:55 +02:00
|
|
|
|
2010-08-08 02:14:22 +02:00
|
|
|
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|