📄 pwrman.c
字号:
/*****************************************************************************
* pwrman.c: Power Management module file for NXP LPC23xx/24xx Family Microprocessors
*
* Copyright(C) 2006, NXP Semiconductor
* All rights reserved.
*
* History
* 2006.07.20 ver 1.00 Prelimnary version, first Release
*
******************************************************************************/
#include "LPC230x.h" /* LPC23xx/24xx definitions */
#include "type.h"
#include "irq.h"
#include "target.h"
#include "pwrman.h"
#include <intrinsics.h>
volatile DWORD eint0_counter;
/*****************************************************************************
** Function name: EINT0_Handler
**
** Descriptions: external INT handler
**
** parameters: None
** Returned value: None
**
*****************************************************************************/
__irq __nested __arm void EINT0_Handler (void)
{
EXTINT = EINT0; /* clear interrupt */
__enable_interrupt(); /* handles nested interrupt */
eint0_counter++;
VICVectAddr = 0; /* Acknowledge Interrupt */
}
/*****************************************************************************
** Function name: EINTInit
**
** Descriptions: Initialize external interrupt pin and
** install interrupt handler
**
** parameters: None
** Returned value: true or false, return false if the interrupt
** handler can't be installed to the VIC table.
**
*****************************************************************************/
DWORD EINTInit( void )
{
PINSEL4 = 0x00100000; /* set P2.10 as EINT0 and
P2.0~7 GPIO output */
FIO2DIR = 0x000000FF; /* port 2, bit 0~7 only */
FIO2CLR = 0x000000FF; /* turn off LEDs */
IO2_INT_EN_F = 0x200; /* Port2.10 is falling edge. */
EXTMODE = EINT0_EDGE; /* INT0 edge trigger */
EXTPOLAR = 0; /* INT0 is falling edge by default */
if ( install_irq( EINT0_INT, (void *)EINT0_Handler, HIGHEST_PRIORITY ) == FALSE )
{
return (FALSE);
}
return( TRUE );
}
/******************************************************************************
** Function name: PM_Init
**
** Descriptions: Set up wakeup source before powering down
** Use EXTINT0 as wakeup source
**
** parameters:
** Returned value: true or fase, if VIC table is full, return false
**
******************************************************************************/
DWORD PM_Init( void )
{
if ( EINTInit() != TRUE ) /* Enable external interrupt 0 */
{
return ( FALSE );
}
INTWAKE |= 0x01; /* Set EXTINT0 as wakeup source */
return ( TRUE );
}
/******************************************************************************
** End Of File
******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -