summaryrefslogtreecommitdiff
path: root/board/zinger/debug.c
blob: 2cf62996bf833b59d3fa32c3c2407a6302491241 (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
/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
/* Synchronous UART debug printf */

#include "common.h"
#include "printf.h"
#include "registers.h"
#include "util.h"

static int debug_txchar(void *context, int c)
{
	if (c == '\n') {
		while (!(STM32_USART_SR(UARTN) & STM32_USART_SR_TXE))
			;
		STM32_USART_TDR(UARTN) = '\r';
	}

	/* Wait for space to transmit */
	while (!(STM32_USART_SR(UARTN) & STM32_USART_SR_TXE))
		;
	STM32_USART_TDR(UARTN) = c;

	return 0;
}



void debug_printf(const char *format, ...)
{
	va_list args;

	va_start(args, format);
	vfnprintf(debug_txchar, NULL, format, args);
	va_end(args);
}

void panic(const char *msg)
{
}