分享一点资料拿份
单片机源程序如下:
- /*
- *******************************************************************************
- * Copyright (c) 2008,
- * All rights reserved.
- *
- * File Name : Main.c
- * Project :
- * Author :
- * Version : 1.0.0
- * Date : 12/11/2008
- * Description :
- *******************************************************************************
- */
- /*
- *************************************修改日志**********************************
- *******************************************************************************
- */
- #include "Includes.h"
- /*
- *******************************************************************************
- * 常量定义
- *******************************************************************************
- */
- #define PROC_CNT 0x09
- #define MODEM_TEST 0
- /*
- *******************************************************************************
- * 类型定义
- *******************************************************************************
- */
- typedef struct
- {
- void (*proc)(void); //处理程序//
- s8 TaskTick; //时间片大小//
- }sTask;
- /*
- *******************************************************************************
- * 变量定义
- *******************************************************************************
- */
- s32 SoftDog = 0;
- static u8 Task_Cnt;
- bool LicenseOK = FALSE;
- const u8 Version[]=" [Version 1.0.0]";
- u8 time_val[PROC_CNT]={10, 1000, 10, 10, 10, 100, 10, 100}; //设置时间片初始值//
- const sTask Task[PROC_CNT] = {
- {APP_Task, 2},
- {FILE_Monitor, 1000},
- {NULL, 10},
- {NULL, 10},
- {NULL, 10},
- {NULL, 100},
- {NULL, 10},
- {NULL, 100},
- }; //任务栈初始化//
- /*
- *******************************************************************************
- * 函数原型定义
- *******************************************************************************
- */
- u16 DetectResetReason(void)
- {
- u16 ResetFlag = 0;
-
- if (SET == RCC_GetFlagStatus(RCC_FLAG_HSIRDY))
- {
- ResetFlag |= 0x0001;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_HSERDY))
- {
- ResetFlag |= 0x0002;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_PLLRDY))
- {
- ResetFlag |= 0x0004;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_LSERDY))
- {
- ResetFlag |= 0x0008;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_LSIRDY))
- {
- ResetFlag |= 0x0010;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_PINRST))
- {
- ResetFlag |= 0x0020;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_PORRST))
- {
- ResetFlag |= 0x0040;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_SFTRST))
- {
- ResetFlag |= 0x0080;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_IWDGRST))
- {
- ResetFlag |= 0x0100;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_WWDGRST))
- {
- ResetFlag |= 0x0200;
- }
- if (SET == RCC_GetFlagStatus(RCC_FLAG_LPWRRST))
- {
- ResetFlag |= 0x0400;
- }
- return ResetFlag;
- }
- void DisplayResetReason(u16 Reason)
- {
- if ((Reason & 0x0001) == 0x0001)
- {
- Trace("RCC_FLAG_HSIRDY\r\n");
- }
- if ((Reason & 0x0002) == 0x0002)
- {
- Trace("RCC_FLAG_HSERDY\r\n");
- }
- if ((Reason & 0x0004) == 0x0004)
- {
- Trace("RCC_FLAG_PLLRDY\r\n");
- }
- if ((Reason & 0x0008) == 0x0008)
- {
- Trace("RCC_FLAG_LSERDY\r\n");
- }
- if ((Reason & 0x0010) == 0x0010)
- {
- Trace("RCC_FLAG_LSIRDY\r\n");
- }
- if ((Reason & 0x0020) == 0x0020)
- {
- Trace("RCC_FLAG_PINRST\r\n");
- }
- if ((Reason & 0x0040) == 0x0040)
- {
- Trace("RCC_FLAG_PORRST\r\n");
- }
- if ((Reason & 0x0080) == 0x0080)
- {
- Trace("RCC_FLAG_SFTRST\r\n");
- }
- if ((Reason & 0x0100) == 0x0100)
- {
- Trace("RCC_FLAG_IWDGRST\r\n");
- }
- if ((Reason & 0x0200) == 0x0200)
- {
- Trace("RCC_FLAG_WWDGRST\r\n");
- }
- if ((Reason & 0x0400) == 0x0400)
- {
- Trace("RCC_FLAG_LPWRRST\r\n");
- }
- }
- /*
- *******************************************************************************
- * 函数描述:任务调度钩子
- * 输入参数:无
- * 输出参数:无
- * 返回参数:无
- *******************************************************************************
- */
- s16 TaskTimerHook(void)
- {
- u8 i;
- for (i=0;i<PROC_CNT;i++)
- {
- if (time_val[i] > 0)
- {
- time_val[i]--;
- }
- }
- if (SoftDog > 0)
- {
- SoftDog--;
- }
- else
- {
- i = 0;
- BSP_UartPollSend(USART1, "SoftDog!\r\n\0");
- BSP_SysReset();
- }
- return 0;
- }
- FATFS fs; // Work area (file system object) for logical drive
- int main(void)
- {
- u16 reason = 0;
- reason = DetectResetReason();
- /* Initialize the Demo */
- SoftDog = 60 * OS_TICKS_PER_SEC; //喂软狗//
- BSP_SysInit();
- USB_DetectInit(ENABLE);
- DisplayResetReason(reason);
- Timer_Register(TaskTimerHook, 1);
- Timer_Register(SYS_Timer, 1);
- // Register a work area for logical drive 0
- f_mount(0, &fs);
- CFG_Init();
- //FILE_Scan("/");
-
- FILE_List("/linedata");
-
- FILE_Append("/linedata/rec.txt", "test write data!\r\n", strlen("test write data!\r\n"));
- while (1)
- {
- for (Task_Cnt=0;Task_Cnt<PROC_CNT;Task_Cnt++)
- {
- if (0 == time_val[Task_Cnt])
- {
- time_val[Task_Cnt] = Task[Task_Cnt].TaskTick;
- if (Task[Task_Cnt].proc != NULL)
- {
- if (LicenseOK)
- {
- Task[Task_Cnt].proc();
- }
- }
- }
- USB_DiskProbe();
- BSP_RESET_DOG();
- SoftDog = 60 * OS_TICKS_PER_SEC; //喂软狗//
- }
- }
-
- }
复制代码
所有资料51hei提供下载:
USB读卡器.rar
(1.3 MB, 下载次数: 15)
|