annotate f103c8/Src/main.c @ 6:ca42336826bd default tip

working on clock sources
author cin
date Mon, 23 Jan 2017 02:40:17 +0300
parents 0c59e7a7782a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
1 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
2 ******************************************************************************
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
3 * File Name : main.c
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
4 * Description : Main program body
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
5 ******************************************************************************
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
6 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
7 * COPYRIGHT(c) 2017 STMicroelectronics
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
8 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
9 * Redistribution and use in source and binary forms, with or without modification,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
10 * are permitted provided that the following conditions are met:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
11 * 1. Redistributions of source code must retain the above copyright notice,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
12 * this list of conditions and the following disclaimer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
14 * this list of conditions and the following disclaimer in the documentation
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
15 * and/or other materials provided with the distribution.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
16 * 3. Neither the name of STMicroelectronics nor the names of its contributors
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
17 * may be used to endorse or promote products derived from this software
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
18 * without specific prior written permission.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
19 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
27 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
30 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
31 ******************************************************************************
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
32 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
33 /* Includes ------------------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
34 #include "main.h"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
35 #include "stm32f1xx_hal.h"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
36
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
37 /* USER CODE BEGIN Includes */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
38
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
39 /* USER CODE END Includes */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
40
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
41 /* Private variables ---------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
42 TIM_HandleTypeDef htim4;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
43
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
44 /* USER CODE BEGIN PV */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
45 /* Private variables ---------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
46
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
47 /* USER CODE END PV */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
48
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
49 /* Private function prototypes -----------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
50 void SystemClock_Config(void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
51 void Error_Handler(void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
52 static void MX_GPIO_Init(void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
53 static void MX_TIM4_Init(void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
54 void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
55
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
56
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
57 /* USER CODE BEGIN PFP */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
58 /* Private function prototypes -----------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
59
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
60 /* USER CODE END PFP */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
61
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
62 /* USER CODE BEGIN 0 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
63
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
64 /* USER CODE END 0 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
65
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
66 int main(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
67 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
68
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
69 /* USER CODE BEGIN 1 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
70
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
71 /* USER CODE END 1 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
72
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
73 /* MCU Configuration----------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
74
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
75 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
76 HAL_Init();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
77
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
78 /* Configure the system clock */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
79 SystemClock_Config();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
80
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
81 /* Initialize all configured peripherals */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
82 MX_GPIO_Init();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
83 MX_TIM4_Init();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
84
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
85 /* USER CODE BEGIN 2 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
86
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
87 /* USER CODE END 2 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
88
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
89 /* Infinite loop */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
90 /* USER CODE BEGIN WHILE */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
91 while (1)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
92 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
93 /* USER CODE END WHILE */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
94
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
95 /* USER CODE BEGIN 3 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
96
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
97 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
98 /* USER CODE END 3 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
99
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
100 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
101
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
102 /** System Clock Configuration
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
103 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
104 void SystemClock_Config(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
105 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
106
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
107 RCC_OscInitTypeDef RCC_OscInitStruct;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
108 RCC_ClkInitTypeDef RCC_ClkInitStruct;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
109
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
110 /**Initializes the CPU, AHB and APB busses clocks
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
111 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
112 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
113 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
114 RCC_OscInitStruct.HSICalibrationValue = 16;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
115 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
116 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
117 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
118 Error_Handler();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
119 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
120
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
121 /**Initializes the CPU, AHB and APB busses clocks
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
122 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
123 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
124 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
125 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
126 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
127 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
128 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
129
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
130 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
131 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
132 Error_Handler();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
133 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
134
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
135 /**Configure the Systick interrupt time
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
136 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
137 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
138
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
139 /**Configure the Systick
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
140 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
141 HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
142
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
143 /* SysTick_IRQn interrupt configuration */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
144 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
145 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
146
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
147 /* TIM4 init function */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
148 static void MX_TIM4_Init(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
149 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
150
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
151 TIM_ClockConfigTypeDef sClockSourceConfig;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
152 TIM_MasterConfigTypeDef sMasterConfig;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
153 TIM_OC_InitTypeDef sConfigOC;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
154
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
155 htim4.Instance = TIM4;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
156 htim4.Init.Prescaler = 0;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
157 htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
158 htim4.Init.Period = 0;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
159 htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
160 if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
161 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
162 Error_Handler();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
163 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
164
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
165 sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
166 if (HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig) != HAL_OK)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
167 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
168 Error_Handler();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
169 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
170
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
171 if (HAL_TIM_PWM_Init(&htim4) != HAL_OK)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
172 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
173 Error_Handler();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
174 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
175
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
176 sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
177 sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
178 if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
179 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
180 Error_Handler();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
181 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
182
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
183 sConfigOC.OCMode = TIM_OCMODE_PWM1;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
184 sConfigOC.Pulse = 0;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
185 sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
186 sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
187 if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
188 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
189 Error_Handler();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
190 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
191
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
192 HAL_TIM_MspPostInit(&htim4);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
193
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
194 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
195
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
196 /** Configure pins as
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
197 * Analog
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
198 * Input
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
199 * Output
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
200 * EVENT_OUT
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
201 * EXTI
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
202 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
203 static void MX_GPIO_Init(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
204 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
205
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
206 GPIO_InitTypeDef GPIO_InitStruct;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
207
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
208 /* GPIO Ports Clock Enable */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
209 __HAL_RCC_GPIOC_CLK_ENABLE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
210 __HAL_RCC_GPIOD_CLK_ENABLE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
211 __HAL_RCC_GPIOA_CLK_ENABLE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
212 __HAL_RCC_GPIOB_CLK_ENABLE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
213
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
214 /*Configure GPIO pin Output Level */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
215 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
216
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
217 /*Configure GPIO pin : PA5 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
218 GPIO_InitStruct.Pin = GPIO_PIN_5;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
219 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
220 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
221 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
222
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
223 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
224
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
225 /* USER CODE BEGIN 4 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
226
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
227 /* USER CODE END 4 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
228
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
229 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
230 * @brief This function is executed in case of error occurrence.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
231 * @param None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
232 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
233 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
234 void Error_Handler(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
235 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
236 /* USER CODE BEGIN Error_Handler */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
237 /* User can add his own implementation to report the HAL error return state */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
238 while(1)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
239 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
240 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
241 /* USER CODE END Error_Handler */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
242 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
243
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
244 #ifdef USE_FULL_ASSERT
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
245
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
246 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
247 * @brief Reports the name of the source file and the source line number
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
248 * where the assert_param error has occurred.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
249 * @param file: pointer to the source file name
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
250 * @param line: assert_param error line source number
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
251 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
252 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
253 void assert_failed(uint8_t* file, uint32_t line)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
254 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
255 /* USER CODE BEGIN 6 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
256 /* User can add his own implementation to report the file name and line number,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
257 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
258 /* USER CODE END 6 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
259
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
260 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
261
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
262 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
263
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
264 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
265 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
266 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
267
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
268 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
269 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
270 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
271
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
272 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/