Files
OpenCellular/board/keyborg/debug.c
Vic Yang 2478058b7a Emit error when board.h or config_chip.h is included before config.h
If board.h or config_chip.h is included before config.h, CONFIG_* flags
may be incorrect. For example, if config.h says:

    ...
  #define CONFIG_DEFINED_FLAG
    ...
  #include "board.h"
    ...

And board.h says:

  #ifndef __BOARD_H
  #define __BOARD_H
    ...
  #undef CONFIG_DEFINED_FLAG
    ...
  #endif

Then this code:

  #include "board.h"
  #include "config.h"

would results in CONFIG_DEFINED_FLAG being defined, instead of undefined
as stated in board.h.

Avoid this by emitting error when board.h or config_chip.h is included
before config.h.

BUG=None
TEST=make buildall
BRANCH=None

Change-Id: Ic4a8b68e8ab1ef2a4cf9e926ab9008d2b106b943
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203265
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-11 03:34:17 +00:00

50 lines
921 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 "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)
{
}