?? exercise_2.c
字號:
#include "..\include\exercise_2.h"
#define SW6_BIT 0x0020
#define SW7_BIT 0x0040
typedef enum {OFF, ON} Switch_States;
Switch_States state_sw6=OFF, state_sw7=OFF;
// state variables for switch 6 and 7
// init state: off
//--------------------------------------------------------------------------//
// Function: main //
// //
// Description: After calling a few initalization routines, main() just //
// waits in a loop forever. A simple state modell is implemented //
// to check the switch status and act correspondingly. The code to process the incoming //
// data can be placed in the function Process_Data() in the //
// file "Process_Data.c". //
//--------------------------------------------------------------------------//
/*
void process_data();
void reduce_volume();
void increase_volume();
*/
void main(void)
{
*pFIO0_INEN |= 0x01E0; // enable input buffer PF5 .. 8
ssync();
#ifndef DSP_DEBUG
// initialize AD1836 when code is not debugged
start_AD1836();
#else
// set cNewSample when code is debugged
cNewSample=1;
#endif
// loop forever
while(1) {
#ifndef DSP_DEBUG
idle(); // go asleep and wake up when external interrupt and ISR have been
// processed
#endif
if (cNewSample) { // check whether new sample has been read by SPORT0 ISR
#ifndef DSP_DEBUG
cNewSample=0; // reset flag
#endif
switch (state_sw6) { // State of SW6
case OFF: // is off
if (*pFIO0_FLAG_D & SW6_BIT) { // current state = on
state_sw6 = ON; // set State of SW6 to on
reduce_volume();
}
break;
case ON: // is on
if (!(*pFIO0_FLAG_D & SW6_BIT)) { // current state = off
state_sw6 = OFF; // set State of SW6 to off
}
break;
}
switch (state_sw7) { // State of SW7
case OFF: // is off
if (*pFIO0_FLAG_D & SW7_BIT) { // current state = on
state_sw7 = ON; // set State of SW7 to on
increase_volume();
}
break;
case ON: // is on
if (!(*pFIO0_FLAG_D & SW7_BIT)) { // current state = off
state_sw7 = OFF; // set State of SW7 to off
}
break;
}
process_data(); // do the sample processing
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -