1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* 3 * Copyright (c) 2020-2021 Rockchip Electronics Co., Ltd. 4 */ 5 6 #include "hal_conf.h" 7 8 #ifdef HAL_NVIC_MODULE_ENABLED 9 10 /** @addtogroup RK_HAL_Driver 11 * @{ 12 */ 13 14 /** @addtogroup NVIC 15 * @{ 16 */ 17 18 #ifndef _HAL_NVIC_H_ 19 #define _HAL_NVIC_H_ 20 21 #include "hal_def.h" 22 23 /***************************** MACRO Definition ******************************/ 24 /** @defgroup NVIC_Exported_Definition_Group1 Basic Definition 25 * @{ 26 */ 27 28 typedef enum { 29 NVIC_PRIORITYGROUP_0 = (0x7U), /*!< 0 bits pre-emption, 8 bits subpriority*/ 30 NVIC_PRIORITYGROUP_1 = (0x6U), /*!< 1 bits pre-emption, 7 bits subpriority*/ 31 NVIC_PRIORITYGROUP_2 = (0x5U), /*!< 2 bits pre-emption, 6 bits subpriority*/ 32 NVIC_PRIORITYGROUP_3 = (0x4U), /*!< 3 bits pre-emption, 5 bits subpriority*/ 33 NVIC_PRIORITYGROUP_4 = (0x3U), /*!< 4 bits pre-emption, 4 bits subpriority*/ 34 NVIC_PRIORITYGROUP_5 = (0x2U), /*!< 5 bits pre-emption, 3 bits subpriority*/ 35 } eNVIC_PriorityGroup; 36 37 #ifndef NVIC_PRIORITYGROUP_DEFAULT 38 #define NVIC_PRIORITYGROUP_DEFAULT NVIC_PRIORITYGROUP_5 /**< Can be redefined in soc.h */ 39 #endif 40 41 /* preempt priority */ 42 #define NVIC_PERIPH_PRIO_LOWEST (0xFFU) 43 #ifndef NVIC_PERIPH_PRIO_DEFAULT 44 #if (__NVIC_PRIO_BITS == 2U) 45 #define NVIC_PERIPH_PRIO_DEFAULT (0x2U) /**< Can be redefined in soc.h */ 46 #elif (__NVIC_PRIO_BITS == 3U) 47 #define NVIC_PERIPH_PRIO_DEFAULT (0x4U) /**< Can be redefined in soc.h */ 48 #else 49 #define NVIC_PERIPH_PRIO_DEFAULT (0xFFU) /**< Can be redefined in soc.h */ 50 #endif 51 #endif 52 #define NVIC_PERIPH_PRIO_HIGHEST (0x0U) 53 54 /* sub priority */ 55 #define NVIC_PERIPH_SUB_PRIO_LOWEST (0xFFU) 56 #define NVIC_PERIPH_SUB_PRIO_DEFAULT (0xFFU) 57 #define NVIC_PERIPH_SUB_PRIO_HIGHEST (0x0U) 58 59 #define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x100U) 60 #define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x100U) 61 62 /** @brief Type define of NVIC interrupt handler */ 63 typedef void (*NVIC_IRQHandler)(void); 64 65 /***************************** Structure Definition **************************/ 66 67 /** @} */ 68 69 /***************************** Function Declare ******************************/ 70 /** @defgroup NVIC_Public_Function_Declare Public Function Declare 71 * @{ 72 */ 73 74 HAL_Status HAL_NVIC_SetIRQHandler(IRQn_Type IRQn, NVIC_IRQHandler handler); 75 NVIC_IRQHandler HAL_NVIC_GetIRQHandler(IRQn_Type IRQn); 76 HAL_Status HAL_NVIC_SetPriorityGrouping(eNVIC_PriorityGroup priorityGroup); 77 uint32_t HAL_NVIC_GetPriorityGrouping(void); 78 HAL_Status HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t preemptPriority, uint32_t subPriority); 79 uint32_t HAL_NVIC_GetPriority(IRQn_Type IRQn); 80 HAL_Status HAL_NVIC_EnableIRQ(IRQn_Type IRQn); 81 HAL_Status HAL_NVIC_DisableIRQ(IRQn_Type IRQn); 82 HAL_Status HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn); 83 HAL_Check HAL_NVIC_IsPendingIRQ(IRQn_Type IRQn); 84 HAL_Status HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn); 85 HAL_Status HAL_NVIC_ConfigExtIRQ(IRQn_Type IRQn, NVIC_IRQHandler handler, 86 uint32_t preemptPriority, uint32_t subPriority); 87 HAL_Status HAL_NVIC_Init(void); 88 89 /** @} */ 90 91 #endif 92 93 /** @} */ 94 95 /** @} */ 96 97 #endif /* HAL_NVIC_MODULE_ENABLED */ 98