|
| 1 | +/** |
| 2 | + ****************************************************************************** |
| 3 | + * @file misc.h |
| 4 | + * @author MCD Application Team |
| 5 | + * @version V3.6.1 |
| 6 | + * @date 05-March-2012 |
| 7 | + * @brief This file contains all the functions prototypes for the miscellaneous |
| 8 | + * firmware library functions (add-on to CMSIS functions). |
| 9 | + ****************************************************************************** |
| 10 | + * @attention |
| 11 | + * |
| 12 | + * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2> |
| 13 | + * |
| 14 | + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
| 15 | + * You may not use this file except in compliance with the License. |
| 16 | + * You may obtain a copy of the License at: |
| 17 | + * |
| 18 | + * http://www.st.com/software_license_agreement_liberty_v2 |
| 19 | + * |
| 20 | + * Unless required by applicable law or agreed to in writing, software |
| 21 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 22 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 23 | + * See the License for the specific language governing permissions and |
| 24 | + * limitations under the License. |
| 25 | + * |
| 26 | + ****************************************************************************** |
| 27 | + */ |
| 28 | + |
| 29 | +/* Define to prevent recursive inclusion -------------------------------------*/ |
| 30 | +#ifndef __MISC_H |
| 31 | +#define __MISC_H |
| 32 | + |
| 33 | +#ifdef __cplusplus |
| 34 | + extern "C" { |
| 35 | +#endif |
| 36 | + |
| 37 | +/* Includes ------------------------------------------------------------------*/ |
| 38 | +#include "stm32f10x.h" |
| 39 | + |
| 40 | +/** @addtogroup STM32F10x_StdPeriph_Driver |
| 41 | + * @{ |
| 42 | + */ |
| 43 | + |
| 44 | +/** @addtogroup MISC |
| 45 | + * @{ |
| 46 | + */ |
| 47 | + |
| 48 | +/** @defgroup MISC_Exported_Types |
| 49 | + * @{ |
| 50 | + */ |
| 51 | + |
| 52 | +/** |
| 53 | + * @brief NVIC Init Structure definition |
| 54 | + */ |
| 55 | + |
| 56 | +typedef struct |
| 57 | +{ |
| 58 | + uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. |
| 59 | + This parameter can be a value of @ref IRQn_Type |
| 60 | + (For the complete STM32 Devices IRQ Channels list, please |
| 61 | + refer to stm32f10x.h file) */ |
| 62 | + |
| 63 | + uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel |
| 64 | + specified in NVIC_IRQChannel. This parameter can be a value |
| 65 | + between 0 and 15 as described in the table @ref NVIC_Priority_Table */ |
| 66 | + |
| 67 | + uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified |
| 68 | + in NVIC_IRQChannel. This parameter can be a value |
| 69 | + between 0 and 15 as described in the table @ref NVIC_Priority_Table */ |
| 70 | + |
| 71 | + FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel |
| 72 | + will be enabled or disabled. |
| 73 | + This parameter can be set either to ENABLE or DISABLE */ |
| 74 | +} NVIC_InitTypeDef; |
| 75 | + |
| 76 | +/** |
| 77 | + * @} |
| 78 | + */ |
| 79 | + |
| 80 | +/** @defgroup NVIC_Priority_Table |
| 81 | + * @{ |
| 82 | + */ |
| 83 | + |
| 84 | +/** |
| 85 | +@code |
| 86 | + The table below gives the allowed values of the pre-emption priority and subpriority according |
| 87 | + to the Priority Grouping configuration performed by NVIC_PriorityGroupConfig function |
| 88 | + ============================================================================================================================ |
| 89 | + NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description |
| 90 | + ============================================================================================================================ |
| 91 | + NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority |
| 92 | + | | | 4 bits for subpriority |
| 93 | + ---------------------------------------------------------------------------------------------------------------------------- |
| 94 | + NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority |
| 95 | + | | | 3 bits for subpriority |
| 96 | + ---------------------------------------------------------------------------------------------------------------------------- |
| 97 | + NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority |
| 98 | + | | | 2 bits for subpriority |
| 99 | + ---------------------------------------------------------------------------------------------------------------------------- |
| 100 | + NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority |
| 101 | + | | | 1 bits for subpriority |
| 102 | + ---------------------------------------------------------------------------------------------------------------------------- |
| 103 | + NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority |
| 104 | + | | | 0 bits for subpriority |
| 105 | + ============================================================================================================================ |
| 106 | +@endcode |
| 107 | +*/ |
| 108 | + |
| 109 | +/** |
| 110 | + * @} |
| 111 | + */ |
| 112 | + |
| 113 | +/** @defgroup MISC_Exported_Constants |
| 114 | + * @{ |
| 115 | + */ |
| 116 | + |
| 117 | +/** @defgroup Vector_Table_Base |
| 118 | + * @{ |
| 119 | + */ |
| 120 | + |
| 121 | +#define NVIC_VectTab_RAM ((uint32_t)0x20000000) |
| 122 | +#define NVIC_VectTab_FLASH ((uint32_t)0x08000000) |
| 123 | +#define IS_NVIC_VECTTAB(VECTTAB) (((VECTTAB) == NVIC_VectTab_RAM) || \ |
| 124 | + ((VECTTAB) == NVIC_VectTab_FLASH)) |
| 125 | +/** |
| 126 | + * @} |
| 127 | + */ |
| 128 | + |
| 129 | +/** @defgroup System_Low_Power |
| 130 | + * @{ |
| 131 | + */ |
| 132 | + |
| 133 | +#define NVIC_LP_SEVONPEND ((uint8_t)0x10) |
| 134 | +#define NVIC_LP_SLEEPDEEP ((uint8_t)0x04) |
| 135 | +#define NVIC_LP_SLEEPONEXIT ((uint8_t)0x02) |
| 136 | +#define IS_NVIC_LP(LP) (((LP) == NVIC_LP_SEVONPEND) || \ |
| 137 | + ((LP) == NVIC_LP_SLEEPDEEP) || \ |
| 138 | + ((LP) == NVIC_LP_SLEEPONEXIT)) |
| 139 | +/** |
| 140 | + * @} |
| 141 | + */ |
| 142 | + |
| 143 | +/** @defgroup Preemption_Priority_Group |
| 144 | + * @{ |
| 145 | + */ |
| 146 | + |
| 147 | +#define NVIC_PriorityGroup_0 ((uint32_t)0x700) /*!< 0 bits for pre-emption priority |
| 148 | + 4 bits for subpriority */ |
| 149 | +#define NVIC_PriorityGroup_1 ((uint32_t)0x600) /*!< 1 bits for pre-emption priority |
| 150 | + 3 bits for subpriority */ |
| 151 | +#define NVIC_PriorityGroup_2 ((uint32_t)0x500) /*!< 2 bits for pre-emption priority |
| 152 | + 2 bits for subpriority */ |
| 153 | +#define NVIC_PriorityGroup_3 ((uint32_t)0x400) /*!< 3 bits for pre-emption priority |
| 154 | + 1 bits for subpriority */ |
| 155 | +#define NVIC_PriorityGroup_4 ((uint32_t)0x300) /*!< 4 bits for pre-emption priority |
| 156 | + 0 bits for subpriority */ |
| 157 | + |
| 158 | +#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PriorityGroup_0) || \ |
| 159 | + ((GROUP) == NVIC_PriorityGroup_1) || \ |
| 160 | + ((GROUP) == NVIC_PriorityGroup_2) || \ |
| 161 | + ((GROUP) == NVIC_PriorityGroup_3) || \ |
| 162 | + ((GROUP) == NVIC_PriorityGroup_4)) |
| 163 | + |
| 164 | +#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) |
| 165 | + |
| 166 | +#define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10) |
| 167 | + |
| 168 | +#define IS_NVIC_OFFSET(OFFSET) ((OFFSET) < 0x000FFFFF) |
| 169 | + |
| 170 | +/** |
| 171 | + * @} |
| 172 | + */ |
| 173 | + |
| 174 | +/** @defgroup SysTick_clock_source |
| 175 | + * @{ |
| 176 | + */ |
| 177 | + |
| 178 | +#define SysTick_CLKSource_HCLK_Div8 ((uint32_t)0xFFFFFFFB) |
| 179 | +#define SysTick_CLKSource_HCLK ((uint32_t)0x00000004) |
| 180 | +#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SysTick_CLKSource_HCLK) || \ |
| 181 | + ((SOURCE) == SysTick_CLKSource_HCLK_Div8)) |
| 182 | +/** |
| 183 | + * @} |
| 184 | + */ |
| 185 | + |
| 186 | +/** |
| 187 | + * @} |
| 188 | + */ |
| 189 | + |
| 190 | +/** @defgroup MISC_Exported_Macros |
| 191 | + * @{ |
| 192 | + */ |
| 193 | + |
| 194 | +/** |
| 195 | + * @} |
| 196 | + */ |
| 197 | + |
| 198 | +/** @defgroup MISC_Exported_Functions |
| 199 | + * @{ |
| 200 | + */ |
| 201 | + |
| 202 | +void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup); |
| 203 | +void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct); |
| 204 | +void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset); |
| 205 | +void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState); |
| 206 | +void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource); |
| 207 | + |
| 208 | +#ifdef __cplusplus |
| 209 | +} |
| 210 | +#endif |
| 211 | + |
| 212 | +#endif /* __MISC_H */ |
| 213 | + |
| 214 | +/** |
| 215 | + * @} |
| 216 | + */ |
| 217 | + |
| 218 | +/** |
| 219 | + * @} |
| 220 | + */ |
| 221 | + |
| 222 | +/** |
| 223 | + * @} |
| 224 | + */ |
| 225 | + |
| 226 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
0 commit comments