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

📄 swi.c

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

/***************************************************************************
 *
 * Module		: swi.c
 * Description 	: Installs both a SWI handler and IRQ handler... 
 * Tool Chain	: ARM Developer Suite v1.0
 * Platform		: Evaluator7T
 * History		:
 *
 *		980301 ASloss
 *		- started working on the design and structure.
 *
 *		980428 ASloss
 *		- added interrupt handler
 *
 *		980625 ASloss
 *		- added Angel SWI
 *
 *		980730 ASloss
 *		- added SWI routines
 *
 *		990202 ASloss
 *		- added Multi-ICE support
 *
 *		2000-04-04 Andrew N. Sloss
 *		- ported to Evaluator7T
 *
 **************************************************************************/

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

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

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

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

#define		angel_SWI		0x123456
#define		example_SWI_78	0x78

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

__swi (angel_SWI) void _Exit(unsigned op, unsigned except);
#define Exit() _Exit(0x18,0x20026) 

__swi (example_SWI_78) void _SWI_78(unsigned op, unsigned except);
#define SWI_78() _SWI_78(0x78,0x20026)

__swi (angel_SWI) void _WriteC(unsigned op, const char *c);
#define WriteC(c) _WriteC (0x3,c)

/**************************************************************************
 * DATATYPES
 **************************************************************************/

// none...

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

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

/* -- swi_init ------------------------------------------------------------
 *
 * Description	:
 * 
 * Parameters	:
 *
 */

void swi_init (void)
{ 
	LED_1_ON;
	LED_2_ON;
	LED_3_ON;
	LED_4_ON;

	irq_init (); 
	segment_init();
}


/* -- swi_78_routine ------------------------------------------------------
 *
 * Description	: simple swi routine
 *
 * Parameters	: none...
 * Return	: none...
 * Other info	: none...
 *
 */

void swi_78_routine (void)
{
	LED_1_OFF;
	LED_2_OFF;
	LED_3_OFF;
	LED_4_OFF;	
	
	segment_set (0xa); // just to test the SWI
}

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

void swi_interrupt (void)
{
	counter ++;
	
	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;

}

/* -- swi_writes -----------------------------------------------------------
 *
 * Description	: write a string via the Angel SWI call WriteC
 *
 * Parameters	: none...
 * Return		: none...
 * Notes		: none...
 *
 */

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

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

/* -- swi_idle -----------------------------------------------------------
 *
 * Description	: idle loop
 *
 * Parameters	: none...
 * Return		: none...
 * Notes		: none...
 *
 */

void swi_idle (void) 
{
	do {} while (1); // -- endless loop Multi-ICE
}

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

int C_Entry ( void )
{
	// -- initialize all internal structures .......................

	swi_init 	();

	// -- process ..................................................
	
	SWI_78 		();	

	// -- end banner ...............................................
	
	
	swi_writes ("\n    -- 7 Segment Display should read 'A'...");
	swi_writes ("\n    -- USER INT0 button READY... \n\n");
	swi_writes ("\n    ********************************************* \n");
	swi_writes ("    *** Remember to RESET the board after USE *** \n");
	swi_writes ("    ********************************************* \n");

	// -- idle loop ................................................

	swi_idle 	();
	
	Exit(); // Exiting from the Embedded System

	return 0;
}

/**************************************************************************
 * End of swi.c
 **************************************************************************/

⌨️ 快捷键说明

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