annotate l476rg/Src/main.c @ 2:0c59e7a7782a

Working on GPIO and RCC
author cin
date Mon, 16 Jan 2017 11:04:47 +0300
parents 32a3b1785697
children ca4f5b55b391
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
1 /**
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
2 ******************************************************************************
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
3 * File Name : main.c
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
4 * Description : Main program body
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
5 ******************************************************************************
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
6 *
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
7 * COPYRIGHT(c) 2017 STMicroelectronics
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
8 *
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
9 * Redistribution and use in source and binary forms, with or without modification,
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
10 * are permitted provided that the following conditions are met:
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
11 * 1. Redistributions of source code must retain the above copyright notice,
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
12 * this list of conditions and the following disclaimer.
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
14 * this list of conditions and the following disclaimer in the documentation
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
15 * and/or other materials provided with the distribution.
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
16 * 3. Neither the name of STMicroelectronics nor the names of its contributors
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
17 * may be used to endorse or promote products derived from this software
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
18 * without specific prior written permission.
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
19 *
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
27 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
30 *
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
31 ******************************************************************************
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
32 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
33 /* Includes ------------------------------------------------------------------*/
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
34 #include "main.h"
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
35 #include "stm32l4xx_hal.h"
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
36 #include "usart.h"
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
37 #include "gpio.h"
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
38
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
39 /* USER CODE BEGIN Includes */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
40
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
41 /* USER CODE END Includes */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
42
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
43 /* Private variables ---------------------------------------------------------*/
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
44
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
45 /* USER CODE BEGIN PV */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
46 /* Private variables ---------------------------------------------------------*/
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
47
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
48 /* USER CODE END PV */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
49
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
50 /* Private function prototypes -----------------------------------------------*/
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
51 void SystemClock_Config(void);
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
52 void Error_Handler(void);
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
53
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
54 /* USER CODE BEGIN PFP */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
55 /* Private function prototypes -----------------------------------------------*/
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
56
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
57 /* USER CODE END PFP */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
58
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
59 /* USER CODE BEGIN 0 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
60
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
61 /* USER CODE END 0 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
62
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
63 int main(void)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
64 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
65
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
66 /* USER CODE BEGIN 1 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
67
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
68 /* USER CODE END 1 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
69
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
70 /* MCU Configuration----------------------------------------------------------*/
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
71
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
72 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
73 HAL_Init();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
74
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
75 /* Configure the system clock */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
76 SystemClock_Config();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
77
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
78 /* Initialize all configured peripherals */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
79 MX_GPIO_Init();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
80 MX_USART2_UART_Init();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
81
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
82 /* USER CODE BEGIN 2 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
83
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
84 /* USER CODE END 2 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
85
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
86 /* Infinite loop */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
87 /* USER CODE BEGIN WHILE */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
88 while (1)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
89 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
90 /* USER CODE END WHILE */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
91
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
92 /* USER CODE BEGIN 3 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
93
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
94 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
95 /* USER CODE END 3 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
96
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
97 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
98
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
99 /** System Clock Configuration
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
100 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
101 void SystemClock_Config(void)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
102 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
103
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
104 RCC_OscInitTypeDef RCC_OscInitStruct;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
105 RCC_ClkInitTypeDef RCC_ClkInitStruct;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
106 RCC_PeriphCLKInitTypeDef PeriphClkInit;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
107
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
108 /**Initializes the CPU, AHB and APB busses clocks
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
109 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
110 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
111 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
112 RCC_OscInitStruct.HSICalibrationValue = 16;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
113 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
114 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
115 RCC_OscInitStruct.PLL.PLLM = 1;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
116 RCC_OscInitStruct.PLL.PLLN = 10;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
117 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
118 RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
119 RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
120 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
121 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
122 Error_Handler();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
123 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
124
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
125 /**Initializes the CPU, AHB and APB busses clocks
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
126 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
127 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
128 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
129 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
130 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
131 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
132 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
133
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
134 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
135 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
136 Error_Handler();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
137 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
138
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
139 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
140 PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
141 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
142 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
143 Error_Handler();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
144 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
145
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
146 /**Configure the main internal regulator output voltage
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
147 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
148 if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
149 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
150 Error_Handler();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
151 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
152
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
153 /**Configure the Systick interrupt time
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
154 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
155 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
156
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
157 /**Configure the Systick
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
158 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
159 HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
160
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
161 /* SysTick_IRQn interrupt configuration */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
162 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
163 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
164
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
165 /* USER CODE BEGIN 4 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
166
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
167 /* USER CODE END 4 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
168
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
169 /**
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
170 * @brief Period elapsed callback in non blocking mode
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
171 * @note This function is called when TIM6 interrupt took place, inside
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
172 * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
173 * a global variable "uwTick" used as application time base.
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
174 * @param htim : TIM handle
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
175 * @retval None
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
176 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
177 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
178 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
179 /* USER CODE BEGIN Callback 0 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
180
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
181 /* USER CODE END Callback 0 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
182 if (htim->Instance == TIM6) {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
183 HAL_IncTick();
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
184 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
185 /* USER CODE BEGIN Callback 1 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
186
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
187 /* USER CODE END Callback 1 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
188 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
189
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
190 /**
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
191 * @brief This function is executed in case of error occurrence.
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
192 * @param None
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
193 * @retval None
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
194 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
195 void Error_Handler(void)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
196 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
197 /* USER CODE BEGIN Error_Handler */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
198 /* User can add his own implementation to report the HAL error return state */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
199 while(1)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
200 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
201 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
202 /* USER CODE END Error_Handler */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
203 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
204
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
205 #ifdef USE_FULL_ASSERT
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
206
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
207 /**
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
208 * @brief Reports the name of the source file and the source line number
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
209 * where the assert_param error has occurred.
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
210 * @param file: pointer to the source file name
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
211 * @param line: assert_param error line source number
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
212 * @retval None
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
213 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
214 void assert_failed(uint8_t* file, uint32_t line)
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
215 {
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
216 /* USER CODE BEGIN 6 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
217 /* User can add his own implementation to report the file name and line number,
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
218 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
219 /* USER CODE END 6 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
220
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
221 }
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
222
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
223 #endif
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
224
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
225 /**
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
226 * @}
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
227 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
228
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
229 /**
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
230 * @}
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
231 */
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
232
32a3b1785697 a rough draft of Hardware Abstraction Layer for C++
cin
parents:
diff changeset
233 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/