1 /*****************************************************************************
\r
2 * © 2015 Microchip Technology Inc. and its subsidiaries.
\r
3 * You may use this software and any derivatives exclusively with
\r
4 * Microchip products.
\r
5 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS".
\r
6 * NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
\r
7 * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
\r
8 * AND FITNESS FOR A PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP
\r
9 * PRODUCTS, COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
\r
10 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
\r
11 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
\r
12 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
\r
13 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.
\r
14 * TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
\r
15 * CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF
\r
16 * FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
\r
17 * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE
\r
19 ******************************************************************************
\r
21 Version Control Information (Perforce)
\r
22 ******************************************************************************
\r
24 $DateTime: 2016/09/22 08:03:49 $
\r
26 Last Change: Initial Draft
\r
27 ******************************************************************************/
\r
28 /** @file interrupt_nvic_perphl.c
\r
29 * \brief Interrupt NVIC Peripheral Source File
\r
32 * This file implements the NVIC peripheral functions
\r
33 ******************************************************************************/
\r
35 /** @defgroup Interrupt
\r
39 #include "common_lib.h"
\r
40 #include "interrupt.h"
\r
42 /* ------------------------------------------------------------------------------- */
\r
43 /* NVIC Functions */
\r
44 /* ------------------------------------------------------------------------------- */
\r
46 /** Enable/Disable the NVIC IRQ in the NVIC interrupt controller
\r
47 * @param nvic_num : NVIC number (see enum IRQn_Type)
\r
48 * @param en_flag : 1 = Enable the NVIC IRQ, 0 = Disable the NVIC IRQ
\r
50 void p_interrupt_nvic_enable(IRQn_Type nvic_num, uint8_t en_flag)
\r
53 NVIC_EnableIRQ(nvic_num);
\r
55 NVIC_DisableIRQ(nvic_num);
\r
60 /** ecia_nvic_clr_en - Clear all NVIC external enables */
\r
61 void p_interrupt_nvic_extEnables_clr(void)
\r
65 m = (uint32_t)(MAX_IRQn) >> 5;
\r
66 if ( (uint32_t)(MAX_IRQn) & 0x1Ful ) { m++; }
\r
68 for ( i = 0ul; i < m ; i++ )
\r
70 NVIC->ICER[i] = 0xfffffffful;
\r
74 /** Clear all NVIC external enables and pending bits */
\r
75 void p_interrupt_nvic_enpend_clr(void)
\r
79 // Clear NVIC enables & pending status
\r
80 m = (uint32_t)(MAX_IRQn) >> 5;
\r
81 if ( (uint32_t)(MAX_IRQn) & 0x1Ful ) { m++; }
\r
83 for ( i = 0ul; i < m ; i++ )
\r
85 NVIC->ICER[i] = 0xfffffffful;
\r
86 NVIC->ICPR[i] = 0xfffffffful;
\r
90 /** Set NVIC external priorities to POR value */
\r
91 void p_interrupt_nvic_priorities_default_set(void)
\r
94 // Set POR default NVIC priority (highest)
\r
95 for ( i = 0ul; i < (uint32_t)MAX_IRQn; i++ ) {
\r
100 /** Set NVIC external priorities to specified priority (0 - 7)
\r
101 * @param zero-based 3-bit priority value: 0=highest, 7=lowest.
\r
102 * @note NVIC highest priority is the value 0, lowest is all 1's.
\r
103 * Each external interrupt has an 8-bit register and the priority
\r
104 * is left justified in the registers. MECxxx implements 8 priority
\r
105 * levels or bits [7:5] in the register. Lowest priority = 0xE0
\r
107 void p_interrupt_nvic_priorities_set(uint8_t new_pri)
\r
111 for ( i = 0ul; i < MAX_IRQn; i++ ) {
\r
112 NVIC_SetPriority((IRQn_Type)i, new_pri);
\r
117 /* end interrupt_nvic_perphl.c */
\r