📄 yc_mainfile.c
字号:
/*===========================================================================
【项目名】: 遥控渐变选色程序
【文件名】: YCPLAY
【名 称】: 主文件
【版 本】: 1.0
【组 织】:
【作 者】: 周盛志
【E-mail】: zhounanxu@163.com
------------------------------------------------------------------------
【编译工具】: GCC_AVRX + WinAVR20050214
【编译芯片】: ATMEGA8L
【时钟频率】: 内部8MHZ
【创建时间】: 29/8/2006
【修改时间】:
------------------------------------------------------------------------
【特别说明】: 遥控4键控制
------------------------------------------------------------------------
【使用说明】:
1. A键:开关机;B键:渐变;C键:选色;D键:翻选选色存储的某一色。
2. 每次开机播放上次关机前的最后状态。
===========================================================================*/
#include <avrx/avrx.h>
#include "Hardware.h"
#include "YC_MainFile.h"
Mutex key_pressed;
TimerControlBlock delay;
BYTE bTempValy = 0;
BYTE bTempVal = 0;
//----------------------------------------------------------------
//TimerControlBlock delay;// Declare the control blocks for timers
AVRX_SIGINT(SIG_OVERFLOW0)
{
IntProlog(); //switch to kernel stack/context.
TCNT0 = TCNT0_INIT; //Reset timer overflow count.
AvrXTimerHandler(); //Call Time queue manager
Epilog(); //Return to tasks.
}
AVRX_SIGINT(SIG_INTERRUPT0)
{
IntProlog();
AvrXSetSemaphore(&key_pressed);
Epilog();
}
AVRX_GCC_TASKDEF(KeyPress, 100, 4)
{
while(1)
{
while(1)
{
AvrXResetSemaphore(&key_pressed);
AvrXWaitSemaphore(&key_pressed);
if (PIND & _BV(PD2)) break;
else KeyYc(PINC & 0x0f);
}
}
}
/*Task 1: .*/
AVRX_GCC_TASKDEF(Monitor, 100, 5)
{
while (1)
{
LoadWorkState();
AvrXDelay(&delay, 1);
}
}
int main(void)
{
AvrXSetKernelStack(0);//Set Avrx stack to "0",or,if NULL then to current stack.
ACSR = 0x80;
SFIOR = 0x00;
TCCR0 = T0MC8_CK256; // Set up Timer0 for CLK/256 rate
TCNT0 = TCNT0_INIT;
TIMSK |= _BV(TOIE0); // Enable Timer0 overflow interrupt
InitWorkState();
MCUCR |= _BV(ISC01) ;
GICR |= _BV(INT0);
AvrXRunTask(TCB(Monitor));
AvrXRunTask(TCB(KeyPress));
Epilog(); // Switch from AvrX Stack to first task
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -