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

📄 switch.c

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

/***************************************************************************
 *
 * Module		: Switch.c
 * Description 	: Uses the IRQ interrupt switch... 
 *
 * Platform		: Evaluator7T
 * Tool Chain	: ARM Developers Suite 1.0
 * History		:
 *
 *			980301 ASloss
 *			- started working on the design and structure.
 *
 *			980408 ASloss
 *			- added in-line assembler example.
 *
 *			980428 ASloss
 *			- added interrupt handler
 *
 *			980625 ASloss
 *			- added Angel SWI
 *
 *			990202 ASloss
 *			- added Multi-ICE support
 *
 *			2000-04-04 Andrew N. Sloss
 *			-- port to the Evaluator7T
 *
 **************************************************************************/

/**************************************************************************
 * IMPORTS
 **************************************************************************/

#include <stdio.h>
#include <assert.h>
#include <time.h>

#include "led.h"
#include "irq_ser.h"

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

/* -- Angel SWI ............................ */

#define		angel_SWI	0x123456

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

__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
 **************************************************************************/

// none...

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

static int			counter = 2;
	
/**************************************************************************
 * ROUTINUES
 **************************************************************************/

/* -- switch_init ---------------------------------------------------------
 *
 * Description	:
 * 
 * Parameters	:
 *
 */

void switch_init (void)
{ 
	LED_1_OFF;
	LED_2_OFF;
	LED_3_OFF;
	LED_4_ON;

	irq_init (); 
}


/* -- switch_interrupt ----------------------------------------------------
 *
 * Description	: The interrupt button has been pressed. Toggles LED's...
 *
 * Parameters	: none...
 * Return	: none...
 * Notes	: none...
 *
 */

void switch_interrupt (void)
{
	if ( counter & 0x08 ) LED_1_ON; else LED_1_OFF;
	if ( counter & 0x04 ) LED_2_ON; else LED_2_OFF;
	if ( counter & 0x02 ) LED_3_ON; else LED_3_OFF;
	if ( counter & 0x01 ) LED_4_ON; else LED_4_OFF;

	counter ++;
}


/* -- switch_writes --------------------------------------------------------
 *
 * Description	: write a string via the Angel SWI call WriteC
 *
 * Parameters	: const char *string - string to be written
 * Return	: none...
 * Notes	: none...
 *
 */

void switch_writes (const char *string)
{ 
int pos = 0;

	  while (string[pos] != 0) WriteC(&string[pos++]);
}

/* -- switch_idle ----------------------------------------------------------
 * 
 * Description	: Idle loop
 *
 * Parameters	: none...
 * Return		: none...
 * Notes		: Never exits functions
 *
 */
 
void switch_idle (void)
{
	do {} while (1); // -- endless loop ...................
}

/* -- C_Entry --------------------------------------------------------------
 *
 * Description	: entry point for switch
 * 
 * Parameters	: none...
 * Return	: Should Exit with the correct SWI...
 * Notes	: none...
 *
 */

int C_Entry ( void )
{
char string[255];

	// -- initialize all internal structures .......................

	switch_init ();

	// -- process ..................................................

	// -- end banner ...............................................
	
	sprintf (string,"\n    -- USER INT0 button READY... \n\n");
		switch_writes(string);
	sprintf (string,"\n    ********************************************* \n");
		switch_writes(string);
	sprintf (string,"    *** Remember to RESET the board after USE *** \n");
		switch_writes(string);
	sprintf (string,"    ********************************************* \n");
		switch_writes(string);

	switch_idle(); 

	Exit(); // Exiting from the Embedded System

	return 0;
}

/**************************************************************************
 * END OF switch.c
 **************************************************************************/

⌨️ 快捷键说明

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