|
1 #ifndef _LOG_H_
* W1 P+ k% {9 y5 z# i) b 2 #define _LOG_H_
+ `$ }. r7 B+ Q9 ?) r- M) N, f 3 % K2 Q$ \3 i7 |: U
4 /* 0: printf; 1: UART1 */. k% A: h! w0 x; P" m U
5 #define OUTPUT_TO_UART1 1
& P2 W) R9 j7 U2 l: f" n% O 6 ( K' x7 x. n- Q0 U
7 /* Switch Log Output */" z6 p. g2 f# u6 `3 @
8 #if OUTPUT_TO_UART10 u" B# D( S# Y! a* p4 P
9 /* For UART1 Initial */
4 h" \, j0 Y. L2 I 10 #include <stdlib.h>
. f( d8 H K1 o9 o9 y 11 #include "hw_types.h" : M& m! n l1 ?- F$ |" A
12 #include "hw_syscfg0_C6748.h"
6 D* p" O! R' I7 O' F" r* g 13 #include "soc_C6748.h"3 u* [1 C4 |- r# g
14 #include "psc.h" 1 Q1 y! W, h; ^+ ^: g3 z3 q( s
15 #include "gpio.h"
0 e8 I5 m% T. p) o1 [. w1 B6 ~ 16 #include "uart.h"9 j8 i- j6 [+ T; h1 f
17 #include "uartStdio.h"2 x* o) n/ P' d+ E
18 & ]7 z: r3 r1 J% |* x, {
19 #define OUTPUT UARTprintf
. @( x t' m* [" N+ b) u3 p 20 #else
. E4 Y; |5 t/ C. j1 J1 R2 H 21 #include <stdio.h>
1 M; i! U% G! k 22 #include <stdbool.h>/ G) R E3 O4 K, B
23
j0 |4 K8 v h9 N7 N) T1 O5 d& Q 24 #define OUTPUT printf8 z Y4 m! P. J& s
25 #endif3 O. S' F- J8 {3 G' M
26
" U' w' a+ _$ G9 G 27 /* Log init */
2 u, f( ?0 a/ t6 |5 ~" }( K& W 28 #if OUTPUT_TO_UART1# L7 }. `5 G. p1 x% U# n% i9 L
29 #define LOG_INIT() do { \
. b6 G, s& G& M6 t 30 PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, \
5 l0 A6 ]- X. l; t4 c 31 PSC_POWERDOMAIN_ALWAYS_ON, \3 t5 Q8 D9 M' U: D4 z7 p0 r' C
32 PSC_MDCTL_NEXT_ENABLE); \
" g9 Q2 X) x) I6 \7 @7 F5 h 33 GPIOBank6Pin12PinMuxSetup(); \
4 g6 [( P# _) x2 q( V 34 GPIOBank6Pin13PinMuxSetup(); \
+ [# k* Q4 H( [' M 35 GPIODirModeSet(SOC_GPIO_0_REGS, 109, GPIO_DIR_OUTPUT); \
* E. x0 f" I. b: A% |" D( A 36 GPIODirModeSet(SOC_GPIO_0_REGS, 110, GPIO_DIR_OUTPUT); \( c3 h8 v4 Y# C
37 UARTStdioInit(); \
* |$ `+ P) F7 d9 T4 \* ^* W1 j 38 } while (0)
; \1 R, e- E) b9 ` 39 #else7 w9 O |3 D( R2 h; f) a6 H
40 #define LOG_INIT() do { } while (0)
4 G% {( J/ \5 V( y# r; y 41 #endif
' |7 L, X2 _1 T7 C 42
, O* c! x) Y j0 y 43 /* Log Output */. }9 ~& B! ]/ L' @* R
44 #define LOG_INFO(format, ...) \
3 g" F5 T( r& @$ g3 J# ? 45 do { \/ w8 N6 L7 T: w% N S
46 OUTPUT("[%s|%s@%s,%d] " format "\n", "INFO ", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \% D! e/ X l: ~
47 } while (0)0 u& _& w, q& X4 y" J+ C
48
- j$ C5 ]5 r" [+ _+ L9 O8 ]& @ 49 #define LOG_ERROR(format, ...) \( I9 N" o$ d. [$ K/ ?& K
50 do { \/ h& G0 B; z H5 k
51 OUTPUT("[%s|%s@%s,%d] " format "\n", "ERROR", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \. S/ u. S- S' E Y! u2 h
52 } while (0)" r; F# j' `& b2 }7 \2 n% V
53
$ V9 j# p+ Y; c3 o4 M( U 54 #define LOG_DEBUG(format, ...) \
( a- R v8 y9 b* D# y! G! r 55 do { \. U+ U9 n, Z# l4 F/ b' t# K
56 OUTPUT("[%s|%s@%s,%d] " format "\n", "DEBUG", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \, L; m( B& X# q
57 } while (0)) B% ]! ~' r% g5 e( o2 L4 V
58
! ^3 A% E1 x3 s1 h4 D 59 #define LOG_WARN(format, ...) \- c! k+ H, v; P3 V0 T' M
60 do { \
0 J: U0 b* }* J% k, i7 v 61 OUTPUT("[%s|%s@%s,%d] " format "\n", "WRAN ", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \$ k$ _& T9 u8 j: g4 V" T
62 } while (0)
{; o3 ^- [4 k4 |5 Z, @ 63
1 w! E8 ]' U# G- G" n$ ?* ~ 64 #define LOG_TRACE(format, ...) \# n& r# T: v+ ~# n% `
65 do { \& P/ n. X: B# ]* |9 ^$ S
66 OUTPUT("[%s|%s@%s,%d] " format "\n", "TRACE", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
' {7 t9 k- y0 n6 ]% q% N 67 } while (0)
) T6 f- w4 x/ A) Q+ |0 k: [ 68
/ U/ j# p4 T. e) w 69 #define LOG_FATAL(format, ...) \
% M$ @. ]# N+ a8 k6 ? 70 do { \" ~0 {; F/ I4 j
71 OUTPUT("[%s|%s@%s,%d] " format "\n", "FATAL", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \1 X1 y1 X0 p, x: _" G: }2 _
72 exit(1); \$ P) j8 f1 T/ `: B7 _! w0 l2 l* I
73 } while (0): @. `5 O3 z& Q. v: v) I
74 & F5 _; Z4 }! `+ Y- ?* h
75 /* Assert */* V& s' f0 L# o
76 #define ASSERT(EXP) \
2 c. U( i1 p3 A4 H1 d 77 do{ \6 |3 y9 } E; @0 n5 t9 C
78 if (!(EXP)) { \" ]9 f5 J, j2 V6 m
79 OUTPUT("[%s@%s,%d] ASSERT: " #EXP "\n", __func__, __FILE__, __LINE__ ); \
% i+ ~5 @6 n* W* t% f t% c 80 exit(1); \
1 H u, z& \9 P- l- g- P2 Z 81 } \
! a0 Q+ X I# {" m% q( @3 P2 \ 82 } while(0)# Q% p3 t+ h6 A! g7 t9 p8 X- P
83 + m! p7 u2 t. K/ {
84 #endif7 f: E7 T8 D, {! G0 h' q
|
|