2014-05-26 16:47:47 +02:00
|
|
|
/*
|
|
|
|
* Whatever is commonly used throughout USB code
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _USB_COMMON_H_
|
|
|
|
#define _USB_COMMON_H_
|
|
|
|
|
|
|
|
/* For commonly used: NULL, EXIT_*, and stuff like that */
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
/* Current printf implementation for dumping important messages */
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2014-06-04 15:40:00 +02:00
|
|
|
/* In case of verbose debug output, enable this: */
|
|
|
|
#if 0
|
2014-05-26 16:47:47 +02:00
|
|
|
#define DEBUG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* Standard output message *
|
|
|
|
*===========================================================================*/
|
|
|
|
#define USB_MSG(fmt, ...) \
|
|
|
|
do { \
|
|
|
|
printf("USBD: "); \
|
|
|
|
printf(fmt, ##__VA_ARGS__); \
|
|
|
|
printf("\n"); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* Debug helpers *
|
|
|
|
*===========================================================================*/
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define DEBUG_DUMP \
|
|
|
|
do { \
|
|
|
|
printf("USBD (DEBUG %s)\n", __func__); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define USB_DBG(fmt, ...) \
|
|
|
|
do { \
|
|
|
|
printf("USBD (DEBUG %s): ", __func__); \
|
|
|
|
printf(fmt, ##__VA_ARGS__); \
|
|
|
|
printf("\n"); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#else
|
2014-06-04 15:40:00 +02:00
|
|
|
#define DEBUG_DUMP ((void)0)
|
|
|
|
#define USB_DBG(fmt, ...) ((void)0)
|
2014-05-26 16:47:47 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* Assert for USB code *
|
|
|
|
*===========================================================================*/
|
|
|
|
#define USB_ASSERT(cond, otherwise) \
|
|
|
|
do { \
|
|
|
|
if(!(cond)) { \
|
2014-06-04 15:40:00 +02:00
|
|
|
USB_MSG("ASSERTION ERROR (%s:%d) - " \
|
|
|
|
otherwise, __func__, __LINE__); \
|
2014-05-26 16:47:47 +02:00
|
|
|
exit(EXIT_FAILURE); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* !_USB_COMMON_H_ */
|