|
1 #ifndef _LOG_H_# M `) c. J0 I$ a1 ~
2 #define _LOG_H_3 {5 A- S' B. S7 ]. v
3 3 y! P8 `- T' W/ ^; u. q8 x
4 /* 0: printf; 1: UART1 */9 x# i6 Z' \1 R6 P
5 #define OUTPUT_TO_UART1 12 ~, C8 _0 h# k# \ h, y; p
6
: w( j0 X0 q+ [- {) c; f4 S9 N 7 /* Switch Log Output */
: C' Z% |7 F5 H) U, q 8 #if OUTPUT_TO_UART1
2 ~8 j+ L$ M6 n" R1 l- W ~. E 9 /* For UART1 Initial */! I/ l e8 W9 i
10 #include <stdlib.h>
9 s- y5 [+ @) h) Z4 F5 g c* H 11 #include "hw_types.h"
' i+ @+ m& _! P @ 12 #include "hw_syscfg0_C6748.h") B: X9 U. Z. S3 Y, L& U6 |
13 #include "soc_C6748.h"
B: V! h {: U2 s% ~: i' Q' K 14 #include "psc.h"
* w; g8 e& C1 X5 m/ O 15 #include "gpio.h" . s" f' K& x& h2 |# _ Q
16 #include "uart.h"* t' J6 Z+ _6 p7 e, {: a6 Y
17 #include "uartStdio.h". [. F) ~4 ^6 m5 R9 K6 K) N8 e
18
: s1 e. e0 _0 p/ j 19 #define OUTPUT UARTprintf5 W. k) |# l8 Z6 X! X
20 #else
6 a: y2 L% a1 W5 m2 W3 m 21 #include <stdio.h>
0 q4 w. q2 l( o% k$ R7 M, [ 22 #include <stdbool.h>
( X# ?* X( X0 U+ h9 s7 b- Q 23
# A6 @" F2 k4 s7 _1 ]( w2 m: K& x 24 #define OUTPUT printf& l( @3 U; o$ A- [: O! S( j
25 #endif8 I) c6 u1 J. I+ k8 f0 H7 _
26
/ h5 C: @3 L( E! f3 W 27 /* Log init */) T* }' \$ C+ W4 F" i2 i+ t# t
28 #if OUTPUT_TO_UART17 o* c- G- T& B
29 #define LOG_INIT() do { \3 c, @( q6 }, S2 H% S/ Y [
30 PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, \. A( n7 I C" _/ K9 {) M
31 PSC_POWERDOMAIN_ALWAYS_ON, \- I+ n3 B. `7 d; d `9 }/ A1 T
32 PSC_MDCTL_NEXT_ENABLE); \+ d. C: u/ ?3 w' s/ L6 q# s
33 GPIOBank6Pin12PinMuxSetup(); \
. `4 G7 n3 b; K2 Y 34 GPIOBank6Pin13PinMuxSetup(); \& b9 ]5 v1 d& l% d/ N
35 GPIODirModeSet(SOC_GPIO_0_REGS, 109, GPIO_DIR_OUTPUT); \& h& e% ~ A: W8 ? e
36 GPIODirModeSet(SOC_GPIO_0_REGS, 110, GPIO_DIR_OUTPUT); \
4 ~$ D# w1 E: Z 37 UARTStdioInit(); \. Q3 @2 \, m% }5 d# E
38 } while (0)
, C& P$ }4 H! A: G. a, H$ S' O/ z! ^0 F* | 39 #else5 E4 a3 L9 } u% z8 v# V
40 #define LOG_INIT() do { } while (0)
5 f' h* r6 n/ O2 x 41 #endif
9 ~' l% U/ c g: g0 h8 u. X 42 ; K" N5 B. G6 w+ e3 _
43 /* Log Output */
- s3 ]% [" V/ D$ b5 y. s( [ 44 #define LOG_INFO(format, ...) \
1 k& k* s6 C, c5 A' k7 u9 O 45 do { \
$ Z0 f' \$ T; Z8 L& n* u+ v 46 OUTPUT("[%s|%s@%s,%d] " format "\n", "INFO ", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
* p' [: W& n+ E+ R 47 } while (0): l+ G' l$ x. c+ a
48 & O4 m( Q/ o; P$ U, p
49 #define LOG_ERROR(format, ...) \1 [7 \9 P* B- F
50 do { \
' l9 A- c$ R6 @0 V 51 OUTPUT("[%s|%s@%s,%d] " format "\n", "ERROR", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
4 | e- c3 m4 o0 l' q) r* ?& O 52 } while (0)9 y/ @9 X) W- }& D: E: Z! ?! m: c
53
+ A7 ~0 H0 e" ^; C u5 T 54 #define LOG_DEBUG(format, ...) \7 X- m' |6 i# S2 ^! c( m
55 do { \
( C( t: B# \& g* T+ T" R 56 OUTPUT("[%s|%s@%s,%d] " format "\n", "DEBUG", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \2 n4 Z4 X* o/ i2 ^( ?- l {& n
57 } while (0)
: c) i7 O7 y M( B4 \ 58
/ t! ^! B0 Q, M' x 59 #define LOG_WARN(format, ...) \. ]& y3 w! h6 @9 w. M- Z B. O
60 do { \
8 W; U' J$ l+ }. t 61 OUTPUT("[%s|%s@%s,%d] " format "\n", "WRAN ", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \2 T! L! w- Z2 f }- V' q& u+ d
62 } while (0)
+ s* r6 C/ [1 X/ s3 k6 u0 Z 63
, x1 [$ q+ Y7 J$ h9 d 64 #define LOG_TRACE(format, ...) \5 i% l5 u8 }- x* B% B- ?# q- s
65 do { \
: `3 i/ S, p* ^* t( d( z A% L 66 OUTPUT("[%s|%s@%s,%d] " format "\n", "TRACE", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \5 g j" w4 u }$ X- ?9 G p
67 } while (0)/ T+ o/ L P0 I$ V3 J; E" d* T5 E p
68 / U' |' B7 L! u4 \
69 #define LOG_FATAL(format, ...) \
! E+ }' f0 M3 X3 S; t# @ 70 do { \
( A* V/ a9 K8 |7 ~ 71 OUTPUT("[%s|%s@%s,%d] " format "\n", "FATAL", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
# r% D) q: J* b3 y. }8 ]$ G 72 exit(1); \
3 i( N& w3 B- C1 ~, a 73 } while (0)
2 C/ y _3 P6 [7 m 74 ! K& p$ h( J+ R% R) t8 W/ }
75 /* Assert */6 G* U$ f3 Q9 J: a5 Q/ ^
76 #define ASSERT(EXP) \$ m# t3 {! r' F
77 do{ \
9 u6 f7 H6 p' f3 J7 @4 Y 78 if (!(EXP)) { \ A- {$ [ y7 h9 O8 j- B
79 OUTPUT("[%s@%s,%d] ASSERT: " #EXP "\n", __func__, __FILE__, __LINE__ ); \" q* M, K6 D7 K1 [/ q
80 exit(1); \- ?$ G, {; w3 n
81 } \
0 \# u& p0 P0 |- t" Y5 @/ ^ 82 } while(0)
3 ^& f9 z- {) e, ?* A5 l& [9 [ 83
( a- L, V- n* U0 Z 84 #endif
; @# m4 d* e6 o" f& [0 D |
|