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

📄 segment.c

📁 AT91所有开发板的资料 AT91所有开发板的资料
💻 C
字号:
/****************************************************************
 *
 * ARM Strategic Support Group
 * 
 ****************************************************************/

/****************************************************************
 *
 *	Module		: segment.c
 *	Description	: Rotates the 7 segment display
 *  Tool Chain	: ARM Developer Suite 1.0
 *	Platform	: Evaluator7T
 * 	History		: 
 *
 *		2000-03-22 Andrew N. Sloss
 *		- implemented
 *				
 *	Notes		:
 *
 *				This program never end the user has to break in
 *				using the debugger.
 *
 ****************************************************************/

/****************************************************************
 * IMPORT
 ****************************************************************/

#include "segment.h"

/****************************************************************
 * MACROS
 ****************************************************************/

// -- Samsung KS32C50100 settings ....

#define SYSCFG			0x03ff0000
#define IOPMOD          ((volatile unsigned *)(SYSCFG+0x5000))
#define IOPDATA         ((volatile unsigned *)(SYSCFG+0x5008))

// standard defines ..................

#define FOREVER			(1)	

/****************************************************************
 * MISC
 ****************************************************************/

// none...

/****************************************************************
 * DATATYPE
 ****************************************************************/

// none...

/****************************************************************
 * STATICS
 ****************************************************************/

// -- numeric_display for the 7 segment display....

static unsigned int numeric_display [16] = 
{
	DISP_0,
	DISP_1,
	DISP_2,
	DISP_3,
	DISP_4,
	DISP_5,
	DISP_6,
	DISP_7,
	DISP_8,
	DISP_9,
	DISP_A,
	DISP_B,
	DISP_C,
	DISP_D,
	DISP_E,
	DISP_F
};	

/****************************************************************
 * ROUTINES
 ****************************************************************/

/* -- segment_setdisplay ----------------------------------------
 * 
 * Descriptions	: sets the display of the segment display
 *
 * Parameters	: int d - binary pattern
 * Return		: none...
 * Notes		: 
 *
 */

void segment_setdisplay (unsigned d)
{
		*IOPDATA 	&= ~SEG_MASK;
		*IOPDATA 	|= d;	
}

/* -- segment_set -----------------------------------------------
 * 
 * Descriptions	: check whether number is in the range of 0x0 and
 *				  0xf. If so then it set the segment display. 
 *
 * Parameters	: int seg - then new number to set the segment 
 *				  display.
 * Return		: none...
 * Notes		: 
 *
 */

void segment_set (int seg)
{
	if ( seg >= 0 & seg <= 0xf ) 
		segment_setdisplay(numeric_display[seg]);

}

/* -- segment_delay --------------------------------------------
 * 
 * Description	: produces a particular time delay. 
 *
 * Parameters	: int d - depth
 * Return		: none...
 * Notes		: 
 *
 */

void segment_delay (int d)
{
int i;

	for ( i=0; i<=d; i++ ) {}
}

/* -- segment_rotate -------------------------------------------
 * 
 * Description	: rotates from 0xf to 0 on the segment display. 
 *
 * Parameters	: none...
 * Return		: none...
 * Notes		: 
 *
 */

void segment_rotate (void)
{
int x;

	for ( x=0xf; x>=0; x--) {
		segment_set (x);
		segment_delay  (0xeffff);
	}
}	

/* -- segment_init ---------------------------------------------
 * 
 * Description	: initialize the 7 segment display. 
 *
 * Parameters	: int d - depth
 * Return		: none...
 * Notes		: 
 *
 */

void segment_init (void)
{
	*IOPMOD 	|= SEG_MASK;
	*IOPDATA 	|= SEG_MASK;
}


/****************************************************************
 * END OF segment.c
 ****************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -