浏览代码

Add define to enable/disable all debug printing

main
PaulStoffregen 7 年前
父节点
当前提交
b18ee4ea06
共有 3 个文件被更改,包括 37 次插入0 次删除
  1. +33
    -0
      USBHost.h
  2. +2
    -0
      ehci.cpp
  3. +2
    -0
      print.cpp

+ 33
- 0
USBHost.h 查看文件

@@ -26,6 +26,8 @@

#include <stdint.h>

#define USBHOST_PRINT_DEBUG

/************************************************/
/* Data Structure Definitions */
/************************************************/
@@ -182,6 +184,7 @@ private:
uint32_t maxlen, uint32_t interval);
static void add_qh_to_periodic_schedule(Pipe_t *pipe);
protected:
#ifdef USBHOST_PRINT_DEBUG
static void print(const Transfer_t *transfer);
static void print(const Transfer_t *first, const Transfer_t *last);
static void print_token(uint32_t token);
@@ -218,6 +221,36 @@ protected:
Serial.print(s); Serial.println(n, b); }
static void println(const char *s, unsigned long n, uint8_t b) {
Serial.print(s); Serial.println(n, b); }
#else
static void print(const Transfer_t *transfer) {}
static void print(const Transfer_t *first, const Transfer_t *last) {}
static void print_token(uint32_t token) {}
static void print(const Pipe_t *pipe) {}
static void print_driverlist(const char *name, const USBDriver *driver) {}
static void print_qh_list(const Pipe_t *list) {}
static void print_hexbytes(const void *ptr, uint32_t len) {}
static void print(const char *s) {}
static void print(int n) {}
static void print(unsigned int n) {}
static void print(long n) {}
static void print(unsigned long n) {}
static void println(const char *s) {}
static void println(int n) {}
static void println(unsigned int n) {}
static void println(long n) {}
static void println(unsigned long n) {}
static void println() {}
static void print(uint32_t n, uint8_t b) {}
static void println(uint32_t n, uint8_t b) {}
static void println(const char *s, int n) {}
static void println(const char *s, unsigned int n) {}
static void println(const char *s, long n) {}
static void println(const char *s, unsigned long n) {}
static void println(const char *s, int n, uint8_t b) {}
static void println(const char *s, unsigned int n, uint8_t b) {}
static void println(const char *s, long n, uint8_t b) {}
static void println(const char *s, unsigned long n, uint8_t b) {}
#endif

static void mk_setup(setup_t &s, uint32_t bmRequestType, uint32_t bRequest,
uint32_t wValue, uint32_t wIndex, uint32_t wLength) {

+ 2
- 0
ehci.cpp 查看文件

@@ -347,12 +347,14 @@ void USBHost::isr()

void USBDriverTimer::start(uint32_t microseconds)
{
#ifdef USBHOST_PRINT_DEBUG
Serial.print("start_timer, us = ");
Serial.print(microseconds);
Serial.print(", driver = ");
Serial.print((uint32_t)driver, HEX);
Serial.print(", this = ");
Serial.println((uint32_t)this, HEX);
#endif
if (!driver) return;
if (microseconds < 100) return; // minimum timer duration
started_micros = micros();

+ 2
- 0
print.cpp 查看文件

@@ -24,6 +24,7 @@
#include <Arduino.h>
#include "USBHost.h"

#ifdef USBHOST_PRINT_DEBUG

void USBHost::print(const Transfer_t *transfer)
{
@@ -178,3 +179,4 @@ void USBHost::print_hexbytes(const void *ptr, uint32_t len)
Serial.println();
}

#endif

正在加载...
取消
保存