| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- /****************************************Copyright (c)****************************************************
- **
- ** http://www.powermcu.com
- **
- **--------------File Info---------------------------------------------------------------------------------
- ** File name: main.c
- ** Descriptions: The UCOSII application function
- **
- **--------------------------------------------------------------------------------------------------------
- ** Created by: AVRman
- ** Created date: 2010-11-9
- ** Version: v1.0
- ** Descriptions: The original version
- **
- **--------------------------------------------------------------------------------------------------------
- ** Modified by:
- ** Modified date:
- ** Version:
- ** Descriptions:
- **
- *********************************************************************************************************/
- /* Includes ------------------------------------------------------------------*/
- #include "includes.h"
- /**********************************************************************************************************
- * main()
- *
- * Description : This is the standard entry point for C code. It is assumed that your code will call
- * main() once you have performed all necessary initialization.
- *
- * Argument(s) : none.
- *
- * Return(s) : none.
- **********************************************************************************************************/
- void PwrLock(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
-
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
- GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
-
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC, ENABLE);
- GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
-
- GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- //USB SWITCH
- GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13;
- GPIO_Init(GPIOC, &GPIO_InitStructure);
- GPIOC->BSRR=GPIO_Pin_13;
- //key power
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Pin=KEY_POWER_PIN;//3
- GPIO_Init(KEY_POWER_PORT, &GPIO_InitStructure);
- }
- #define FLASH_BASE ((uint32_t)0x08000000)
- #define MAIN_CONFIG_ADDR (FLASH_BASE+126*1024)
- int sutProductParaPSN=0;
- void ShowMcuFreq(void)
- {
- char buf[40];
- RCC_ClocksTypeDef clk;
- RCC_GetClocksFreq(&clk);
- //SysTick_Config(clk.SYSCLK_Frequency / 100);
- printf("SYSCLK=%d,PCLK1=%d,PCLK2=%d,HCLK=%d\r\n",clk.SYSCLK_Frequency,clk.PCLK1_Frequency,clk.PCLK2_Frequency,clk.HCLK_Frequency);
- }
- int main (void)
- {
- Uart1Init();
- if (SysTick_Config(SystemCoreClock / 100)){ //100
- while (1);
- }
- PwrLock();
- W25Q64_Init();
- FileSysInit();
- //IapTrace(IAP_VERSION_NAME);
- g_ucRand=GetRandBySTM32ID();
- memset(&sutMsg,0,sizeof(SUT_MSG));
- NewTask(TASK_WAIT);
- ShowMcuFreq();
- CheckPwrKeyOn();
- //NewTask(TASK_DL_APP);
- //CopyFileInit();
- while(1)
- {
- if(sutMsg.Uart1Recv){ //Use for PC
- Uart1Msg();
- g_usRx1Len=0;
- sutMsg.Uart1Recv=0;
- g_usRx1In=0;
- memset(IapRxBuf,0,sizeof(IapRxBuf));
- }
-
- if(sutMsg.TaskStart){
- sutMsg.TaskStart=0;
- StartMsg();
- }
- if(sutMsg.Tick10ms){
- sutMsg.Tick10ms=0;
- TickMsg();
- }
- if(sutMsg.Tick500ms){
- sutMsg.Tick500ms=0;
- Tick500Msg();
- }
- }
- return (0);
- }
- //void assert_failed(uint8_t* file, uint32_t line)
- //{
- // printf("[AF]f:%s,l:%d\r\n",file,line);
- // while (1)
- // {}
- //}
- /*********************************************************************************************************
- END FILE
- *********************************************************************************************************/
|