/**
*     Copyright (c) 2025, Nsing Technologies Inc.
* 
*     All rights reserved.
*
*     This software is the exclusive property of Nsing Technologies Inc. (Hereinafter 
* referred to as Nsing). This software, and the product of Nsing described herein 
* (Hereinafter referred to as the Product) are owned by Nsing under the laws and treaties
* of the People's Republic of China and other applicable jurisdictions worldwide.
*
*     Nsing does not grant any license under its patents, copyrights, trademarks, or other 
* intellectual property rights. Names and brands of third party may be mentioned or referred 
* thereto (if any) for identification purposes only.
*
*     Nsing reserves the right to make changes, corrections, enhancements, modifications, and 
* improvements to this software at any time without notice. Please contact Nsing and obtain 
* the latest version of this software before placing orders.

*     Although Nsing has attempted to provide accurate and reliable information, Nsing assumes 
* no responsibility for the accuracy and reliability of this software.
* 
*     It is the responsibility of the user of this software to properly design, program, and test 
* the functionality and safety of any application made of this information and any resulting product. 
* In no event shall Nsing be liable for any direct, indirect, incidental, special,exemplary, or 
* consequential damages arising in any way out of the use of this software or the Product.
*
*     Nsing Products are neither intended nor warranted for usage in systems or equipment, any
* malfunction or failure of which may cause loss of human life, bodily injury or severe property 
* damage. Such applications are deemed, "Insecure Usage".
*
*     All Insecure Usage shall be made at user's risk. User shall indemnify Nsing and hold Nsing 
* harmless from and against all claims, costs, damages, and other liabilities, arising from or related 
* to any customer's Insecure Usage.

*     Any express or implied warranty with regard to this software or the Product, including,but not 
* limited to, the warranties of merchantability, fitness for a particular purpose and non-infringement
* are disclaimed to the fullest extent permitted by law.

*     Unless otherwise explicitly permitted by Nsing, anyone may not duplicate, modify, transcribe
* or otherwise distribute this software for any purposes, in whole or in part.
*
*     Nsing products and technologies shall not be used for or incorporated into any products or systems
* whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or regulations. 
* User shall comply with any applicable export control laws and regulations promulgated and administered by 
* the governments of any countries asserting jurisdiction over the parties or transactions.
**/

/***
*\*\file n32g033_exti.h
*\*\author Nsing
*\*\version v1.0.0
*\*\copyright Copyright (c) 2025, Nsing Technologies Inc. All rights reserved.
***/
#ifndef __N32G033_EXTI_H__
#define __N32G033_EXTI_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "n32g033.h"

/*** EXTI Structure Definition Start ***/

/** EXTI Init Structure definition **/
typedef struct
{
    uint32_t EXTI_Line;   /* < Specifies the EXTI lines to be enabled or disabled */

    uint8_t EXTI_Mode;    /* < Specifies the mode for the EXTI lines */

    uint8_t EXTI_Trigger; /* < Specifies the trigger signal active edge for the EXTI lines */
    
    FunctionalState EXTI_LineCmd;  /* Specifies the new state of the selected EXTI lines. */
} EXTI_InitType;

/** EXTI mode enumeration **/
typedef enum
{
    EXTI_Mode_Event      = 0x00U,
    EXTI_Mode_Interrupt  = 0x04U
} EXTI_ModeType;

/** EXTI Trigger enumeration **/
typedef enum
{   
    EXTI_Trigger_Falling        = 0x08U,
    EXTI_Trigger_Rising         = 0x0CU,    
    EXTI_Trigger_Rising_Falling  = 0x10U
} EXTI_TriggerType;

/*** EXTI Structure Definition End ***/

/*** EXTI Macro Definition Start ***/

#define EXTI_IMASK_MASK  ((uint32_t)0x000007FFU)
#define EXTI_EMASK_MASK  ((uint32_t)0x000007FFU)
#define EXTI_RT_CFG_MASK ((uint32_t)0x000007FFU)
#define EXTI_FT_CFG_MASK ((uint32_t)0x000007FFU)
#define EXTI_PEND_MASK   ((uint32_t)0x000007FFU)


/** EXTI_Lines **/
#define EXTI_LINENONE ((uint32_t)0x00000U) /** No interrupt selected **/
#define EXTI_LINE0    ((uint32_t)0x00001U)   /** External interrupt line 0 **/
#define EXTI_LINE1    ((uint32_t)0x00002U)   /** External interrupt line 1 **/
#define EXTI_LINE2    ((uint32_t)0x00004U)   /** External interrupt line 2 **/
#define EXTI_LINE3    ((uint32_t)0x00008U)   /** External interrupt line 3 **/
#define EXTI_LINE4    ((uint32_t)0x00010U)   /** External interrupt line 4 **/
#define EXTI_LINE5    ((uint32_t)0x00020U)   /** External interrupt line 5 **/
#define EXTI_LINE6    ((uint32_t)0x00040U)   /** External interrupt line 6 **/
#define EXTI_LINE7    ((uint32_t)0x00080U)   /** External interrupt line 7 **/
#define EXTI_LINE8    ((uint32_t)0x00100U)   /** External interrupt line 8 **/
#define EXTI_LINE9    ((uint32_t)0x00200U)   /** External interrupt line 9 **/
#define EXTI_LINE10   ((uint32_t)0x00400U)   /** External interrupt line 10 **/

/** EXTI_Mode definition**/
#define EXTI_MODE_INT   (0x00U)
#define EXTI_MODE_EVENT (0x04U)

/** EXTI Trigger enumeration **/
#define EXTI_TRIGGER_RISING         (0x08U)
#define EXTI_TRIGGER_FALLING        (0x0CU)
#define EXTI_TRIGGER_RISING_FALLING (0x10U)

/*** EXTI Macro Definition End ***/

/** EXTI Driving Functions Declaration **/

void EXTI_DeInit(void);
void EXTI_InitPeripheral(const EXTI_InitType* EXTI_InitStruct);
void EXTI_InitStruct(EXTI_InitType* EXTI_InitStruct);
void EXTI_TriggerSWInt(uint32_t EXTI_Line);
FlagStatus EXTI_GetStatusFlag(uint32_t EXTI_Line);
void EXTI_ClrStatusFlag(uint32_t EXTI_Line);
INTStatus EXTI_GetITStatus(uint32_t EXTI_Line);
void EXTI_ClrITPendBit(uint32_t EXTI_Line);

#ifdef __cplusplus
}
#endif

#endif /* __N32G033_EXTI_H__ */

