mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 10:45:22 +00:00
Fix bug in which we were using the wrong index to the USART register macros. This bug was recently introduced in: https://chromium-review.googlesource.com/208488 BUG=none BRANCH=none TEST=load code on zinger and verify serial console works Change-Id: I03142a8cafb68e0cbbcba4b720e7ec89fe20110b Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/209557 Reviewed-by: Anton Staaf <robotboy@chromium.org>
38 lines
767 B
C
38 lines
767 B
C
/* 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_BASE) & STM32_USART_SR_TXE))
|
|
;
|
|
STM32_USART_TDR(UARTN_BASE) = '\r';
|
|
}
|
|
|
|
/* Wait for space to transmit */
|
|
while (!(STM32_USART_SR(UARTN_BASE) & STM32_USART_SR_TXE))
|
|
;
|
|
STM32_USART_TDR(UARTN_BASE) = 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);
|
|
}
|