Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

stm32main.c 16 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2024 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main.h"
  21. #include <stdarg.h>
  22. #include "stdio.h"
  23. #include "string.h"
  24. #define INT_STATUS_1_REG 0x00
  25. #define MAX30102_ADDR (0x57 << 1)
  26. #define INT_STA1_REG 0x00
  27. #define INT_STA2_REG 0x01
  28. #define INT_ENA1_REG 0x02
  29. #define INT_ENA2_REG 0x03
  30. #define FIFO_WR_PTR 0x04
  31. #define FIFO_OVF_COUNT 0x05
  32. #define FIFO_RD_PTR 0x06
  33. #define FIFO_DATA_REG 0x07
  34. #define FIFO_CONFIG_REG 0x08
  35. #define MODE_CONFIG_REG 0x09
  36. #define SPO2_CONFIG_REG 0x0A
  37. #define LED_PULSE_AMPL_1 0x0C
  38. #define LED_PULSE_AMPL_2 0x0D
  39. #define MULTI_LED_CONTR_REG_1 0x11
  40. #define MULTI_LED_CONTR_REG_2 0x12
  41. // MAX30102 I2C Address
  42. #define MAX30102_WR_ADDR 0xAE
  43. #define MAX30102_RD_ADDR 0xAF
  44. #define PORT_USED 0
  45. #define HR_Mode 0x02 // Red LED only
  46. #define SpO2_Mode 0x03 // RED & IR LED
  47. #define MulitLED_Mode 0x07 // RED & IR LED
  48. #define THRESHOLD 1000
  49. #define SAMPLE_RATE 1000
  50. /* Private includes ----------------------------------------------------------*/
  51. /* USER CODE BEGIN Includes */
  52. int check=0;
  53. I2C_HandleTypeDef hi2c1;
  54. I2C_HandleTypeDef hi2c2;
  55. I2C_HandleTypeDef hi2c3;
  56. TIM_HandleTypeDef htim3;
  57. UART_HandleTypeDef huart2;
  58. int max30102_write_reg(uint8_t , uint8_t,I2C_HandleTypeDef );
  59. int max30102_init(uint8_t,I2C_HandleTypeDef x);
  60. void max30102_read_fifo_and_calculate_hr(I2C_HandleTypeDef );
  61. int max30102_read_register(uint8_t , uint8_t* , size_t ,I2C_HandleTypeDef );
  62. /* USER CODE BEGIN PV */
  63. void log_message(char *format, ...) {
  64. char buffer[100]; // Adjust size as needed
  65. va_list args;
  66. va_start(args, format);
  67. vsprintf(buffer, format, args);
  68. va_end(args);
  69. HAL_UART_Transmit(&huart2, (uint8_t*)buffer, strlen(buffer), HAL_MAX_DELAY);
  70. }
  71. /* USER CODE END PV */
  72. /* Private function prototypes -----------------------------------------------*/
  73. void SystemClock_Config(void);
  74. static void MX_GPIO_Init(void);
  75. static void MX_I2C1_Init(void);
  76. static void MX_I2C2_Init(void);
  77. static void MX_I2C3_Init(void);
  78. static void MX_USART2_UART_Init(void);
  79. static void MX_TIM3_Init(void);
  80. int max30102_write_reg(uint8_t reg , uint8_t value,I2C_HandleTypeDef x)
  81. {
  82. uint8_t data[2];
  83. data[0] = reg; // Register address
  84. data[1] = value; // Value to write
  85. HAL_StatusTypeDef ret;
  86. ret = HAL_I2C_Master_Transmit(&x, MAX30102_ADDR, data, sizeof(data), HAL_MAX_DELAY);
  87. if ( ret != HAL_OK ){
  88. log_message("Not working write");
  89. return 0;
  90. }
  91. return 1;
  92. }
  93. void max30102_read_fifo_and_calculate_hr(I2C_HandleTypeDef x)
  94. {
  95. uint8_t wr_ptr=0; uint8_t rd_ptr=0;
  96. max30102_read_register(FIFO_WR_PTR, &wr_ptr, 1,x);
  97. max30102_read_register(FIFO_RD_PTR, &rd_ptr, 1,x);
  98. uint8_t num_samples = (wr_ptr - rd_ptr);
  99. if(num_samples<1)
  100. num_samples=num_samples+32;
  101. for (int i = 0; i < num_samples; i++)
  102. {
  103. uint8_t sample[6];
  104. HAL_Delay(10);
  105. max30102_read_register(FIFO_DATA_REG, sample,6,x);
  106. //Extract only Red LED sample
  107. uint32_t red_sample = ((uint32_t)(sample[0] << 16) | (uint32_t)(sample[1] << 8) | (uint32_t)(sample[2])) & 0x3FFFF;
  108. log_message("%d,",red_sample);
  109. }
  110. }
  111. int max30102_read_register(uint8_t reg, uint8_t* value, size_t length, I2C_HandleTypeDef x)
  112. {
  113. HAL_StatusTypeDef ret_code_t;
  114. ret_code_t = HAL_I2C_Master_Transmit(&x, MAX30102_ADDR, &reg, 1, HAL_MAX_DELAY);
  115. if (ret_code_t != HAL_OK ) {
  116. log_message("Failed to set register address Error code");
  117. return 0;
  118. }
  119. ret_code_t= HAL_I2C_Master_Receive(&x, MAX30102_ADDR, value, length,HAL_MAX_DELAY);
  120. if (ret_code_t != HAL_OK ) {
  121. log_message("Failed to read data from MAX30102 register");
  122. return 0;
  123. }
  124. return 1;
  125. }
  126. int max30102_init(uint8_t Mode, I2C_HandleTypeDef x)
  127. {
  128. if (!max30102_write_reg(INT_ENA1_REG, 0x00, x)) { // A_FULL=1, PPG_RDY_EN=0 ALC_OVF_EN=0 -> 0x80
  129. log_message("Failed to write INT_ENA1_REG");
  130. return 0;
  131. }
  132. if (!max30102_write_reg(INT_ENA2_REG, 0x00,x)) { // DIE_TEMP_RDY_EN = 0
  133. log_message("Failed to write INT_ENA2_REG");
  134. return 0;
  135. }
  136. if (!max30102_write_reg(FIFO_WR_PTR, 0x00,x)) {
  137. log_message("Failed to write FIFO_WR_PTR");
  138. return 0;
  139. }
  140. if (!max30102_write_reg(FIFO_OVF_COUNT, 0x00,x)) {
  141. log_message("Failed to write FIFO_OVF_COUNT");
  142. return 0;
  143. }
  144. if (!max30102_write_reg(FIFO_RD_PTR, 0x00,x)) {
  145. log_message("Failed to write FIFO_RD_PTR");
  146. return 0;
  147. }
  148. if (!max30102_write_reg(FIFO_CONFIG_REG, 0xF0,x)) { // SMP_AVE=32(111), FIFO_ROLLOVER_EN=0, FIFO_A_FULL=32(0000) ->1110 0000=0xE0
  149. log_message("Failed to write FIFO_CONFIG_REG");
  150. return 0;
  151. }
  152. if (!max30102_write_reg(MODE_CONFIG_REG, Mode,x)) {
  153. log_message("Failed to write MODE_CONFIG_REG");
  154. return 0;
  155. }
  156. if (!max30102_write_reg(SPO2_CONFIG_REG, 0x27,x)) {
  157. log_message("Failed to write SPO2_CONFIG_REG");
  158. return 0;
  159. }
  160. if (!max30102_write_reg(LED_PULSE_AMPL_1, 0x32,x)) { // IR-LED current = 10mA
  161. log_message("Failed to write LED_PULSE_AMPL_1");
  162. return 0;
  163. }
  164. if (!max30102_write_reg(LED_PULSE_AMPL_2, 0x32,x)) { // RED-LED current = 10mA
  165. log_message("Failed to write LED_PULSE_AMPL_2");
  166. return 0;
  167. }
  168. return 1;
  169. }
  170. /* USER CODE END Includes */
  171. /* Private typedef -----------------------------------------------------------*/
  172. /* USER CODE BEGIN PTD */
  173. /* USER CODE END PTD */
  174. /* Private define ------------------------------------------------------------*/
  175. /* USER CODE BEGIN PD */
  176. /* USER CODE END PD */
  177. /* Private macro -------------------------------------------------------------*/
  178. /* USER CODE BEGIN PM */
  179. /* USER CODE END PM */
  180. /* Private variables ---------------------------------------------------------*/
  181. /* USER CODE BEGIN PFP */
  182. /* USER CODE END PFP */
  183. /* Private user code ---------------------------------------------------------*/
  184. /* USER CODE BEGIN 0 */
  185. /* USER CODE END 0 */
  186. /**
  187. * @brief The application entry point.
  188. * @retval int
  189. */
  190. int main(void)
  191. {
  192. /* USER CODE BEGIN 1 */
  193. /* USER CODE END 1 */
  194. /* MCU Configuration--------------------------------------------------------*/
  195. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  196. HAL_Init();
  197. /* USER CODE BEGIN Init */
  198. /* USER CODE END Init */
  199. /* Configure the system clock */
  200. SystemClock_Config();
  201. /* USER CODE BEGIN SysInit */
  202. /* USER CODE END SysInit */
  203. /* Initialize all configured peripherals */
  204. MX_GPIO_Init();
  205. MX_I2C1_Init();
  206. MX_I2C2_Init();
  207. MX_I2C3_Init();
  208. MX_USART2_UART_Init();
  209. MX_TIM3_Init();
  210. log_message("Place_your_hand");
  211. HAL_Delay(2000);
  212. max30102_init(SpO2_Mode,hi2c1);
  213. max30102_init(SpO2_Mode,hi2c2);
  214. max30102_init(SpO2_Mode,hi2c3);
  215. HAL_TIM_Base_Start_IT(&htim3);
  216. /* USER CODE BEGIN 2 */
  217. /* USER CODE END 2 */
  218. void kappdata(){
  219. max30102_read_fifo_and_calculate_hr(hi2c1);
  220. }
  221. void vatta(){
  222. max30102_read_fifo_and_calculate_hr(hi2c2);
  223. }
  224. void pitta(){
  225. max30102_read_fifo_and_calculate_hr(hi2c3);
  226. }
  227. /* Infinite loop */
  228. /* USER CODE BEGIN WHILE */
  229. while (1)
  230. {
  231. if(check==0) kappdata();
  232. if(check==1) vatta();
  233. if(check==2) pitta();
  234. }
  235. /* USER CODE END 3 */
  236. }
  237. /**
  238. * @brief System Clock Configuration
  239. * @retval None
  240. */
  241. void SystemClock_Config(void)
  242. {
  243. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  244. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  245. /** Configure the main internal regulator output voltage
  246. */
  247. __HAL_RCC_PWR_CLK_ENABLE();
  248. __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
  249. /** Initializes the RCC Oscillators according to the specified parameters
  250. * in the RCC_OscInitTypeDef structure.
  251. */
  252. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  253. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  254. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  255. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  256. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  257. RCC_OscInitStruct.PLL.PLLM = 16;
  258. RCC_OscInitStruct.PLL.PLLN = 336;
  259. RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
  260. RCC_OscInitStruct.PLL.PLLQ = 2;
  261. RCC_OscInitStruct.PLL.PLLR = 2;
  262. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  263. {
  264. Error_Handler();
  265. }
  266. /** Initializes the CPU, AHB and APB buses clocks
  267. */
  268. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  269. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  270. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  271. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  272. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  273. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  274. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  275. {
  276. Error_Handler();
  277. }
  278. }
  279. /**
  280. * @brief I2C1 Initialization Function
  281. * @param None
  282. * @retval None
  283. */
  284. static void MX_I2C1_Init(void)
  285. {
  286. /* USER CODE BEGIN I2C1_Init 0 */
  287. /* USER CODE END I2C1_Init 0 */
  288. /* USER CODE BEGIN I2C1_Init 1 */
  289. /* USER CODE END I2C1_Init 1 */
  290. hi2c1.Instance = I2C1;
  291. hi2c1.Init.ClockSpeed = 100000;
  292. hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
  293. hi2c1.Init.OwnAddress1 = 0;
  294. hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  295. hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  296. hi2c1.Init.OwnAddress2 = 0;
  297. hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  298. hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  299. if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  300. {
  301. Error_Handler();
  302. }
  303. /* USER CODE BEGIN I2C1_Init 2 */
  304. /* USER CODE END I2C1_Init 2 */
  305. }
  306. /**
  307. * @brief I2C2 Initialization Function
  308. * @param None
  309. * @retval None
  310. */
  311. static void MX_I2C2_Init(void)
  312. {
  313. /* USER CODE BEGIN I2C2_Init 0 */
  314. /* USER CODE END I2C2_Init 0 */
  315. /* USER CODE BEGIN I2C2_Init 1 */
  316. /* USER CODE END I2C2_Init 1 */
  317. hi2c2.Instance = I2C2;
  318. hi2c2.Init.ClockSpeed = 100000;
  319. hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
  320. hi2c2.Init.OwnAddress1 = 0;
  321. hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  322. hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  323. hi2c2.Init.OwnAddress2 = 0;
  324. hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  325. hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  326. if (HAL_I2C_Init(&hi2c2) != HAL_OK)
  327. {
  328. Error_Handler();
  329. }
  330. /* USER CODE BEGIN I2C2_Init 2 */
  331. /* USER CODE END I2C2_Init 2 */
  332. }
  333. /**
  334. * @brief I2C3 Initialization Function
  335. * @param None
  336. * @retval None
  337. */
  338. static void MX_I2C3_Init(void)
  339. {
  340. /* USER CODE BEGIN I2C3_Init 0 */
  341. /* USER CODE END I2C3_Init 0 */
  342. /* USER CODE BEGIN I2C3_Init 1 */
  343. /* USER CODE END I2C3_Init 1 */
  344. hi2c3.Instance = I2C3;
  345. hi2c3.Init.ClockSpeed = 100000;
  346. hi2c3.Init.DutyCycle = I2C_DUTYCYCLE_2;
  347. hi2c3.Init.OwnAddress1 = 0;
  348. hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  349. hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  350. hi2c3.Init.OwnAddress2 = 0;
  351. hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  352. hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  353. if (HAL_I2C_Init(&hi2c3) != HAL_OK)
  354. {
  355. Error_Handler();
  356. }
  357. /* USER CODE BEGIN I2C3_Init 2 */
  358. /* USER CODE END I2C3_Init 2 */
  359. }
  360. /**
  361. * @brief TIM3 Initialization Function
  362. * @param None
  363. * @retval None
  364. */
  365. static void MX_TIM3_Init(void)
  366. {
  367. /* USER CODE BEGIN TIM3_Init 0 */
  368. /* USER CODE END TIM3_Init 0 */
  369. TIM_ClockConfigTypeDef sClockSourceConfig = {0};
  370. TIM_MasterConfigTypeDef sMasterConfig = {0};
  371. /* USER CODE BEGIN TIM3_Init 1 */
  372. /* USER CODE END TIM3_Init 1 */
  373. htim3.Instance = TIM3;
  374. htim3.Init.Prescaler = 8399;
  375. htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
  376. htim3.Init.Period = 49999;
  377. htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  378. htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
  379. if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
  380. {
  381. Error_Handler();
  382. }
  383. sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
  384. if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
  385. {
  386. Error_Handler();
  387. }
  388. sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  389. sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  390. if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
  391. {
  392. Error_Handler();
  393. }
  394. /* USER CODE BEGIN TIM3_Init 2 */
  395. /* USER CODE END TIM3_Init 2 */
  396. }
  397. /**
  398. * @brief USART2 Initialization Function
  399. * @param None
  400. * @retval None
  401. */
  402. static void MX_USART2_UART_Init(void)
  403. {
  404. /* USER CODE BEGIN USART2_Init 0 */
  405. /* USER CODE END USART2_Init 0 */
  406. /* USER CODE BEGIN USART2_Init 1 */
  407. /* USER CODE END USART2_Init 1 */
  408. huart2.Instance = USART2;
  409. huart2.Init.BaudRate = 115200;
  410. huart2.Init.WordLength = UART_WORDLENGTH_8B;
  411. huart2.Init.StopBits = UART_STOPBITS_1;
  412. huart2.Init.Parity = UART_PARITY_NONE;
  413. huart2.Init.Mode = UART_MODE_TX_RX;
  414. huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  415. huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  416. if (HAL_UART_Init(&huart2) != HAL_OK)
  417. {
  418. Error_Handler();
  419. }
  420. /* USER CODE BEGIN USART2_Init 2 */
  421. /* USER CODE END USART2_Init 2 */
  422. }
  423. /**
  424. * @brief GPIO Initialization Function
  425. * @param None
  426. * @retval None
  427. */
  428. static void MX_GPIO_Init(void)
  429. {
  430. GPIO_InitTypeDef GPIO_InitStruct = {0};
  431. /* USER CODE BEGIN MX_GPIO_Init_1 */
  432. /* USER CODE END MX_GPIO_Init_1 */
  433. /* GPIO Ports Clock Enable */
  434. __HAL_RCC_GPIOC_CLK_ENABLE();
  435. __HAL_RCC_GPIOH_CLK_ENABLE();
  436. __HAL_RCC_GPIOA_CLK_ENABLE();
  437. __HAL_RCC_GPIOB_CLK_ENABLE();
  438. /*Configure GPIO pin Output Level */
  439. HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
  440. /*Configure GPIO pin : B1_Pin */
  441. GPIO_InitStruct.Pin = B1_Pin;
  442. GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
  443. GPIO_InitStruct.Pull = GPIO_NOPULL;
  444. HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
  445. /*Configure GPIO pin : LD2_Pin */
  446. GPIO_InitStruct.Pin = LD2_Pin;
  447. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  448. GPIO_InitStruct.Pull = GPIO_NOPULL;
  449. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  450. HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
  451. /* USER CODE BEGIN MX_GPIO_Init_2 */
  452. /* USER CODE END MX_GPIO_Init_2 */
  453. }
  454. /* USER CODE BEGIN 4 */
  455. /* USER CODE END 4 */
  456. /**
  457. * @brief This function is executed in case of error occurrence.
  458. * @retval None
  459. */
  460. void Error_Handler(void)
  461. {
  462. /* USER CODE BEGIN Error_Handler_Debug */
  463. /* User can add his own implementation to report the HAL error return state */
  464. __disable_irq();
  465. while (1)
  466. {
  467. }
  468. /* USER CODE END Error_Handler_Debug */
  469. }
  470. #ifdef USE_FULL_ASSERT
  471. /**
  472. * @brief Reports the name of the source file and the source line number
  473. * where the assert_param error has occurred.
  474. * @param file: pointer to the source file name
  475. * @param line: assert_param error line source number
  476. * @retval None
  477. */
  478. void assert_failed(uint8_t *file, uint32_t line)
  479. {
  480. /* USER CODE BEGIN 6 */
  481. /* User can add his own implementation to report the file name and line number,
  482. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  483. /* USER CODE END 6 */
  484. }
  485. #endif /* USE_FULL_ASSERT */