ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */
时间: 2024-04-27 09:21:08 浏览: 144
C_language_example_of_the_essence.rar_The Essence
这段代码是用于检查参数合法性的宏定义。在代码中如果使用了assert_param()函数,当参数不合法时,会触发assert_failed()函数。该函数会输出错误的源文件名和行号,以便于开发者进行调试和修复代码。如果使用了USE_FULL_ASSERT宏定义,表示开启了完整的断言检查,否则只开启了基本的断言检查。
阅读全文