?? dips.c
字號:
/****************************************************************
*
* ARM Strategic Support Group
*
****************************************************************/
/****************************************************************
*
* Module : dips.c
* Description : Polls the DIP switch and displays the value in
* in hex.
*
* Tool Chain : ARM Developer Suite 1.0
* Platform : Evaluator7T
* Status : Complete
* 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
****************************************************************/
// -- base value for registers on the Evaluator7T ..............
#define SYSCFG 0x03ff0000
// -- look up the Samsung User's Manual for more information....
#define IOPMOD ((volatile unsigned *)(SYSCFG+0x5000))
#define IOPDATA ((volatile unsigned *)(SYSCFG+0x5008))
#define SWITCH_MASK (0xf)
#define FOREVER (1)
#define angel_SWI 0x123456
__swi (angel_SWI) void _Exit(unsigned op, unsigned except);
#define Exit() _Exit(0x18,0x20026)
__swi (angel_SWI) void _WriteC(unsigned op, const char *c);
#define WriteC(c) _WriteC (0x3,c)
/****************************************************************
* DATATYPES
****************************************************************/
// -- 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
****************************************************************/
/* -- dips_delay ------------------------------------------------
*
* Description : produces a particular time delay.
*
* Parameters : int d - depth
* Return : none...
* Notes :
*
*/
void dips_delay (int w)
{
int y;
for ( y=0; y<=w; y++) {};
}
/* -- dips_setsegment -------------------------------------------
*
* Description : outputs a value on the segment display
*
* Parameters : unsigned d - new display value
* Return : none...
* Notes :
*
*/
void dips_setsegment (unsigned d)
{
*IOPDATA &= ~SEG_MASK;
*IOPDATA |= d;
}
/* -- dips_init ------------------------------------------------
*
* Description : setups the segment display
*
* Parameters : none...
* Return : none...
* Notes :
*
*/
void dips_init (void)
{
*IOPMOD |= SEG_MASK;
*IOPDATA |= SEG_MASK;
}
/* -- dips_read ------------------------------------------------
*
* Description : reads the DIP switch
*
* Parameters : none
* Return : return the of the DIP switch
* Notes :
*
*/
unsigned dips_read (void)
{
return SWITCH_MASK & *IOPDATA;
}
/* -- C_Entry --------------------------------------------------
*
* Description : standard entry into the C application
*
* Parameters : none
* Return : none...
* Notes :
*
*/
void C_Entry (void)
{
int dips;
// initialize the segment display ..........................
dips_init ();
// infinite polling loop ...................................
while ( FOREVER ) {
dips = dips_read ();
dips_setsegment(numeric_display[dips]);
dips_delay(0x1ffff0);
}
// should never get to this code ...........................
Exit();
}
/****************************************************************
* END OF DIPS.C
****************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -