Skip to content

Commit 8a579df

Browse files
committed
add assert support
1 parent 600ccb7 commit 8a579df

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

lib/onchip/Util/Assert.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
#include "Assert.h"
3+
4+
//#define DEBUG_USE_USART
5+
6+
#ifdef DEBUG_USE_USART
7+
#include "USART.h"
8+
extern USART log;
9+
#define LOG(str) log<<str
10+
11+
#else
12+
#define LOG(str)
13+
#endif
14+
15+
void assert_failed(uint8_t* file, uint32_t line)
16+
{
17+
LOG("!!!!!assert fail!!!!!");
18+
LOG("\n==================\nfile:");
19+
LOG((const char*)file);
20+
LOG("\nline:");
21+
LOG((const char*)line);
22+
LOG("\n==================\n");
23+
while(1);
24+
}

lib/onchip/Util/Assert.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef __ASSERT_H
2+
#define __ASSERT_H
3+
4+
#ifdef __cplusplus
5+
extern "C"
6+
{
7+
#endif
8+
9+
#include "stm32f10x_conf.h"
10+
11+
#define assert(pass) assert_param(pass)
12+
13+
14+
#ifdef __cplusplus
15+
}
16+
#endif
17+
18+
#endif
19+

0 commit comments

Comments
 (0)