mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-11 10:25:20 +00:00
We are running a minimal runtime with less overhead. This allows us to run UART at 38400 bps. Let's update the config for easier debugging. Also fix a potential underflow bug. BUG=None TEST=See debug output at 38400 bps BRANCH=None Change-Id: Ic9e4f9d545f5dbc4a0816a843b0f01a4cf219666 Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/196190 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
51 lines
940 B
C
51 lines
940 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.
|
|
*/
|
|
/* GPIO UART debug printf */
|
|
|
|
#include "board.h"
|
|
#include "common.h"
|
|
#include "printf.h"
|
|
#include "registers.h"
|
|
#include "timer.h"
|
|
#include "util.h"
|
|
|
|
#define BAUD 38400
|
|
#define BIT_PERIOD (1000000 / BAUD)
|
|
|
|
int debug_txchar(void *context, int c)
|
|
{
|
|
int i;
|
|
timestamp_t st;
|
|
int32_t d;
|
|
|
|
if (c == '\n')
|
|
debug_txchar(context, '\r');
|
|
|
|
c = (c << 1) | (1 << 9);
|
|
st = get_time();
|
|
for (i = 0; i < 10; ++i) {
|
|
STM32_GPIO_BSRR(GPIO_A) = 1 << ((c & 1) ? 15 : 31);
|
|
d = (int32_t)st.le.lo + BIT_PERIOD * (i + 1) - get_time().le.lo;
|
|
if (d > 0)
|
|
udelay(d);
|
|
c >>= 1;
|
|
}
|
|
|
|
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)
|
|
{
|
|
}
|