Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
Beam Positoning Monitor - Gateware
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Beam Positoning Monitor - Gateware
Commits
f2f7be9d
Commit
f2f7be9d
authored
Apr 29, 2013
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
emb-sw/*: new debug macros
parent
b1590610
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
4 deletions
+55
-4
debug_subsys.h
embedded-sw/include/debug_subsys.h
+20
-0
debug_print.h
embedded-sw/lib/debug_print.h
+35
-4
No files found.
embedded-sw/include/debug_subsys.h
0 → 100644
View file @
f2f7be9d
/*
* Copyright (C) 2013 LNLS (www.lnls.br)
* Author: Lucas Russo <lucas.russo@lnls.br>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#ifndef _DEBUG_SUBSYS_
#define _DEBUG_SUBSYS_
#define DBG_GENERIC (0x1 << 4)
#define DBG_GPIO (0x2 << 4)
#define DBG_SPI (0x4 << 4)
#define DBG_I2C (0x8 << 4)
#define DBG_OWR (0x10 << 4)
#define DBG_ETH (0x20 << 4)
#define DBG_SUBSYS_ON (DBG_GENERIC | DBG_GPIO | DBG_SPI | DBG_I2C | DBG_OWR | DBG_ETH)
#endif
embedded-sw/lib/debug_print.h
View file @
f2f7be9d
...
...
@@ -10,15 +10,29 @@
#include <stdarg.h>
#include "pp-printf.h"
#include "debug_subsys.h"
void
debug_print
(
const
char
*
fmt
,
...);
//__attribute__((format(printf,1,2)));
/* temporary */
#define DBG_MIN_LEVEL DBE_DBG_INFO
/* Debug levels */
#define DBE_DBG_TRACE (0x1 << 1)
#define DBE_DBG_INFO (0x2 << 1)
#define DBE_DBG_WARN (0x3 << 1)
#define DBE_DBG_ERR (0x4 << 1)
#define DBE_DBG_FATAL (0x5 << 1)
#define DBE_DBG_MASK (0xF << 1)
/* Debug halt */
#define DBE_DBG_HALT (0x1)
void
debug_print
(
const
char
*
fmt
,
...);
void
debug_print2
(
const
char
*
fmt
,
const
char
*
data
,
int
len
);
#ifdef D
EBUG_PRINT
#ifdef D
BE_DBG
#define dbg_print(fmt, ...) \
pp_printf("%s
: %s (%d): "fmt, __FILE__
, __FUNCTION__, __LINE__, ##__VA_ARGS__)
pp_printf("%s
(%d): "fmt
, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define dbg_print2(fmt, data, len) \
debug_print2(fmt, data, len)
#else
...
...
@@ -26,4 +40,21 @@ void debug_print2(const char *fmt, const char *data, int len);
#define dbg_print2(fmt, data, len)
#endif
/* dbg has the following format:
* 31 - 4 3 - 1 0-0
* DBG_SUBSYS DBG_LVL DBG_HALT
*/
#ifdef DBE_DBG
#define DBE_DEBUG(dbg, fmt, ...) do { if (((dbg) & DBG_SUBSYS_ON) && (((dbg) & DBE_DBG_MASK) >= DBG_MIN_LEVEL)) { dbg_print(fmt, ##__VA_ARGS__); if ((dbg) & DBE_DBG_HALT) while(1); } } while(0)
#define DBE_DEBUG_ARRAY(dbg, fmt, ...) do { if (((dbg) & DBG_SUBSYS_ON) && (((dbg) & DBE_DBG_MASK) >= DBG_MIN_LEVEL)) { dbg_print2(fmt, ##__VA_ARGS__); if ((dbg) & DBE_DBG_HALT) while(1); } } while(0)
#define DBE_ERR(...) do { dbg_print(fmt, ##__VA_ARGS__); } while(0)
#else
/* DBE_DEBUG */
#define DBE_DEBUG(dbg, fmt, ...)
#define DBE_DEBUG_ARRAY(dbg, fmt, ...)
#define DBE_ERR(...)
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment