/*********************************************************************************************************************
* TC264 Opensourec Library TC264 Դ⣩һڹٷ SDK ӿڵĵԴ
* Copyright (c) 2022 SEEKFREE ɿƼ
*
* ļ TC264 Դһ
*
* TC264 Դ 
* Ըᷢ GPLGNU General Public License GNUͨù֤
*  GPL ĵ3棨 GPL3.0ѡģκκİ汾·/޸
*
* Դķϣܷãδκεı֤
* ûԻʺض;ı֤
* ϸμ GPL
*
* ӦյԴͬʱյһ GPL ĸ
* ûУ<https://www.gnu.org/licenses/>
*
* ע
* Դʹ GPL3.0 Դ֤Э Ϊİ汾
* Ӣİ libraries/doc ļµ GPL3_permission_statement.txt ļ
* ֤ libraries ļ ļµ LICENSE ļ
* ӭλʹò ޸ʱ뱣ɿƼİȨ
*
* ļ          zf_driver_exti
* ˾          ɶɿƼ޹˾
* 汾Ϣ          鿴 libraries/doc ļ version ļ 汾˵
*           ADS v1.9.4
* ƽ̨          TC264D
*           https://seekfree.taobao.com/
*
* ޸ļ¼
*                              ע
* 2022-09-15       pudding            first version
********************************************************************************************************************/

#ifndef _zf_driver_exti_h_
#define _zf_driver_exti_h_

#include "IfxScuEru.h"
#include "zf_common_typedef.h"

typedef enum  // öERUͨ
{
    // һֻͨѡһΪ ⲿжϵ
    ERU_CH0_REQ0_P15_4   = 0*3 + 1,                                                 // ͨ0ѡ
    ERU_CH1_REQ10_P14_3  = 1*3 + 1,                                                 // ͨ1ѡ
    // رעͨ2  ͨ3ͷռ
    // رעͨ2  ͨ3ͷռ
    // رעͨ2  ͨ3ͷռ
    ERU_CH2_REQ7_P00_4   = 2*3,  ERU_CH2_REQ14_P02_1, ERU_CH2_REQ2_P10_2,           // ͨ2ѡ
    ERU_CH3_REQ6_P02_0   = 3*3,  ERU_CH3_REQ3_P10_3,  ERU_CH3_REQ15_P14_1,          // ͨ3ѡ

    // ͨ4ͨ0 жϺ жͨжϱ־λʶĸͨж
    ERU_CH4_REQ13_P15_5  = 4*3,  ERU_CH4_REQ8_P33_7,                                // ͨ4ѡ
    // ͨ5ͨ1 жϺ
    ERU_CH5_REQ1_P15_8   = 5*3,                                                     // ͨ5ѡ
    // ͨ6ͨ2 жϺ
    ERU_CH6_REQ12_P11_10 = 6*3,  ERU_CH6_REQ9_P20_0,                                // ͨ6ѡ
    // ͨ7ͨ3 жϺ
    ERU_CH7_REQ16_P15_1  = 7*3,  ERU_CH7_REQ11_P20_9,                               // ͨ7ѡ
}exti_pin_enum;



typedef enum  // öٴʽ
{
    EXTI_TRIGGER_RISING,                                                            // شģʽ
    EXTI_TRIGGER_FALLING,                                                           // ½شģʽ
    EXTI_TRIGGER_BOTH,                                                              // ˫شģʽ
}exti_trigger_enum;



// жϱ־λȡ
#define exti_flag_get(eru_pin)      IfxScuEru_getEventFlagStatus((IfxScuEru_InputChannel)(eru_pin/3))
// жϱ־λ
#define exti_flag_clear(eru_pin)    IfxScuEru_clearEventFlag((IfxScuEru_InputChannel)(eru_pin/3))

//====================================================EXIT ====================================================
void exti_all_close         (void);                                                 // EXTI ʧ
void exti_enable            (exti_pin_enum eru_pin);                                // EXTI жʹ
void exti_disable           (exti_pin_enum eru_pin);                                // EXTI жʧ
void exti_init              (exti_pin_enum eru_pin, exti_trigger_enum trigger);     // EXTI жϳʼ
//====================================================EXIT ====================================================


#endif
