From 6d592945a04fc3a2190fadfbc540bce978932202 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 24 Mar 2018 21:22:54 +0000 Subject: [PATCH] Use a single common dbg.h --- arch/cpu/cc2538/dbg.c | 1 - arch/cpu/cc2538/dbg.h | 89 ------------------- arch/platform/nrf52dk/dbg-io/dbg.h | 67 -------------- .../cpu/cc26xx-cc13xx => os/lib/dbg-io}/dbg.h | 25 +++--- os/lib/dbg-io/printf.c | 1 + os/lib/dbg-io/putchar.c | 1 + os/lib/dbg-io/puts.c | 1 + 7 files changed, 17 insertions(+), 168 deletions(-) delete mode 100644 arch/cpu/cc2538/dbg.h delete mode 100644 arch/platform/nrf52dk/dbg-io/dbg.h rename {arch/cpu/cc26xx-cc13xx => os/lib/dbg-io}/dbg.h (80%) diff --git a/arch/cpu/cc2538/dbg.c b/arch/cpu/cc2538/dbg.c index b97936feb..e95a6c94a 100644 --- a/arch/cpu/cc2538/dbg.c +++ b/arch/cpu/cc2538/dbg.c @@ -37,7 +37,6 @@ */ #include "contiki.h" -#include "dbg.h" #include "dev/uart.h" #include "usb/usb-serial.h" diff --git a/arch/cpu/cc2538/dbg.h b/arch/cpu/cc2538/dbg.h deleted file mode 100644 index d5ab51f9d..000000000 --- a/arch/cpu/cc2538/dbg.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/ - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/** - * \addtogroup cc2538 - * @{ - * - * \defgroup cc2538-char-io cc2538 Character I/O - * - * CPU-specific functions for debugging and SLIP I/O - * - * On the cc2538, character I/O can be directed over USB or UART. This is - * controlled by a series of configuration directives: - * - SLIP_ARCH_CONF_USB: Controls the operation of slip-arch. - * - DBG_CONF_USB: Controls all debugging output - * - * Defaults for those defines are set in contiki-conf.h - * @{ - * - * \file - * Header file for the cc2538 Debug I/O module - */ -#ifndef DBG_H_ -#define DBG_H_ - -#include "contiki.h" - -#include "usb/usb-serial.h" -/** - * \brief Print a stream of bytes - * \param seq A pointer to the stream - * \param len The number of bytes to print - * \return The number of printed bytes - * - * This function is an arch-specific implementation required by the dbg-io - * API in cpu/arm/common/dbg-io. It prints a stream of bytes over the - * peripheral used by the platform. - */ -unsigned int dbg_send_bytes(const unsigned char *seq, unsigned int len); - -/** - * \brief Flushes character output - * - * When debugging is sent over USB, this functions causes the USB - * driver to immediately TX the content of output buffers. When - * debugging is over UART, this function does nothing. - * - * There is nothing stopping you from using this macro in your code but - * normally, you won't have to. - */ -#if DBG_CONF_USB -#define dbg_flush() usb_serial_flush() -#else -#define dbg_flush() -#endif - -#endif /* DBG_H_ */ - -/** - * @} - * @} - */ diff --git a/arch/platform/nrf52dk/dbg-io/dbg.h b/arch/platform/nrf52dk/dbg-io/dbg.h deleted file mode 100644 index 5d9568270..000000000 --- a/arch/platform/nrf52dk/dbg-io/dbg.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, Nordic Semiconductor - * All rights reserved. - * -3 * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/** - * \addtogroup nrf52dk - * @{ - * - * \addtogroup nrf52dk-dbg-io Debug IO over UART - * @{ - * - * \file - * Header file for the debug module. - * \author - * Wojciech Bober - * - */ -#ifndef DBG_H_ -#define DBG_H_ -/*---------------------------------------------------------------------------*/ -#include "contiki.h" -/*---------------------------------------------------------------------------*/ -/** - * \brief Print a stream of bytes - * \param seq A pointer to the stream - * \param len The number of bytes to print - * \return The number of printed bytes - */ -unsigned int dbg_send_bytes(const unsigned char *seq, unsigned int len); -/** - * \brief Print a character to debug output - * \param c Character to print - * \return Printed character - */ -int dbg_putchar(int c); -/*---------------------------------------------------------------------------*/ -#endif /* DBG_H_ */ -/*---------------------------------------------------------------------------*/ -/** - * @} - * @} - */ diff --git a/arch/cpu/cc26xx-cc13xx/dbg.h b/os/lib/dbg-io/dbg.h similarity index 80% rename from arch/cpu/cc26xx-cc13xx/dbg.h rename to os/lib/dbg-io/dbg.h index 4460b6eb4..14f06fd31 100644 --- a/arch/cpu/cc26xx-cc13xx/dbg.h +++ b/os/lib/dbg-io/dbg.h @@ -1,10 +1,11 @@ /* - * Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (c) 2015, Nordic Semiconductor * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: + * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright @@ -27,18 +28,18 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ -/*---------------------------------------------------------------------------*/ /** - * \addtogroup cc26xx + * \addtogroup nrf52dk * @{ * - * \defgroup cc26xx-char-io CC13xx/CC26xx Character I/O - * - * CC13xx/CC26xx CPU-specific functions for debugging and SLIP I/O + * \addtogroup nrf52dk-dbg-io Debug IO over UART * @{ * * \file - * Header file for the CC13xx/CC26xx Debug I/O module + * Header file for the debug module. + * \author + * Wojciech Bober + * */ #ifndef DBG_H_ #define DBG_H_ @@ -50,12 +51,14 @@ * \param seq A pointer to the stream * \param len The number of bytes to print * \return The number of printed bytes - * - * This function is an arch-specific implementation required by the dbg-io - * API in cpu/arm/common/dbg-io. It prints a stream of bytes over the - * peripheral used by the platform. */ unsigned int dbg_send_bytes(const unsigned char *seq, unsigned int len); +/** + * \brief Print a character to debug output + * \param c Character to print + * \return Printed character + */ +int dbg_putchar(int c); /*---------------------------------------------------------------------------*/ #endif /* DBG_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/os/lib/dbg-io/printf.c b/os/lib/dbg-io/printf.c index 9a747d538..9749f1f7d 100644 --- a/os/lib/dbg-io/printf.c +++ b/os/lib/dbg-io/printf.c @@ -30,6 +30,7 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" +#include "lib/dbg-io/dbg.h" #include #include diff --git a/os/lib/dbg-io/putchar.c b/os/lib/dbg-io/putchar.c index 98a3617b2..11bb7b5e6 100644 --- a/os/lib/dbg-io/putchar.c +++ b/os/lib/dbg-io/putchar.c @@ -30,6 +30,7 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" +#include "lib/dbg-io/dbg.h" #include #include diff --git a/os/lib/dbg-io/puts.c b/os/lib/dbg-io/puts.c index 6332ae471..93d73d3a5 100644 --- a/os/lib/dbg-io/puts.c +++ b/os/lib/dbg-io/puts.c @@ -30,6 +30,7 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" +#include "lib/dbg-io/dbg.h" #include #include