diff options
Diffstat (limited to 'firmware/usrp3/include')
-rw-r--r-- | firmware/usrp3/include/ethernet.h | 5 | ||||
-rw-r--r-- | firmware/usrp3/include/trace.h | 82 |
2 files changed, 84 insertions, 3 deletions
diff --git a/firmware/usrp3/include/ethernet.h b/firmware/usrp3/include/ethernet.h index 52f14d05b..a6bacfcd0 100644 --- a/firmware/usrp3/include/ethernet.h +++ b/firmware/usrp3/include/ethernet.h @@ -31,7 +31,7 @@ typedef void (*ethernet_link_changed_callback_t)(int ethnum, int speed); /*! * \brief one time call to initialize ethernet */ -void xge_ethernet_init(const uint32_t eth); +void ethernet_init(const uint32_t eth); /*! * \brief Return number of ethernet interfaces @@ -44,8 +44,7 @@ void dump_mdio_regs(const uint8_t eth, uint32_t mdio_port); /*! * \brief Test status of SFP+ modules */ -void -xge_poll_sfpp_status(const uint32_t eth); +void poll_sfpp_status(const uint32_t eth); //! get the link status of eth (true for link up) bool ethernet_get_link_up(const uint32_t eth); diff --git a/firmware/usrp3/include/trace.h b/firmware/usrp3/include/trace.h new file mode 100644 index 000000000..0daa231fe --- /dev/null +++ b/firmware/usrp3/include/trace.h @@ -0,0 +1,82 @@ +// +// Copyright 2015 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_TRACE_H +#define INCLUDED_TRACE_H + +#include <stdint.h> +#include <stdbool.h> +#include <printf.h> + +/* + * Enables basic conditional tracing support + * If UHD_FW_TRACE_LEVEL is defined, all messages + * with a verbosity >= UHD_FW_TRACE_LEVEL will be + * printed. + * + * An alternate way of defining the level is the "TRACE_LEVEL" + * variable in cmake. (eg. -DTRACE_LEVEL=13). + */ +//#define UHD_FW_TRACE_LEVEL 13 + +typedef enum +{ + /* 0-9: Use for performance/restricted debugging */ + ERROR = 10, + WARN = 11, + INFO = 12, + /* 13-19: Use for general debugging */ + DEBUG = 20, //Verbose! +} trace_level_t; + +static inline int _trace_typecheck_conv(trace_level_t lvl) { + return (int)lvl; +} + +#define UHD_FW_PRINTF(...) printf(__VA_ARGS__) +#define UHD_FW_BEAUTIFY_LVL(lvl) "[" #lvl "] " + +/* + * UHD_FW_TRACE(<log level>, <message>) + * - Simple trace. Print the messages with the log level as the prefix and \n at the end + * + * UHD_FW_TRACE_FSTR(<log level>, <format string>, <args>) + * - Trace format string with the log level as the prefix and \n at the end + * + * UHD_FW_TRACE_SHORT(<log level>, <message>) + * - Simple trace. Print the messages without the log level prefix or \n at the end + * + * UHD_FW_TRACE_FSTR_SHORT(<log level>, <format string>, <args>) + * - Trace format string without the log level prefix or \n at the end + */ +#ifdef UHD_FW_TRACE_LEVEL + #define UHD_FW_TRACE(lvl, fmt) \ + if (UHD_FW_TRACE_LEVEL >= _trace_typecheck_conv(lvl)) UHD_FW_PRINTF(UHD_FW_BEAUTIFY_LVL(lvl) fmt "\r\n"); + #define UHD_FW_TRACE_FSTR(lvl, fmt, ...) \ + if (UHD_FW_TRACE_LEVEL >= _trace_typecheck_conv(lvl)) UHD_FW_PRINTF(UHD_FW_BEAUTIFY_LVL(lvl) fmt "\r\n", __VA_ARGS__); + #define UHD_FW_TRACE_SHORT(lvl, fmt) \ + if (UHD_FW_TRACE_LEVEL >= _trace_typecheck_conv(lvl)) UHD_FW_PRINTF(fmt); + #define UHD_FW_TRACE_FSTR_SHORT(lvl, fmt, ...) \ + if (UHD_FW_TRACE_LEVEL >= _trace_typecheck_conv(lvl)) UHD_FW_PRINTF(fmt, __VA_ARGS__); +#else + #define UHD_FW_TRACE(lvl, fmt) ; + #define UHD_FW_TRACE_FSTR(lvl, fmt, ...) ; + #define UHD_FW_TRACE_SHORT(lvl, fmt) ; + #define UHD_FW_TRACE_FSTR_SHORT(lvl, fmt, ...) ; +#endif + +#endif /* INCLUDED_TRACE_H */ |