hal_nvic.h 3.0 KB

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