OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [drivers/] [ST/] [STM32F10xFWLib/] [src/] [misc.c] - Blame information for rev 608

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 608 jeremybenn
/**
2
  ******************************************************************************
3
  * @file  misc.c
4
  * @author  MCD Application Team
5
  * @version  V3.0.0
6
  * @date  04/06/2009
7
  * @brief  This file provides all the miscellaneous firmware functions.
8
  ******************************************************************************
9
  * @copy
10
  *
11
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17
  *
18
  * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
19
  */
20
 
21
/* Includes ------------------------------------------------------------------*/
22
#include "misc.h"
23
 
24
/** @addtogroup StdPeriph_Driver
25
  * @{
26
  */
27
 
28
/** @defgroup MISC
29
  * @brief MISC driver modules
30
  * @{
31
  */
32
 
33
/** @defgroup MISC_Private_TypesDefinitions
34
  * @{
35
  */
36
 
37
/**
38
  * @}
39
  */
40
 
41
/** @defgroup MISC_Private_Defines
42
  * @{
43
  */
44
 
45
#define AIRCR_VECTKEY_MASK    ((uint32_t)0x05FA0000)
46
/**
47
  * @}
48
  */
49
 
50
/** @defgroup MISC_Private_Macros
51
  * @{
52
  */
53
 
54
/**
55
  * @}
56
  */
57
 
58
/** @defgroup MISC_Private_Variables
59
  * @{
60
  */
61
 
62
/**
63
  * @}
64
  */
65
 
66
/** @defgroup MISC_Private_FunctionPrototypes
67
  * @{
68
  */
69
 
70
/**
71
  * @}
72
  */
73
 
74
/** @defgroup MISC_Private_Functions
75
  * @{
76
  */
77
 
78
/**
79
  * @brief  Configures the priority grouping: pre-emption priority and
80
  *         subpriority.
81
  * @param NVIC_PriorityGroup: specifies the priority grouping bits length.
82
  *   This parameter can be one of the following values:
83
  * @arg NVIC_PriorityGroup_0: 0 bits for pre-emption priority
84
  *                            4 bits for subpriority
85
  * @arg NVIC_PriorityGroup_1: 1 bits for pre-emption priority
86
  *                            3 bits for subpriority
87
  * @arg NVIC_PriorityGroup_2: 2 bits for pre-emption priority
88
  *                            2 bits for subpriority
89
  * @arg NVIC_PriorityGroup_3: 3 bits for pre-emption priority
90
  *                            1 bits for subpriority
91
  * @arg NVIC_PriorityGroup_4: 4 bits for pre-emption priority
92
  *                            0 bits for subpriority
93
  * @retval : None
94
  */
95
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
96
{
97
  /* Check the parameters */
98
  assert_param(IS_NVIC_PRIORITY_GROUP(NVIC_PriorityGroup));
99
 
100
  /* Set the PRIGROUP[10:8] bits according to NVIC_PriorityGroup value */
101
  SCB->AIRCR = AIRCR_VECTKEY_MASK | NVIC_PriorityGroup;
102
}
103
 
104
/**
105
  * @brief  Initializes the NVIC peripheral according to the specified
106
  *   parameters in the NVIC_InitStruct.
107
  * @param NVIC_InitStruct: pointer to a NVIC_InitTypeDef structure
108
  *   that contains the configuration information for the
109
  *   specified NVIC peripheral.
110
  * @retval : None
111
  */
112
void NVIC_Init(NVIC_InitTypeDef* NVIC_InitStruct)
113
{
114
  uint32_t tmppriority = 0x00, tmppre = 0x00, tmpsub = 0x0F;
115
 
116
  /* Check the parameters */
117
  assert_param(IS_FUNCTIONAL_STATE(NVIC_InitStruct->NVIC_IRQChannelCmd));
118
  assert_param(IS_NVIC_PREEMPTION_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority));
119
  assert_param(IS_NVIC_SUB_PRIORITY(NVIC_InitStruct->NVIC_IRQChannelSubPriority));
120
 
121
  if (NVIC_InitStruct->NVIC_IRQChannelCmd != DISABLE)
122
  {
123
    /* Compute the Corresponding IRQ Priority --------------------------------*/
124
    tmppriority = (0x700 - ((SCB->AIRCR) & (uint32_t)0x700))>> 0x08;
125
    tmppre = (0x4 - tmppriority);
126
    tmpsub = tmpsub >> tmppriority;
127
 
128
    tmppriority = (uint32_t)NVIC_InitStruct->NVIC_IRQChannelPreemptionPriority << tmppre;
129
    tmppriority |=  NVIC_InitStruct->NVIC_IRQChannelSubPriority & tmpsub;
130
    tmppriority = tmppriority << 0x04;
131
 
132
    NVIC->IP[NVIC_InitStruct->NVIC_IRQChannel] = tmppriority;
133
 
134
    /* Enable the Selected IRQ Channels --------------------------------------*/
135
    NVIC->ISER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
136
      (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
137
  }
138
  else
139
  {
140
    /* Disable the Selected IRQ Channels -------------------------------------*/
141
    NVIC->ICER[NVIC_InitStruct->NVIC_IRQChannel >> 0x05] =
142
      (uint32_t)0x01 << (NVIC_InitStruct->NVIC_IRQChannel & (uint8_t)0x1F);
143
  }
144
}
145
 
146
/**
147
  * @brief  Sets the vector table location and Offset.
148
  * @param NVIC_VectTab: specifies if the vector table is in RAM or
149
  *   FLASH memory.
150
  *   This parameter can be one of the following values:
151
  * @arg NVIC_VectTab_RAM
152
  * @arg NVIC_VectTab_FLASH
153
  * @param Offset: Vector Table base offset field.
154
  *   This value must be a multiple of 0x100.
155
  * @retval : None
156
  */
157
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
158
{
159
  /* Check the parameters */
160
  assert_param(IS_NVIC_VECTTAB(NVIC_VectTab));
161
  assert_param(IS_NVIC_OFFSET(Offset));
162
 
163
  SCB->VTOR = NVIC_VectTab | (Offset & (uint32_t)0x1FFFFF80);
164
}
165
 
166
/**
167
  * @brief  Selects the condition for the system to enter low power mode.
168
  * @param LowPowerMode: Specifies the new mode for the system to enter
169
  *   low power mode.
170
  *   This parameter can be one of the following values:
171
  * @arg NVIC_LP_SEVONPEND
172
  * @arg NVIC_LP_SLEEPDEEP
173
  * @arg NVIC_LP_SLEEPONEXIT
174
  * @param NewState: new state of LP condition.
175
  *   This parameter can be: ENABLE or DISABLE.
176
  * @retval : None
177
  */
178
void NVIC_SystemLPConfig(uint8_t LowPowerMode, FunctionalState NewState)
179
{
180
  /* Check the parameters */
181
  assert_param(IS_NVIC_LP(LowPowerMode));
182
  assert_param(IS_FUNCTIONAL_STATE(NewState));
183
 
184
  if (NewState != DISABLE)
185
  {
186
    SCB->SCR |= LowPowerMode;
187
  }
188
  else
189
  {
190
    SCB->SCR &= (uint32_t)(~(uint32_t)LowPowerMode);
191
  }
192
}
193
 
194
/**
195
  * @brief  Configures the SysTick clock source.
196
  * @param SysTick_CLKSource: specifies the SysTick clock source.
197
  *   This parameter can be one of the following values:
198
  * @arg SysTick_CLKSource_HCLK_Div8: AHB clock divided by 8
199
  *   selected as SysTick clock source.
200
  * @arg SysTick_CLKSource_HCLK: AHB clock selected as
201
  *   SysTick clock source.
202
  * @retval : None
203
  */
204
void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
205
{
206
  /* Check the parameters */
207
  assert_param(IS_SYSTICK_CLK_SOURCE(SysTick_CLKSource));
208
  if (SysTick_CLKSource == SysTick_CLKSource_HCLK)
209
  {
210
    SysTick->CTRL |= SysTick_CLKSource_HCLK;
211
  }
212
  else
213
  {
214
    SysTick->CTRL &= SysTick_CLKSource_HCLK_Div8;
215
  }
216
}
217
 
218
/**
219
  * @}
220
  */
221
 
222
/**
223
  * @}
224
  */
225
 
226
/**
227
  * @}
228
  */
229
 
230
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.