⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exercise_2.c

📁 所用板ADSP-BF561 EZ-KIT Lite
💻 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 + -