接触过一些产品,大多是这种框架,要么时间触发,要么信号触发。main函数如下
/*******************************************************************
Copyright(C) NULL, All rights reserved.
File name: main.c
Author:dong_abc
Version: V1.0
Date: 2011.10.10
Description: NUC1xx MCU Demo of software systerm
History:
********************************************************************/
#include "main.h"
extern struct
{
uint8_t T_5ms :1;
uint8_t T_20ms :1;
uint8_t T_100ms :1;
uint8_t T_500ms :1;
}SysTimeFlag;
void Systerm_Init(void)
{
UNLOCKREG();
SYSCLK->PWRCON.XTL12M_EN = 1;
DrvSYS_Delay(5000);
DrvSYS_Open(48000);
DrvSYS_Delay(5000);
SysTick_Init();
Timer0_Init();
Uart_Init();
ADC_Init();
Seg7_Init();
Key_Init();
}
int main (void)
{
Systerm_Init();
while(1)
{
ADC_Check();
if(SysTimeFlag.T_5ms==true)
{
//add do something in timer 5ms
SysTimeFlag.T_5ms=false;
Seg7_Fresh();
}
if(SysTimeFlag.T_20ms==true)
{
//add do something in timer 20ms
SysTimeFlag.T_20ms=false;
Key_Proc();
}
if(SysTimeFlag.T_100ms==true)
{
//add do something in timer 100ms
SysTimeFlag.T_100ms=false;
}
if(SysTimeFlag.T_500ms==true)
{
//add do something in timer 500ms
SysTimeFlag.T_500ms=false;
}
}
}
NUC1xx.rar
(2.01 MB)
|