MTK之外部中断篇

简介: MTK之外部中断篇

例子:添加一个按键,按下时响应中断函数,这里的功能为按下后系统进入睡眠。

1)在interface\hwdrv\Eint.h的eint_channel_type中添加

sleep_eint_chann

2)在custom\drv\misc_drv\CUSTOMER_BB\Eint_def.c中添加

extern const kal_uint8 SLEEP_EINT_NO;

kal_uint8    eint_sleep_handler = 0xFF;

注:一般都会有__CUST_NEW__这个宏定义,所以应在该宏条件下添加,最好先确认编译条件中是否有这个宏。

在函数custom_eint_get_channel的switch语句中添加

      case sleep_eint_chann:

             return ((kal_uint8)SLEEP_EINT_NO);

3)在custom\drv\misc_drv\CUSTOMER_BB\Eint_var.c中设定中断号,这里设置为EINT2

const unsigned char SLEEP_EINT_NO = 2;

4)在custom\drv\misc_drv\CUSTOMER_BB\auxmain.c的aux_task_main函数中注册中断

eint_sleep_handler = L1SM_GetHandle(); //获取睡眠控制句柄
      L1SM_SleepDisable(eint_sleep_handler); //Disable睡眠
      //注册睡眠模式处理外部中断
      EINT_Registration(SLEEP_EINT_NO,
                                    KAL_TRUE,
                                    sleep_state,
                                    SLEEP_EINT_HISR,
                                    KAL_FALSE);

在该文件中实现中断函数:

kal_bool                 sleep_state = LEVEL_LOW;
extern const kal_uint8  SLEEP_EINT_NO;//外部中断号
void SLEEP_EINT_HISR(void);//中断函数
void SLEEP_EINT_HISR(void)
{
              if(sleep_state == LEVEL_HIGH)
              {
          L1SM_SleepDisable(eint_sleep_handler);
              }
              else
              {
                     L1SM_SleepEnable(eint_sleep_handler); //睡眠使能
              }
              sleep_state = !sleep_state;
              EINT_Set_Polarity(SLEEP_EINT_NO, sleep_state);//设置中断方式
              EINT_UnMask(SLEEP_EINT_NO);
}
相关文章
|
5天前
|
芯片
MTK平台驱动调试指南 GPIO设置篇
MTK平台驱动调试指南 GPIO设置篇
11 1
|
5天前
|
传感器 存储
STM32--EXTI外部中断
STM32--EXTI外部中断
|
5天前
|
传感器 存储 缓存
STM32--MPU6050与I2C外设
STM32--MPU6050与I2C外设
|
5天前
|
C# 内存技术
|
8月前
|
缓存 C++
基于ARM-contexA9-蜂鸣器pwm驱动开发
基于ARM-contexA9-蜂鸣器pwm驱动开发
59 0
|
10月前
|
芯片
STM32F103C8 EXTI外部中断
STM32F103C8 EXTI外部中断
63 0
|
存储 开发工具 芯片
ZYNQ-UART串口中断测试
ZYNQ-UART串口中断测试
523 0
ZYNQ-UART串口中断测试
|
11月前
野火F1开发板STM32-USART使用
野火F1开发板STM32-USART使用
96 0
|
11月前
|
内存技术
STM32CubeMX外部中断
STM32CubeMX外部中断
101 0