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

📄 button.c

📁 AT91所有开发板的资料 AT91所有开发板的资料
💻 C
字号:

/**************************************************************************
 *
 * ARM - Strategic Support Group
 *
 **************************************************************************/

/***************************************************************************
 *
 * Title		: Button
 * Module		: button.c
 * Description 	: Services the button being pressed and toggles LED(1)
 * Tool Chain	: ARM Developer Suite v1.0
 * Platform		: Evaluator7T
 * History	:
 *
 *		990929 ASloss
 *		- started working on button.c 	
 *
 *		2000-04-04 Andrew N. Sloss
 *		- ported to the Evaluator7T
 *
 **************************************************************************/

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

#include "led.h"
#include "macros.h"

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

// none...

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

static int toggle = 0;

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


/* -- button_init ---------------------------------------------------------
 *                                                            
 * Description  :  Initialises the button interrupt    
 *
 * Parameters   : none...   
 * Return       : none...
 * Notes        : none...
 *                                                                             
 */

void button_init (void)
{	
	// Bitwise OR incase an existing set of Interrupts have been .....
	// set by Angel Debug Monitor ....................................
		
/*
 * Update the register on the target which masks the irq passed to the IC.
 * This routine is target-specific.  Turn the interrupt source on.
 */
  *(volatile int*)INTMSK &= ~((1 << INT_GLOBAL) | (1<<10) | (1<<0));

  *(unsigned *)IOPCON 	|= IO_ENABLE_INT0; 			// enable int0
  *(unsigned *)IOPCON	|= IO_ACTIVE_HIGH_INT0; 	// set as active high
  *(unsigned *)IOPCON	|= IO_RISING_EDGE_INT0;		// allow for RISING EDGE
}

/* -- button_pressed ----------------------------------------------------
 *
 * Description	: The interrupt button has been pressed. Toggles D1 LED...
 *
 * Parameters	: none...
 * Return		: none...
 * Notes		: none...
 *
 */

void button_pressed (void)
{
	if( toggle == 0 ) {
	toggle = 1;
	LED_1_ON;
	} else {
	toggle = 0;
	LED_1_OFF;
	}

	
	// add user function code here...
}

/* -- button_irq  ----------------------------------------------------------
 *
 * Description  : handles the button press interrupt...
 *
 * Parameters   : none...
 * Return       : none...
 * Notes        : none...
 *
 */ 

void  button_irq (void) 
{
   /* Read in the Interrupt source .................................. */
	
	*(unsigned *) INTPND |= INT_SW3_MASK;

	button_pressed ();		// Call toggle LED's.......	
}

/**************************************************************************
 * END OF button.c
 **************************************************************************/

⌨️ 快捷键说明

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