xref: /btstack/port/stm32-f4discovery-usb/Core/Src/main.c (revision d20c764cf7101fbf842ceeacaa4e9dd0eed2991d)
1a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN Header */
2a8f7f3fcSMatthias Ringwald /**
3a8f7f3fcSMatthias Ringwald   ******************************************************************************
4a8f7f3fcSMatthias Ringwald   * @file           : main.c
5a8f7f3fcSMatthias Ringwald   * @brief          : Main program body
6a8f7f3fcSMatthias Ringwald   ******************************************************************************
7a8f7f3fcSMatthias Ringwald   * @attention
8a8f7f3fcSMatthias Ringwald   *
9a8f7f3fcSMatthias Ringwald   * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
10a8f7f3fcSMatthias Ringwald   * All rights reserved.</center></h2>
11a8f7f3fcSMatthias Ringwald   *
12a8f7f3fcSMatthias Ringwald   * This software component is licensed by ST under Ultimate Liberty license
13a8f7f3fcSMatthias Ringwald   * SLA0044, the "License"; You may not use this file except in compliance with
14a8f7f3fcSMatthias Ringwald   * the License. You may obtain a copy of the License at:
15a8f7f3fcSMatthias Ringwald   *                             www.st.com/SLA0044
16a8f7f3fcSMatthias Ringwald   *
17a8f7f3fcSMatthias Ringwald   ******************************************************************************
18a8f7f3fcSMatthias Ringwald   */
19a8f7f3fcSMatthias Ringwald /* USER CODE END Header */
20a8f7f3fcSMatthias Ringwald /* Includes ------------------------------------------------------------------*/
21a8f7f3fcSMatthias Ringwald #include "main.h"
22a8f7f3fcSMatthias Ringwald #include "usb_host.h"
23a8f7f3fcSMatthias Ringwald 
24a8f7f3fcSMatthias Ringwald /* Private includes ----------------------------------------------------------*/
25a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN Includes */
26*d20c764cSMatthias Ringwald #include "port.h"
27a8f7f3fcSMatthias Ringwald 
28a8f7f3fcSMatthias Ringwald /* USER CODE END Includes */
29a8f7f3fcSMatthias Ringwald 
30a8f7f3fcSMatthias Ringwald /* Private typedef -----------------------------------------------------------*/
31a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN PTD */
32a8f7f3fcSMatthias Ringwald 
33a8f7f3fcSMatthias Ringwald /* USER CODE END PTD */
34a8f7f3fcSMatthias Ringwald 
35a8f7f3fcSMatthias Ringwald /* Private define ------------------------------------------------------------*/
36a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN PD */
37a8f7f3fcSMatthias Ringwald /* USER CODE END PD */
38a8f7f3fcSMatthias Ringwald 
39a8f7f3fcSMatthias Ringwald /* Private macro -------------------------------------------------------------*/
40a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN PM */
41a8f7f3fcSMatthias Ringwald 
42a8f7f3fcSMatthias Ringwald /* USER CODE END PM */
43a8f7f3fcSMatthias Ringwald 
44a8f7f3fcSMatthias Ringwald /* Private variables ---------------------------------------------------------*/
45a8f7f3fcSMatthias Ringwald 
46a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN PV */
47a8f7f3fcSMatthias Ringwald 
48a8f7f3fcSMatthias Ringwald /* USER CODE END PV */
49a8f7f3fcSMatthias Ringwald 
50a8f7f3fcSMatthias Ringwald /* Private function prototypes -----------------------------------------------*/
51a8f7f3fcSMatthias Ringwald void SystemClock_Config(void);
52a8f7f3fcSMatthias Ringwald static void MX_GPIO_Init(void);
53a8f7f3fcSMatthias Ringwald void MX_USB_HOST_Process(void);
54a8f7f3fcSMatthias Ringwald 
55a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN PFP */
56a8f7f3fcSMatthias Ringwald 
57a8f7f3fcSMatthias Ringwald /* USER CODE END PFP */
58a8f7f3fcSMatthias Ringwald 
59a8f7f3fcSMatthias Ringwald /* Private user code ---------------------------------------------------------*/
60a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN 0 */
61a8f7f3fcSMatthias Ringwald 
62a8f7f3fcSMatthias Ringwald /* USER CODE END 0 */
63a8f7f3fcSMatthias Ringwald 
64a8f7f3fcSMatthias Ringwald /**
65a8f7f3fcSMatthias Ringwald   * @brief  The application entry point.
66a8f7f3fcSMatthias Ringwald   * @retval int
67a8f7f3fcSMatthias Ringwald   */
main(void)68a8f7f3fcSMatthias Ringwald int main(void)
69a8f7f3fcSMatthias Ringwald {
70a8f7f3fcSMatthias Ringwald   /* USER CODE BEGIN 1 */
71a8f7f3fcSMatthias Ringwald 
72a8f7f3fcSMatthias Ringwald   /* USER CODE END 1 */
73a8f7f3fcSMatthias Ringwald 
74a8f7f3fcSMatthias Ringwald   /* MCU Configuration--------------------------------------------------------*/
75a8f7f3fcSMatthias Ringwald 
76a8f7f3fcSMatthias Ringwald   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
77a8f7f3fcSMatthias Ringwald   HAL_Init();
78a8f7f3fcSMatthias Ringwald 
79a8f7f3fcSMatthias Ringwald   /* USER CODE BEGIN Init */
80a8f7f3fcSMatthias Ringwald 
81a8f7f3fcSMatthias Ringwald   /* USER CODE END Init */
82a8f7f3fcSMatthias Ringwald 
83a8f7f3fcSMatthias Ringwald   /* Configure the system clock */
84a8f7f3fcSMatthias Ringwald   SystemClock_Config();
85a8f7f3fcSMatthias Ringwald 
86a8f7f3fcSMatthias Ringwald   /* USER CODE BEGIN SysInit */
87a8f7f3fcSMatthias Ringwald 
88a8f7f3fcSMatthias Ringwald   /* USER CODE END SysInit */
89a8f7f3fcSMatthias Ringwald 
90a8f7f3fcSMatthias Ringwald   /* Initialize all configured peripherals */
91a8f7f3fcSMatthias Ringwald   MX_GPIO_Init();
92a8f7f3fcSMatthias Ringwald   MX_USB_HOST_Init();
93a8f7f3fcSMatthias Ringwald   /* USER CODE BEGIN 2 */
94*d20c764cSMatthias Ringwald   port_main();
95a8f7f3fcSMatthias Ringwald   /* USER CODE END 2 */
96a8f7f3fcSMatthias Ringwald 
97a8f7f3fcSMatthias Ringwald   /* Infinite loop */
98a8f7f3fcSMatthias Ringwald   /* USER CODE BEGIN WHILE */
99a8f7f3fcSMatthias Ringwald   while (1)
100a8f7f3fcSMatthias Ringwald   {
101a8f7f3fcSMatthias Ringwald     /* USER CODE END WHILE */
102a8f7f3fcSMatthias Ringwald     MX_USB_HOST_Process();
103a8f7f3fcSMatthias Ringwald 
104a8f7f3fcSMatthias Ringwald     /* USER CODE BEGIN 3 */
105a8f7f3fcSMatthias Ringwald   }
106a8f7f3fcSMatthias Ringwald   /* USER CODE END 3 */
107a8f7f3fcSMatthias Ringwald }
108a8f7f3fcSMatthias Ringwald 
109a8f7f3fcSMatthias Ringwald /**
110a8f7f3fcSMatthias Ringwald   * @brief System Clock Configuration
111a8f7f3fcSMatthias Ringwald   * @retval None
112a8f7f3fcSMatthias Ringwald   */
SystemClock_Config(void)113a8f7f3fcSMatthias Ringwald void SystemClock_Config(void)
114a8f7f3fcSMatthias Ringwald {
115a8f7f3fcSMatthias Ringwald   RCC_OscInitTypeDef RCC_OscInitStruct = {0};
116a8f7f3fcSMatthias Ringwald   RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
117a8f7f3fcSMatthias Ringwald 
118a8f7f3fcSMatthias Ringwald   /** Configure the main internal regulator output voltage
119a8f7f3fcSMatthias Ringwald   */
120a8f7f3fcSMatthias Ringwald   __HAL_RCC_PWR_CLK_ENABLE();
121a8f7f3fcSMatthias Ringwald   __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
122a8f7f3fcSMatthias Ringwald   /** Initializes the RCC Oscillators according to the specified parameters
123a8f7f3fcSMatthias Ringwald   * in the RCC_OscInitTypeDef structure.
124a8f7f3fcSMatthias Ringwald   */
125a8f7f3fcSMatthias Ringwald   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
126a8f7f3fcSMatthias Ringwald   RCC_OscInitStruct.HSEState = RCC_HSE_ON;
127a8f7f3fcSMatthias Ringwald   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
128a8f7f3fcSMatthias Ringwald   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
129a8f7f3fcSMatthias Ringwald   RCC_OscInitStruct.PLL.PLLM = 4;
130a8f7f3fcSMatthias Ringwald   RCC_OscInitStruct.PLL.PLLN = 72;
131a8f7f3fcSMatthias Ringwald   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
132a8f7f3fcSMatthias Ringwald   RCC_OscInitStruct.PLL.PLLQ = 3;
133a8f7f3fcSMatthias Ringwald   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
134a8f7f3fcSMatthias Ringwald   {
135a8f7f3fcSMatthias Ringwald     Error_Handler();
136a8f7f3fcSMatthias Ringwald   }
137a8f7f3fcSMatthias Ringwald   /** Initializes the CPU, AHB and APB buses clocks
138a8f7f3fcSMatthias Ringwald   */
139a8f7f3fcSMatthias Ringwald   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
140a8f7f3fcSMatthias Ringwald                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
141a8f7f3fcSMatthias Ringwald   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
142a8f7f3fcSMatthias Ringwald   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
143a8f7f3fcSMatthias Ringwald   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
144a8f7f3fcSMatthias Ringwald   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
145a8f7f3fcSMatthias Ringwald 
146a8f7f3fcSMatthias Ringwald   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
147a8f7f3fcSMatthias Ringwald   {
148a8f7f3fcSMatthias Ringwald     Error_Handler();
149a8f7f3fcSMatthias Ringwald   }
150a8f7f3fcSMatthias Ringwald }
151a8f7f3fcSMatthias Ringwald 
152a8f7f3fcSMatthias Ringwald /**
153a8f7f3fcSMatthias Ringwald   * @brief GPIO Initialization Function
154a8f7f3fcSMatthias Ringwald   * @param None
155a8f7f3fcSMatthias Ringwald   * @retval None
156a8f7f3fcSMatthias Ringwald   */
MX_GPIO_Init(void)157a8f7f3fcSMatthias Ringwald static void MX_GPIO_Init(void)
158a8f7f3fcSMatthias Ringwald {
159a8f7f3fcSMatthias Ringwald   GPIO_InitTypeDef GPIO_InitStruct = {0};
160a8f7f3fcSMatthias Ringwald 
161a8f7f3fcSMatthias Ringwald   /* GPIO Ports Clock Enable */
162a8f7f3fcSMatthias Ringwald   __HAL_RCC_GPIOE_CLK_ENABLE();
163a8f7f3fcSMatthias Ringwald   __HAL_RCC_GPIOC_CLK_ENABLE();
164a8f7f3fcSMatthias Ringwald   __HAL_RCC_GPIOH_CLK_ENABLE();
165a8f7f3fcSMatthias Ringwald   __HAL_RCC_GPIOA_CLK_ENABLE();
166a8f7f3fcSMatthias Ringwald   __HAL_RCC_GPIOB_CLK_ENABLE();
167a8f7f3fcSMatthias Ringwald   __HAL_RCC_GPIOD_CLK_ENABLE();
168a8f7f3fcSMatthias Ringwald 
169a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin Output Level */
170a8f7f3fcSMatthias Ringwald   HAL_GPIO_WritePin(CS_I2C_SPI_GPIO_Port, CS_I2C_SPI_Pin, GPIO_PIN_RESET);
171a8f7f3fcSMatthias Ringwald 
172a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin Output Level */
173a8f7f3fcSMatthias Ringwald   HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET);
174a8f7f3fcSMatthias Ringwald 
175a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin Output Level */
176a8f7f3fcSMatthias Ringwald   HAL_GPIO_WritePin(GPIOD, LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin
177a8f7f3fcSMatthias Ringwald                           |Audio_RST_Pin, GPIO_PIN_RESET);
178a8f7f3fcSMatthias Ringwald 
179a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : CS_I2C_SPI_Pin */
180a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = CS_I2C_SPI_Pin;
181a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
182a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
183a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
184a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(CS_I2C_SPI_GPIO_Port, &GPIO_InitStruct);
185a8f7f3fcSMatthias Ringwald 
186a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : OTG_FS_PowerSwitchOn_Pin */
187a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin;
188a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
189a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
190a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
191a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
192a8f7f3fcSMatthias Ringwald 
193a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : PDM_OUT_Pin */
194a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = PDM_OUT_Pin;
195a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
196a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
197a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
198a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
199a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(PDM_OUT_GPIO_Port, &GPIO_InitStruct);
200a8f7f3fcSMatthias Ringwald 
201a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : B1_Pin */
202a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = B1_Pin;
203a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
204a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
205a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
206a8f7f3fcSMatthias Ringwald 
207a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : I2S3_WS_Pin */
208a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = I2S3_WS_Pin;
209a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
210a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
211a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
212a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
213a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(I2S3_WS_GPIO_Port, &GPIO_InitStruct);
214a8f7f3fcSMatthias Ringwald 
215a8f7f3fcSMatthias Ringwald   /*Configure GPIO pins : SPI1_SCK_Pin SPI1_MISO_Pin SPI1_MOSI_Pin */
216a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = SPI1_SCK_Pin|SPI1_MISO_Pin|SPI1_MOSI_Pin;
217a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
218a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
219a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
220a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
221a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
222a8f7f3fcSMatthias Ringwald 
223a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : BOOT1_Pin */
224a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = BOOT1_Pin;
225a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
226a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
227a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(BOOT1_GPIO_Port, &GPIO_InitStruct);
228a8f7f3fcSMatthias Ringwald 
229a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : CLK_IN_Pin */
230a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = CLK_IN_Pin;
231a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
232a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
233a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
234a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
235a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(CLK_IN_GPIO_Port, &GPIO_InitStruct);
236a8f7f3fcSMatthias Ringwald 
237a8f7f3fcSMatthias Ringwald   /*Configure GPIO pins : LD4_Pin LD3_Pin LD5_Pin LD6_Pin
238a8f7f3fcSMatthias Ringwald                            Audio_RST_Pin */
239a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin
240a8f7f3fcSMatthias Ringwald                           |Audio_RST_Pin;
241a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
242a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
243a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
244a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
245a8f7f3fcSMatthias Ringwald 
246a8f7f3fcSMatthias Ringwald   /*Configure GPIO pins : I2S3_MCK_Pin I2S3_SCK_Pin I2S3_SD_Pin */
247a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = I2S3_MCK_Pin|I2S3_SCK_Pin|I2S3_SD_Pin;
248a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
249a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
250a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
251a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
252a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
253a8f7f3fcSMatthias Ringwald 
254a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : OTG_FS_OverCurrent_Pin */
255a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin;
256a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
257a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
258a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct);
259a8f7f3fcSMatthias Ringwald 
260a8f7f3fcSMatthias Ringwald   /*Configure GPIO pins : Audio_SCL_Pin Audio_SDA_Pin */
261a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = Audio_SCL_Pin|Audio_SDA_Pin;
262a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
263a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_PULLUP;
264a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
265a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
266a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
267a8f7f3fcSMatthias Ringwald 
268a8f7f3fcSMatthias Ringwald   /*Configure GPIO pin : MEMS_INT2_Pin */
269a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pin = MEMS_INT2_Pin;
270a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
271a8f7f3fcSMatthias Ringwald   GPIO_InitStruct.Pull = GPIO_NOPULL;
272a8f7f3fcSMatthias Ringwald   HAL_GPIO_Init(MEMS_INT2_GPIO_Port, &GPIO_InitStruct);
273a8f7f3fcSMatthias Ringwald 
274a8f7f3fcSMatthias Ringwald }
275a8f7f3fcSMatthias Ringwald 
276a8f7f3fcSMatthias Ringwald /* USER CODE BEGIN 4 */
277a8f7f3fcSMatthias Ringwald 
278a8f7f3fcSMatthias Ringwald /* USER CODE END 4 */
279a8f7f3fcSMatthias Ringwald 
280a8f7f3fcSMatthias Ringwald /**
281a8f7f3fcSMatthias Ringwald   * @brief  This function is executed in case of error occurrence.
282a8f7f3fcSMatthias Ringwald   * @retval None
283a8f7f3fcSMatthias Ringwald   */
Error_Handler(void)284a8f7f3fcSMatthias Ringwald void Error_Handler(void)
285a8f7f3fcSMatthias Ringwald {
286a8f7f3fcSMatthias Ringwald   /* USER CODE BEGIN Error_Handler_Debug */
287a8f7f3fcSMatthias Ringwald   /* User can add his own implementation to report the HAL error return state */
288a8f7f3fcSMatthias Ringwald   __disable_irq();
289a8f7f3fcSMatthias Ringwald   while (1)
290a8f7f3fcSMatthias Ringwald   {
291a8f7f3fcSMatthias Ringwald   }
292a8f7f3fcSMatthias Ringwald   /* USER CODE END Error_Handler_Debug */
293a8f7f3fcSMatthias Ringwald }
294a8f7f3fcSMatthias Ringwald 
295a8f7f3fcSMatthias Ringwald #ifdef  USE_FULL_ASSERT
296a8f7f3fcSMatthias Ringwald /**
297a8f7f3fcSMatthias Ringwald   * @brief  Reports the name of the source file and the source line number
298a8f7f3fcSMatthias Ringwald   *         where the assert_param error has occurred.
299a8f7f3fcSMatthias Ringwald   * @param  file: pointer to the source file name
300a8f7f3fcSMatthias Ringwald   * @param  line: assert_param error line source number
301a8f7f3fcSMatthias Ringwald   * @retval None
302a8f7f3fcSMatthias Ringwald   */
assert_failed(uint8_t * file,uint32_t line)303a8f7f3fcSMatthias Ringwald void assert_failed(uint8_t *file, uint32_t line)
304a8f7f3fcSMatthias Ringwald {
305a8f7f3fcSMatthias Ringwald   /* USER CODE BEGIN 6 */
306a8f7f3fcSMatthias Ringwald   /* User can add his own implementation to report the file name and line number,
307a8f7f3fcSMatthias Ringwald      ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
308a8f7f3fcSMatthias Ringwald   /* USER CODE END 6 */
309a8f7f3fcSMatthias Ringwald }
310a8f7f3fcSMatthias Ringwald #endif /* USE_FULL_ASSERT */
311a8f7f3fcSMatthias Ringwald 
312a8f7f3fcSMatthias Ringwald /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
313