2 **************************************************************************
3 * @file at32f435_437_exint.c
6 * @brief contains all the functions for the exint firmware library
7 **************************************************************************
8 * Copyright notice & Disclaimer
10 * The software Board Support Package (BSP) that is made available to
11 * download from Artery official website is the copyrighted work of Artery.
12 * Artery authorizes customers to use, copy, and distribute the BSP
13 * software and its related documentation for the purpose of design and
14 * development in conjunction with Artery microcontrollers. Use of the
15 * software is governed by this copyright notice and the following disclaimer.
17 * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
18 * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
19 * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
20 * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
21 * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
24 **************************************************************************
27 #include "at32f435_437_conf.h"
29 /** @addtogroup AT32F435_437_periph_driver
34 * @brief EXINT driver modules
38 #ifdef EXINT_MODULE_ENABLED
40 /** @defgroup EXINT_private_functions
49 void exint_reset(void)
51 EXINT
->inten
= 0x00000000;
52 EXINT
->polcfg1
= 0x00000000;
53 EXINT
->polcfg2
= 0x00000000;
54 EXINT
->evten
= 0x00000000;
55 EXINT
->intsts
= 0x007FFFFF;
59 * @brief exint default para init
61 * - to the structure of exint_init_type
64 void exint_default_para_init(exint_init_type
*exint_struct
)
66 exint_struct
->line_enable
= FALSE
;
67 exint_struct
->line_select
= EXINT_LINE_NONE
;
68 exint_struct
->line_polarity
= EXINT_TRIGGER_FALLING_EDGE
;
69 exint_struct
->line_mode
= EXINT_LINE_EVENT
;
75 * - to the structure of exint_init_type
78 void exint_init(exint_init_type
*exint_struct
)
80 uint32_t line_index
= 0;
81 line_index
= exint_struct
->line_select
;
83 EXINT
->inten
&= ~line_index
;
84 EXINT
->evten
&= ~line_index
;
86 if(exint_struct
->line_enable
!= FALSE
)
88 if(exint_struct
->line_mode
== EXINT_LINE_INTERRUPUT
)
90 EXINT
->inten
|= line_index
;
94 EXINT
->evten
|= line_index
;
97 EXINT
->polcfg1
&= ~line_index
;
98 EXINT
->polcfg2
&= ~line_index
;
99 if(exint_struct
->line_polarity
== EXINT_TRIGGER_RISING_EDGE
)
101 EXINT
->polcfg1
|= line_index
;
103 else if(exint_struct
->line_polarity
== EXINT_TRIGGER_FALLING_EDGE
)
105 EXINT
->polcfg2
|= line_index
;
109 EXINT
->polcfg1
|= line_index
;
110 EXINT
->polcfg2
|= line_index
;
116 * @brief clear exint flag
118 * this parameter can be any combination of the following values:
126 void exint_flag_clear(uint32_t exint_line
)
128 EXINT
->intsts
= exint_line
;
132 * @brief get exint flag
134 * this parameter can be one of the following values:
140 * @retval the new state of exint flag(SET or RESET).
142 flag_status
exint_flag_get(uint32_t exint_line
)
144 flag_status status
= RESET
;
145 uint32_t exint_flag
=0;
146 exint_flag
= EXINT
->intsts
& exint_line
;
147 if((exint_flag
!= (uint16_t)RESET
))
159 * @brief generate exint software interrupt event
161 * this parameter can be one of the following values:
169 void exint_software_interrupt_event_generate(uint32_t exint_line
)
171 EXINT
->swtrg
|= exint_line
;
175 * @brief enable or disable exint interrupt
177 * this parameter can be any combination of the following values:
183 * @param new_state: new state of exint interrupt.
184 * this parameter can be: TRUE or FALSE.
187 void exint_interrupt_enable(uint32_t exint_line
, confirm_state new_state
)
189 if(new_state
== TRUE
)
191 EXINT
->inten
|= exint_line
;
195 EXINT
->inten
&= ~exint_line
;
200 * @brief enable or disable exint event
202 * this parameter can be any combination of the following values:
208 * @param new_state: new state of exint event.
209 * this parameter can be: TRUE or FALSE.
212 void exint_event_enable(uint32_t exint_line
, confirm_state new_state
)
214 if(new_state
== TRUE
)
216 EXINT
->evten
|= exint_line
;
220 EXINT
->evten
&= ~exint_line
;