1 /***************COPYRIGHT(C) 2019 WCH. A11 rights reserved********************* 2 * File Name : ch32f10x_misc.h 3 * Author : WCH 4 * Version : V1.0.0 5 * Date : 2019/10/15 6 * Description : CThis file contains all the functions prototypes for the 7 * miscellaneous firmware library functions (add-on to CMSIS functions). 8 *******************************************************************************/ 9 #ifndef __CH32F10X_MISC_H 10 #define __CH32F10X_MISC_H 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 #include "ch32f10x.h" 17 18 /* NVIC Init Structure definition */ 19 typedef struct 20 { 21 uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. 22 This parameter can be a value of @ref IRQn_Type 23 (For the complete ch32 Devices IRQ Channels list, please 24 refer to ch32f10x.h file) */ 25 26 uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel 27 specified in NVIC_IRQChannel. This parameter can be a value 28 between 0 and 15 as described in the table @ref NVIC_Priority_Table */ 29 30 uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified 31 in NVIC_IRQChannel. This parameter can be a value 32 between 0 and 15 as described in the table @ref NVIC_Priority_Table */ 33 34 FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel 35 will be enabled or disabled. 36 This parameter can be set either to ENABLE or DISABLE */ 37 } NVIC_InitTypeDef; 38 39 40 /* 41 * NVIC_Priority_Table: 42 * The table below gives the allowed values of the pre-emption priority and subpriority according 43 * to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function 44 * ============================================================================================================================ 45 * NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description 46 * ============================================================================================================================ 47 * NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority 48 * | | | 4 bits for subpriority 49 * ---------------------------------------------------------------------------------------------------------------------------- 50 * NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority 51 * | | | 3 bits for subpriority 52 * ---------------------------------------------------------------------------------------------------------------------------- 53 * NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority 54 * | | | 2 bits for subpriority 55 * ---------------------------------------------------------------------------------------------------------------------------- 56 * NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority 57 * | | | 1 bits for subpriority 58 * ---------------------------------------------------------------------------------------------------------------------------- 59 * NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority 60 * | | | 0 bits for subpriority 61 * ============================================================================================================================ 62 * 63 */ 64 65 66 /* Vector_Table_Base */ 67 #define NVIC_VectTab_RAM ((uint32_t)0x20000000) 68 #define NVIC_VectTab_FLASH ((uint32_t)0x08000000) 69 70 /* System_Low_Power */ 71 #define NVIC_LP_SEVONPEND ((uint8_t)0x10) 72 #define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) 73 #define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) 74 75 76 /* Preemption_Priority_Group */ 77 #define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority 78 4 bits for subpriority */ 79 #define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority 80 3 bits for subpriority */ 81 #define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority 82 2 bits for subpriority */ 83 #define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority 84 1 bits for subpriority */ 85 #define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority 86 0 bits for subpriority */ 87 88 /* SysTick_clock_source */ 89 #define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) 90 #define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) 91 92 /* MISC_Exported_Functions */ 93 void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); 94 void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); 95 void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); 96 void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); 97 void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); 98 99 #ifdef __cplusplus 100 } 101 #endif 102 103 #endif /* __CH32F10x_MISC_H */ 104 105