summaryrefslogtreecommitdiff
path: root/serial.h
blob: 86246092ccac6b05a9e18514a5daccbe0365087b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 *  XIOH power sequence
 *  Copyright (C) 2013  Avencall
 *
 *  serial.h - traces to serial console
 *  Authors:
 *    Guillaume Knispel
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef SERIAL_H
#define SERIAL_H

#include "config.h"

#ifdef TRACE_SERIAL

#ifdef TEST_LOOP_SPEED
#define TL_WAIT   0
#define TL_COUNT  -1
#define TL_SAVED  -2
extern u8 tl_delta;
extern s8 tl_state;
extern u16 tl_num;
extern u16 ref_Timer_A_count;

u16 tl_emit(void);

#define TRACE_WHAT(ms, loops)   (loops)

#else /* ndef TEST_LOOP_SPEED: */

#define TRACE_WHAT(ms, loops)   (ms)

#endif /* TEST_LOOP_SPEED */

void SerialInit(void);

void serial_puts(const char *s);

void trace(u16 tstamp, u8 state, u8 infos);

#define trace_state(ns)						\
	do {							\
		u8 s3inreg_ = SLP_S3_N(inreg);			\
		trace(TRACE_WHAT(Timer_A_count, tl_emit()),	\
		      (ns), s3inreg_ & SLP_S3_N(bit));		\
	} while (0)

void trace_changes(u8 state);

void dump_trace(void);

#else /* ndef TRACE_SERIAL */

#define trace_state(ns)		do { } while (0)
#define trace_changes(state)	do { } while (0)

#endif /* TRACE_SERIAL */

#endif /* SERIAL_H */