ch32v20x_misc.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : ch32v20x_misc.h
  3. * Author : WCH
  4. * Version : V1.0.0
  5. * Date : 2021/06/06
  6. * Description : This file contains all the functions prototypes for the
  7. * miscellaneous firmware library functions.
  8. *********************************************************************************
  9. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  10. * Attention: This software (modified or not) and binary are used for
  11. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  12. *******************************************************************************/
  13. #ifndef __CH32V20x_MISC_H
  14. #define __CH32V20x_MISC_H
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "ch32v20x.h"
  19. /* CSR_INTSYSCR_INEST_definition */
  20. #define INTSYSCR_INEST_NoEN 0x00 /* interrupt nesting disable(CSR-0x804 bit1 = 0) */
  21. #define INTSYSCR_INEST_EN 0x01 /* interrupt nesting enable(CSR-0x804 bit1 = 1) */
  22. /* Check the configuration of CSR(0x804) in the startup file(.S)
  23. * interrupt nesting enable(CSR-0x804 bit1 = 1)
  24. * priority - bit[7] - Preemption Priority
  25. * bit[6:5] - Sub priority
  26. * bit[4:0] - Reserve
  27. * interrupt nesting disable(CSR-0x804 bit1 = 0)
  28. * priority - bit[7:5] - Sub priority
  29. * bit[4:0] - Reserve
  30. */
  31. #ifndef INTSYSCR_INEST
  32. #define INTSYSCR_INEST INTSYSCR_INEST_EN
  33. #endif
  34. /* NVIC Init Structure definition
  35. * interrupt nesting enable(CSR-0x804 bit1 = 1)
  36. * NVIC_IRQChannelPreemptionPriority - range from 0 to 1.
  37. * NVIC_IRQChannelSubPriority - range from 0 to 3.
  38. *
  39. * interrupt nesting disable(CSR-0x804 bit1 = 0)
  40. * NVIC_IRQChannelPreemptionPriority - range is 0.
  41. * NVIC_IRQChannelSubPriority - range from 0 to 7.
  42. *
  43. */
  44. typedef struct
  45. {
  46. uint8_t NVIC_IRQChannel;
  47. uint8_t NVIC_IRQChannelPreemptionPriority;
  48. uint8_t NVIC_IRQChannelSubPriority;
  49. FunctionalState NVIC_IRQChannelCmd;
  50. } NVIC_InitTypeDef;
  51. /* Preemption_Priority_Group */
  52. #if (INTSYSCR_INEST == INTSYSCR_INEST_NoEN)
  53. #define NVIC_PriorityGroup_0 ((uint32_t)0x00) /* interrupt nesting disable(CSR-0x804 bit1 = 0) */
  54. #else
  55. #define NVIC_PriorityGroup_1 ((uint32_t)0x01) /* interrupt nesting enable(CSR-0x804 bit1 = 1) */
  56. #endif
  57. void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup);
  58. void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct);
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif