/** ########################################################################## ** Filename : assert.c ** Project : ** Module : ** Processor : ** Version : 1.0 ** Compiler : ** Date/Time : ** Abstract : ** Contents : ** Note : ** ** (c) Copyright dmdz Co.,Ltd ** -------------------------------------------------------------------------- ** R E V I S I O N H I S T O R Y ** -------------------------------------------------------------------------- ** Date Ver Author Description ** -20230602- --V1.0-- --mingyea--- --修改-- ** #########################################################################*/ /*--------------------------------------------------------------------------- - I N C L U D E F I L E S ----------------------------------------------------------------------------*/ #include "common_types.h" /*--------------------------------------------------------------------------- - D E F I N E S / M A C R O S ----------------------------------------------------------------------------*/ //#ifdef USE_FULL_ASSERT /*--------------------------------------------------------------------------- - T Y P E D E F I N I T I O N S ----------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------- - S T A T I C V A R I A B L E S ----------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------- - G L O B A L V A R I A B L E S ----------------------------------------------------------------------------*/ u32 g_assert_line; u8 *g_assert_file; u8 g_assert_file_buf[200]; /*--------------------------------------------------------------------------- - C O N S T A N T S ----------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------- - F U N C T I O N P R O T O T Y P E ----------------------------------------------------------------------------*/ /*lint -efunc(957,assert_failed) */ /* 函數應當具有原型聲明,且原型在函數的定義和調用範圍內都是可見的 */ /*lint -efunc(818,assert_failed) */ /* (建議)函數原型中的指針參數如果不是用於修改所指向的對像,就應該聲明為指向const的指針MISRA 2004 Rule 16.7 */ /*--------------------------------------------------------------------------- |Prototype : void assert_failed(uint8_t* file, uint32_t line) |Called by : None |Preconditions : None |Input parameters : None |Output parameters : None |Return value : None |Description : ----------------------------------------------------------------------------*/ //void assert_failed(uint8_t* file, uint32_t line) void assert_failed(void) { /* 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) */ /*注意要查看變量的值需將宏開啟*/ #if 0 u8 i; g_assert_line = line; g_assert_file = file; for(i=0;i<200;i++) { g_assert_file_buf[i] = g_assert_file[i]; } g_assert_line = line; #else u8 i; /* Infinite loop */ /*如果想顯示 line 和 file 必須去掉 while語句; 切換到上面的宏顯示*/ while (1) { #if 0 g_assert_file = file; for(i=0u;i<200u;i++) { g_assert_file_buf[i] = g_assert_file[i]; } g_assert_line = line; #else g_assert_line++; #endif //for(g_assert_file_buf) } #endif } /* End of function assert_failed*/ //#endif /* [] END OF FILE */