1 /*! 2 * @file apm32s10x_misc.h 3 * 4 * @brief This file provides all the miscellaneous firmware functions. 5 * Include NVIC,SystemTick and Power management. 6 * 7 * @version V1.0.1 8 * 9 * @date 2022-12-31 10 * 11 * @attention 12 * 13 * Copyright (C) 2022-2023 Geehy Semiconductor 14 * 15 * You may not use this file except in compliance with the 16 * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE). 17 * 18 * The program is only for reference, which is distributed in the hope 19 * that it will be usefull and instructional for customers to develop 20 * their software. Unless required by applicable law or agreed to in 21 * writing, the program is distributed on an "AS IS" BASIS, WITHOUT 22 * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied. 23 * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions 24 * and limitations under the License. 25 */ 26 27 /* Define to prevent recursive inclusion */ 28 #ifndef __APM32S10X_MISC_H 29 #define __APM32S10X_MISC_H 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 /* Includes */ 36 #include "apm32s10x.h" 37 38 /** @addtogroup APM32S10x_StdPeriphDriver 39 @{ 40 */ 41 42 /** @addtogroup MISC_Driver MISC Driver 43 @{ 44 */ 45 46 /** @defgroup MISC_Enumerations Enumerations 47 @{ 48 */ 49 50 /** 51 * @brief NVIC Vect table 52 */ 53 typedef enum 54 { 55 NVIC_VECT_TAB_RAM = 0x20000000, 56 NVIC_VECT_TAB_FLASH = 0x08000000, 57 } NVIC_VECT_TAB_T; 58 59 /** 60 * @brief system low power mode 61 */ 62 typedef enum 63 { 64 NVIC_LOWPOWER_SEVONPEND = 0x10, 65 NVIC_LOWPOWER_SLEEPDEEP = 0x04, 66 NVIC_LOWPOWER_SLEEPONEXIT = 0x02 67 } NVIC_LOWPOWER_T; 68 69 /** 70 * @brief nvic priority group 71 */ 72 typedef enum 73 { 74 NVIC_PRIORITY_GROUP_0 = 0x700, /*!< 0 bits for pre-emption priority,4 bits for subpriority */ 75 NVIC_PRIORITY_GROUP_1 = 0x600, /*!< 1 bits for pre-emption priority,3 bits for subpriority */ 76 NVIC_PRIORITY_GROUP_2 = 0x500, /*!< 2 bits for pre-emption priority,2 bits for subpriority */ 77 NVIC_PRIORITY_GROUP_3 = 0x400, /*!< 3 bits for pre-emption priority,1 bits for subpriority */ 78 NVIC_PRIORITY_GROUP_4 = 0x300 /*!< 4 bits for pre-emption priority,0 bits for subpriority */ 79 } NVIC_PRIORITY_GROUP_T; 80 81 /** 82 * @brief SysTick Clock source 83 */ 84 typedef enum 85 { 86 SYSTICK_CLK_SOURCE_HCLK_DIV8 = 0x00, 87 SYSTICK_CLK_SOURCE_HCLK = 0x01 88 } SYSTICK_CLK_SOURCE_T; 89 90 /**@} end of group MISC_Enumerations */ 91 92 /** @defgroup MISC_Functions Functions 93 @{ 94 */ 95 96 /* NVIC */ 97 void NVIC_ConfigPriorityGroup(NVIC_PRIORITY_GROUP_T priorityGroup); 98 void NVIC_EnableIRQRequest(IRQn_Type irq, uint8_t preemptionPriority, uint8_t subPriority); 99 void NVIC_DisableIRQRequest(IRQn_Type irq); 100 101 /* Vector Table */ 102 void NVIC_ConfigVectorTable(NVIC_VECT_TAB_T vectTab, uint32_t offset); 103 104 /* Power */ 105 void NVIC_SetSystemLowPower(NVIC_LOWPOWER_T lowPowerMode); 106 void NVIC_ResetystemLowPower(NVIC_LOWPOWER_T lowPowerMode); 107 108 /* Systick */ 109 void SysTick_ConfigCLKSource(SYSTICK_CLK_SOURCE_T clkSource); 110 111 /**@} end of group MISC_Functions */ 112 /**@} end of group MISC_Driver */ 113 /**@} end of group APM32S10x_StdPeriphDriver */ 114 115 #ifdef __cplusplus 116 } 117 #endif 118 119 #endif /* __APM32S10X_MISC_H */ 120