|
|
1 #ifndef _LOG_H_
1 d$ K4 g5 g9 s) m 2 #define _LOG_H_0 z: N: R* h/ h1 K
3 2 s0 V7 e: R. P" v& `7 F4 K8 l
4 /* 0: printf; 1: UART1 */. j6 Q; g/ F7 D9 s X
5 #define OUTPUT_TO_UART1 18 k; U0 ~* o' v' v) @# h: I! Y
6 4 ~3 r& Q+ j/ A) R) q3 f4 B1 h
7 /* Switch Log Output */
& t8 g$ ~2 q6 B B0 }8 R H 8 #if OUTPUT_TO_UART1
+ p/ Q! X+ H" p5 s( h+ Y' T 9 /* For UART1 Initial */
2 s% b4 t( J3 W 10 #include <stdlib.h>7 [. }+ U$ u V' m
11 #include "hw_types.h"
, g, T3 c1 F, a, S6 l 12 #include "hw_syscfg0_C6748.h"
I! J6 Q& F- f5 d2 a' J 13 #include "soc_C6748.h"$ ]9 O7 V) w- _; g0 i, ~
14 #include "psc.h" 6 e( Z0 l5 J N% f4 }1 {3 I0 a
15 #include "gpio.h"
0 K( B2 h$ \" j6 h 16 #include "uart.h"
& s2 m% U/ m2 E S2 [ U M( ^3 | 17 #include "uartStdio.h"; g' [9 s" G8 N; p( L+ t& E3 x
18 # f* Z0 O5 l" F0 w* Y
19 #define OUTPUT UARTprintf3 p( s* m4 o: X2 M
20 #else
9 b+ C& F; {2 O1 X 21 #include <stdio.h>! ~) ^( A) Z1 e- R7 }* g; X% F
22 #include <stdbool.h>
' |5 {* w2 M2 }+ L1 Q 23 B6 ^5 A9 A9 z, T! g* Z8 o
24 #define OUTPUT printf* T5 c/ d' u) [* e- \! l; d
25 #endif
( G9 u: {8 R" U; H 26 ( c! C* Y& L# B3 q, J6 Z
27 /* Log init */
9 X9 b3 u% [6 w1 I! ~9 R+ v 28 #if OUTPUT_TO_UART1+ ]. P. l2 v* T, E
29 #define LOG_INIT() do { \
) A- e& j! Y- g. H) q/ r/ x6 p 30 PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, \2 u$ \! u5 M& B, W3 `. d, W5 _( }
31 PSC_POWERDOMAIN_ALWAYS_ON, \) k. G; h, \( W- Y x' E; s( B5 q
32 PSC_MDCTL_NEXT_ENABLE); \
9 ]% X5 H, D1 a3 q# t% y 33 GPIOBank6Pin12PinMuxSetup(); \; Z! m6 Z/ [: a; P b
34 GPIOBank6Pin13PinMuxSetup(); \# y- Q5 q2 t e/ A6 G$ c; ^, E
35 GPIODirModeSet(SOC_GPIO_0_REGS, 109, GPIO_DIR_OUTPUT); \. |# P" X7 ^# ?" K- M
36 GPIODirModeSet(SOC_GPIO_0_REGS, 110, GPIO_DIR_OUTPUT); \
5 H- k* C. [! S: m* T, V/ i0 L 37 UARTStdioInit(); \8 J% f- ]) H1 e4 T9 t8 c" k
38 } while (0)
7 f E5 A3 _ X! U W) J) V7 p 39 #else6 R1 ?$ D# J' ~+ g$ M% O
40 #define LOG_INIT() do { } while (0)
8 r) ~ T# V2 F 41 #endif) @( b* B% q( y
42 9 H' f1 p; j& f8 J
43 /* Log Output */
% I F0 I+ i; Z( I# r 44 #define LOG_INFO(format, ...) \ a' s8 ^1 v9 N M2 d+ v$ k
45 do { \
" n9 i- f$ r6 @+ N4 j& b7 U1 u 46 OUTPUT("[%s|%s@%s,%d] " format "\n", "INFO ", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \, U" j* t) k5 Q
47 } while (0)
/ t) v$ r; j n. A' g, t 48 ! M4 q1 ~ j$ Z* ~3 F# _
49 #define LOG_ERROR(format, ...) \) ?! s- c$ B |
50 do { \
0 v G" ^, v+ S 51 OUTPUT("[%s|%s@%s,%d] " format "\n", "ERROR", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \" s2 e2 ^5 N3 j9 f* u, |
52 } while (0)' M& \& ?1 _0 g S
53
; t# \0 D, |/ u1 A, Q* K( ? 54 #define LOG_DEBUG(format, ...) \( U7 a9 t" u+ @2 Y8 P
55 do { \, S& X! x8 a- @/ P
56 OUTPUT("[%s|%s@%s,%d] " format "\n", "DEBUG", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \ T$ Y( M% M T4 B
57 } while (0)) N, l1 O- A J2 S) E
58
1 d& J' t7 ~6 \ 59 #define LOG_WARN(format, ...) \
8 c ~, v; k2 @2 `7 F 60 do { \' U/ p: j& @0 d* S6 f- I x
61 OUTPUT("[%s|%s@%s,%d] " format "\n", "WRAN ", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
7 I, U8 v( M) o2 J% @) c 62 } while (0) S0 ?& p* X6 g2 G: Y- Z
63
+ h3 n4 O+ n u/ U% s 64 #define LOG_TRACE(format, ...) \7 g. C3 s0 C7 H" v
65 do { \! d, \0 R1 y# D `4 ]: W
66 OUTPUT("[%s|%s@%s,%d] " format "\n", "TRACE", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \
7 H6 u$ i( b0 v 67 } while (0)' t4 r( }2 D' M5 I: V% |6 r7 e# o+ i) r
68
- n/ I1 L0 C% X. _ 69 #define LOG_FATAL(format, ...) \% g6 b3 } {9 a6 t5 @, R
70 do { \6 {4 `; i$ x; N
71 OUTPUT("[%s|%s@%s,%d] " format "\n", "FATAL", __func__, __FILE__, __LINE__, ##__VA_ARGS__ ); \2 f) D$ G, A7 _- f5 g# } Q
72 exit(1); \4 F7 i8 `8 K# K( h
73 } while (0)
7 ?0 M7 L+ b8 z. Z# p" O+ D! q 74
! V; l6 [8 W# K* c) D 75 /* Assert */4 Y* [# E1 Y. p- D# M, i5 ~9 m
76 #define ASSERT(EXP) \: D! I8 F! G6 `; \' l
77 do{ \% x+ X( L9 A6 M% Z7 I4 ~
78 if (!(EXP)) { \
% ]. n' C6 ]# ^4 x9 x# R: {% E 79 OUTPUT("[%s@%s,%d] ASSERT: " #EXP "\n", __func__, __FILE__, __LINE__ ); \
, D' L! T7 U: a% R 80 exit(1); \2 N0 x) g" K$ ]1 `' M# |; x
81 } \8 F! C8 I' L( c
82 } while(0)5 ?, _ l r+ {
83 / d& q( z8 b& f( C3 S' T
84 #endif" ?4 ~, Y& T2 i# a4 k
|
|