|
本帖最后由 FSL_TICS_ZP 于 2014-4-1 09:30 编辑
准备使用MMA8451Q的Motion中断INT1(跟KL25Z PTA14引脚相连)来通知CPU状态,但是在配置PTA14引脚的中断时,中断函数一直进不去。
贴代码:
/**
* @brief: init MMA8451 INT1 interrupt pin
* @note: PTA14
* PULL UP
* Interrupt on falling edge
*
*/
void init_PTA14_interrupt(void)
{
// PTA14 -- MMA8451 INT1
// ALT1
/* PORTA_PCR14: ISF=0, MUX=1, IQRC=0x0A(1010), PE=1, PS=1 */
PORTA_PCR14 = (uint32_t)((PORTA_PCR14 & (uint32_t)~(uint32_t)(PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x06) | PORT_PCR_IRQC_MASK)) |
(uint32_t)(PORT_PCR_MUX(0x01)) |
(uint32_t)PORT_PCR_IRQC(0x0A) |
PORT_PCR_PS_MASK |
PORT_PCR_PE_MASK
);
APP_TRACE("PORTA_PCR14 = 0x%.8X\r\n", PORTA_PCR14);
//PORTA_PCR14 = 0x010A0103;
_int_install_isr(LDD_ivIndex_INT_PORTA, MMA8451_INT1_isr_service, NULL);
// ENABLE PTA14 Falling interrupt
enable_irq(30);
set_irq_priority(30, 2);
}
static void MMA8451_INT1_isr_service(void* p_arg)
{
byte Data;
LDD_TError ret;
TRACE("MMA8451_INT1_isr_service\r\n");
// PTA14
if (PORTA_ISFR & ((uint32_t)(1<<14)))
{
// writte 1 to the flag to clear the interrupt flag
PORTA_ISFR = (uint32_t)(1<<14);
// Determine source of interrupt by reading the system interrupt
ret = ReadAccRegs(g_I2C_DeviceData,
&g_DataState,
INT_SOURCE_REG,
ACC_REG_SIZE,
&Data);
if (ret)
{
// Set up Case statement here to service all of the possible interrupts
if ((Data &0x04)==0x04)
{
//Perform an Action since Motion Flag has been set
//Read the Motion/Freefall Function to clear the interrupt
ret = ReadAccRegs(g_I2C_DeviceData,
&g_DataState,
FF_MT_SRC_REG,
ACC_REG_SIZE,
&Data);
// post a message to the app task
_lwsem_post(&g_mma8451_int_sem);
}
}
}
}
|
|