|
1 #ifndef _LOG_H_7 f3 e2 v) D) n/ m
2 #define _LOG_H_
" P. I0 a' t7 X% p# a4 Y7 {8 t0 Q 3 9 @. ~# @3 N" i; p: b- @+ g# C
4 /* 0: printf; 1: UART1 */
4 I: U& j$ x3 m) Q5 W" {2 \' D% o& P 5 #define OUTPUT_TO_UART1 1
7 L6 t, A S% H6 I 6
, b8 _: V5 @$ u0 E+ ^& b 7 /* Switch Log Output */
) c4 ]! H# w+ Q/ @& x- u& P 8 #if OUTPUT_TO_UART12 g1 L1 c) l9 f* E# J, @6 y) C7 o
9 /* For UART1 Initial */
% O4 O) v7 [- D, j" g: ~ 10 #include <stdlib.h>
$ `& K% k" c3 e 11 #include "hw_types.h"
! G$ D) _4 Y+ O) G; v( F2 H& U) t 12 #include "hw_syscfg0_C6748.h"
7 E9 _0 _2 Q0 |6 Y6 L# Q5 D 13 #include "soc_C6748.h"
6 F- x, L; f+ b4 T 14 #include "psc.h" 1 K. C" y" Z( g
15 #include "gpio.h" ' H3 C+ P, o/ P, \5 b( x% g0 p8 N
16 #include "uart.h"
: m! M% c0 `" ]5 i 17 #include "uartStdio.h"
7 [) T* e3 |4 i- l1 q/ [" l& T 18
! W$ h" B8 z9 f1 c4 K 19 #define OUTPUT UARTprintf9 l$ P; T% l% `( o) w, s- _1 E8 Q
20 #else
( {* _- h3 Q$ w- K' K- C 21 #include <stdio.h>5 f' u, k7 p$ t" a/ r; I
22 #include <stdbool.h>
9 w9 ^" ^0 J& I 23 ; P& ~4 y6 P6 P, V# a5 S
24 #define OUTPUT printf; ^0 l- q3 s, P6 h
25 #endif& n: U0 G: G' w: j$ ]
26 e/ v/ p1 |0 W( q$ A3 L% d
27 /* Log init */
" w, I$ s O+ ]3 W( g! c+ i1 S9 k5 ^ 28 #if OUTPUT_TO_UART1. T ?$ X& _* n; v! G- k/ O
29 #define LOG_INIT() do { \! N: ^* u" [, N) d! Y# z2 f
30 PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, \; q: D2 n) ?$ M9 V
31 PSC_POWERDOMAIN_ALWAYS_ON, \
6 S' D0 E& V" f1 `5 k- ?" G 32 PSC_MDCTL_NEXT_ENABLE); \
; e& y1 ]; }. t4 K- ]$ o 33 GPIOBank6Pin12PinMuxSetup(); \
' y; {7 R/ c1 }0 R1 A 34 GPIOBank6Pin13PinMuxSetup(); \9 g/ x! h' H, M( e2 a: g" p: X
35 GPIODirModeSet(SOC_GPIO_0_REGS, 109, GPIO_DIR_OUTPUT); \
- f8 O! D$ P! o; c 36 GPIODirModeSet(SOC_GPIO_0_REGS, 110, GPIO_DIR_OUTPUT); \
7 V5 a& p9 t/ a; C 37 UARTStdioInit(); \2 E7 z, R" N- g$ N* W, N
38 } while (0) K& G5 m& S- k: Q, W( F4 [
39 #else& |! n$ b# Q- D( j
40 #define LOG_INIT() do { } while (0)
* k5 g5 c7 n+ f1 p& M 41 #endif
' d8 D- I& d: V3 Q# O9 b6 T 42
3 L$ }. l/ R- X% o& q% r8 ? 43 /* Log Output */. W3 A8 Z! T# W6 w9 m# z
44 #define LOG_INFO(format, ...) \
) L4 Q5 `. p$ V! @9 K 45 do { \
1 B. g, p: G g* y5 z6 C 46 OUTPUT("[%s|%s@%s,%d] " format "\n", "INFO ", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \/ Y4 y o0 Z+ c6 y1 n: G
47 } while (0)* [9 \- }5 A0 |8 Y( ]
48 , ~5 P5 I3 `2 S% u5 w! ]
49 #define LOG_ERROR(format, ...) \
) J; c* i3 N! W3 ?3 M 50 do { \
# Z2 r" \0 h$ B- g 51 OUTPUT("[%s|%s@%s,%d] " format "\n", "ERROR", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \3 R9 e( }5 C3 F
52 } while (0)
, b$ }" q1 J' H 53
! ~( l: }; Q) ]+ Q/ B5 A 54 #define LOG_DEBUG(format, ...) \
& a: ?( A9 m$ P c 55 do { \
( ~5 y: d6 a' V6 ?: Q( } 56 OUTPUT("[%s|%s@%s,%d] " format "\n", "DEBUG", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \# @4 o3 q8 E4 U3 j5 [6 k2 i* g
57 } while (0)
: N7 e0 ?. c+ X# R; l, l 58
& A' j+ Q# Q* R% Y$ U; B* ?+ ]2 X5 o 59 #define LOG_WARN(format, ...) \5 M& n4 `$ C! p! r: m
60 do { \
, I% g4 O/ j: }* p# {/ w% U; f 61 OUTPUT("[%s|%s@%s,%d] " format "\n", "WRAN ", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
- I4 r! j' H1 ? 62 } while (0)
3 L1 l- L$ }; R) f @1 v- { 63
: ^1 _& a' h+ H8 f1 n 64 #define LOG_TRACE(format, ...) \( n0 c. T) t: n6 H7 K: F2 k% ?3 K! K
65 do { \
& U7 v. W2 s, |' [" ? 66 OUTPUT("[%s|%s@%s,%d] " format "\n", "TRACE", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \; O+ s7 C- V: o! {
67 } while (0)& M# e, G8 w0 ^) B: d4 [3 I
68 + c% g3 R" `0 K; Z1 I$ ?9 ~
69 #define LOG_FATAL(format, ...) \
; P4 i7 L; A8 B* a* J" Z4 j7 V 70 do { \
6 e: x5 q: Q" E 71 OUTPUT("[%s|%s@%s,%d] " format "\n", "FATAL", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
5 _& Y$ y! t3 e' c 72 exit(1); \. Z" X- o$ Z; p- I p# y3 F, f3 u
73 } while (0)
9 H) e/ H; @5 I 74
; ^+ q1 R) i5 ~ 75 /* Assert */
% Y Z* }% Z1 | 76 #define ASSERT(EXP) \- ]8 S* u! d; l9 q$ J0 L4 N
77 do{ \
4 a% x0 L8 I+ r' T5 E5 A, w3 H 78 if (!(EXP)) { \1 N6 v* V2 c5 J- Q k5 Y7 p5 {/ [
79 OUTPUT("[%s@%s,%d] ASSERT: " #EXP "\n", __func__, __FILE__, __LINE__ ); \0 _& H S5 n; x9 ?- c6 x5 k
80 exit(1); \& m4 G: K( U3 f7 m6 V
81 } \
! N6 f) P3 |& I5 c ^& l 82 } while(0)5 X" e3 l3 d# W) i
83
( C' \9 [2 J+ A 84 #endif9 L& s9 Q, L( o+ e
|
|