Browse Source

Fix print() & println() conflict with Arduino Print class

main
PaulStoffregen 7 years ago
parent
commit
f1bb020282
9 changed files with 77 additions and 64 deletions
  1. +49
    -48
      USBHost_t36.h
  2. +10
    -7
      ehci.cpp
  3. +2
    -0
      enumeration.cpp
  4. +3
    -0
      hid.cpp
  5. +3
    -0
      hub.cpp
  6. +2
    -1
      keyboard.cpp
  7. +2
    -0
      midi.cpp
  8. +4
    -4
      print.cpp
  9. +2
    -4
      serial.cpp

+ 49
- 48
USBHost_t36.h View File

static void followup_Error(void); static void followup_Error(void);
protected: protected:
#ifdef USBHOST_PRINT_DEBUG #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_(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_token(uint32_t token);
static void print(const Pipe_t *pipe);
static void print_(const Pipe_t *pipe);
static void print_driverlist(const char *name, const USBDriver *driver); static void print_driverlist(const char *name, const USBDriver *driver);
static void print_qh_list(const Pipe_t *list); static void print_qh_list(const Pipe_t *list);
static void print_hexbytes(const void *ptr, uint32_t len); static void print_hexbytes(const void *ptr, uint32_t len);
static void print(const char *s) { Serial.print(s); }
static void print(int n) { Serial.print(n); }
static void print(unsigned int n) { Serial.print(n); }
static void print(long n) { Serial.print(n); }
static void print(unsigned long n) { Serial.print(n); }
static void println(const char *s) { Serial.println(s); }
static void println(int n) { Serial.println(n); }
static void println(unsigned int n) { Serial.println(n); }
static void println(long n) { Serial.println(n); }
static void println(unsigned long n) { Serial.println(n); }
static void println() { Serial.println(); }
static void print(uint32_t n, uint8_t b) { Serial.print(n, b); }
static void println(uint32_t n, uint8_t b) { Serial.println(n, b); }
static void print(const char *s, int n, uint8_t b = DEC) {
static void print_(const char *s) { Serial.print(s); }
static void print_(int n) { Serial.print(n); }
static void print_(unsigned int n) { Serial.print(n); }
static void print_(long n) { Serial.print(n); }
static void print_(unsigned long n) { Serial.print(n); }
static void println_(const char *s) { Serial.println(s); }
static void println_(int n) { Serial.println(n); }
static void println_(unsigned int n) { Serial.println(n); }
static void println_(long n) { Serial.println(n); }
static void println_(unsigned long n) { Serial.println(n); }
static void println_() { Serial.println(); }
static void print_(uint32_t n, uint8_t b) { Serial.print(n, b); }
static void println_(uint32_t n, uint8_t b) { Serial.println(n, b); }
static void print_(const char *s, int n, uint8_t b = DEC) {
Serial.print(s); Serial.print(n, b); } Serial.print(s); Serial.print(n, b); }
static void print(const char *s, unsigned int n, uint8_t b = DEC) {
static void print_(const char *s, unsigned int n, uint8_t b = DEC) {
Serial.print(s); Serial.print(n, b); } Serial.print(s); Serial.print(n, b); }
static void print(const char *s, long n, uint8_t b = DEC) {
static void print_(const char *s, long n, uint8_t b = DEC) {
Serial.print(s); Serial.print(n, b); } Serial.print(s); Serial.print(n, b); }
static void print(const char *s, unsigned long n, uint8_t b = DEC) {
static void print_(const char *s, unsigned long n, uint8_t b = DEC) {
Serial.print(s); Serial.print(n, b); } Serial.print(s); Serial.print(n, b); }
static void println(const char *s, int n, uint8_t b = DEC) {
static void println_(const char *s, int n, uint8_t b = DEC) {
Serial.print(s); Serial.println(n, b); } Serial.print(s); Serial.println(n, b); }
static void println(const char *s, unsigned int n, uint8_t b = DEC) {
static void println_(const char *s, unsigned int n, uint8_t b = DEC) {
Serial.print(s); Serial.println(n, b); } Serial.print(s); Serial.println(n, b); }
static void println(const char *s, long n, uint8_t b = DEC) {
static void println_(const char *s, long n, uint8_t b = DEC) {
Serial.print(s); Serial.println(n, b); } Serial.print(s); Serial.println(n, b); }
static void println(const char *s, unsigned long n, uint8_t b = DEC) {
static void println_(const char *s, unsigned long n, uint8_t b = DEC) {
Serial.print(s); Serial.println(n, b); } Serial.print(s); Serial.println(n, b); }
friend class USBDriverTimer; // for access to print & println
#else #else
static void print(const Transfer_t *transfer) {}
static void print(const Transfer_t *first, const Transfer_t *last) {}
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_token(uint32_t token) {}
static void print(const Pipe_t *pipe) {}
static void print_(const Pipe_t *pipe) {}
static void print_driverlist(const char *name, const USBDriver *driver) {} static void print_driverlist(const char *name, const USBDriver *driver) {}
static void print_qh_list(const Pipe_t *list) {} static void print_qh_list(const Pipe_t *list) {}
static void print_hexbytes(const void *ptr, uint32_t len) {} 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 print(const char *s, int n, uint8_t b = DEC) {}
static void print(const char *s, unsigned int n, uint8_t b = DEC) {}
static void print(const char *s, long n, uint8_t b = DEC) {}
static void print(const char *s, unsigned long n, uint8_t b = DEC) {}
static void println(const char *s, int n, uint8_t b = DEC) {}
static void println(const char *s, unsigned int n, uint8_t b = DEC) {}
static void println(const char *s, long n, uint8_t b = DEC) {}
static void println(const char *s, unsigned long n, uint8_t b = DEC) {}
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 print_(const char *s, int n, uint8_t b = DEC) {}
static void print_(const char *s, unsigned int n, uint8_t b = DEC) {}
static void print_(const char *s, long n, uint8_t b = DEC) {}
static void print_(const char *s, unsigned long n, uint8_t b = DEC) {}
static void println_(const char *s, int n, uint8_t b = DEC) {}
static void println_(const char *s, unsigned int n, uint8_t b = DEC) {}
static void println_(const char *s, long n, uint8_t b = DEC) {}
static void println_(const char *s, unsigned long n, uint8_t b = DEC) {}
#endif #endif
static void mk_setup(setup_t &s, uint32_t bmRequestType, uint32_t bRequest, static void mk_setup(setup_t &s, uint32_t bmRequestType, uint32_t bRequest,
uint32_t wValue, uint32_t wIndex, uint32_t wLength) { uint32_t wValue, uint32_t wIndex, uint32_t wLength) {

+ 10
- 7
ehci.cpp View File

static void add_to_periodic_followup_list(Transfer_t *first, Transfer_t *last); static void add_to_periodic_followup_list(Transfer_t *first, Transfer_t *last);
static void remove_from_periodic_followup_list(Transfer_t *transfer); static void remove_from_periodic_followup_list(Transfer_t *transfer);


#define print USBHost::print_
#define println USBHost::println_

void USBHost::begin() void USBHost::begin()
{ {
// Teensy 3.6 has USB host power controlled by PTE6 // Teensy 3.6 has USB host power controlled by PTE6


void USBDriverTimer::start(uint32_t microseconds) void USBDriverTimer::start(uint32_t microseconds)
{ {
#if defined(USBHOST_PRINT_DEBUG) && 0
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);
#if 0
USBHost::print_("start_timer, us = ");
USBHost::print_(microseconds);
USBHost::print_(", driver = ");
USBHost::print_((uint32_t)driver, HEX);
USBHost::print_(", this = ");
USBHost::println_((uint32_t)this, HEX);
#endif #endif
if (!driver) return; if (!driver) return;
if (microseconds < 100) return; // minimum timer duration if (microseconds < 100) return; // minimum timer duration

+ 2
- 0
enumeration.cpp View File

static void pipe_set_maxlen(Pipe_t *pipe, uint32_t maxlen); static void pipe_set_maxlen(Pipe_t *pipe, uint32_t maxlen);
static void pipe_set_addr(Pipe_t *pipe, uint32_t addr); static void pipe_set_addr(Pipe_t *pipe, uint32_t addr);


#define print USBHost::print_
#define println USBHost::println_


// The main user function to cause internal state to update. Since we do // The main user function to cause internal state to update. Since we do
// almost everything with DMA and interrupts, the only work to do here is // almost everything with DMA and interrupts, the only work to do here is

+ 3
- 0
hid.cpp View File

// callbacks with the arriving data full decoded to data/usage // callbacks with the arriving data full decoded to data/usage
// pairs. // pairs.


#define print USBHost::print_
#define println USBHost::println_

void USBHIDParser::init() void USBHIDParser::init()
{ {
contribute_Pipes(mypipes, sizeof(mypipes)/sizeof(Pipe_t)); contribute_Pipes(mypipes, sizeof(mypipes)/sizeof(Pipe_t));

+ 3
- 0
hub.cpp View File

// begin responding to address zero. // begin responding to address zero.
volatile bool USBHub::reset_busy = false; volatile bool USBHub::reset_busy = false;


#define print USBHost::print_
#define println USBHost::println_

void USBHub::init() void USBHub::init()
{ {
contribute_Devices(mydevices, sizeof(mydevices)/sizeof(Device_t)); contribute_Devices(mydevices, sizeof(mydevices)/sizeof(Device_t));

+ 2
- 1
keyboard.cpp View File

{M(KEYPAD_PERIOD), 0x80 | M(KEY_DELETE), '.'} {M(KEYPAD_PERIOD), 0x80 | M(KEY_DELETE), '.'}
}; };



#define print USBHost::print_
#define println USBHost::println_


void KeyboardController::init() void KeyboardController::init()
{ {

+ 2
- 0
midi.cpp View File

#include <Arduino.h> #include <Arduino.h>
#include "USBHost_t36.h" // Read this header first for key info #include "USBHost_t36.h" // Read this header first for key info


#define print USBHost::print_
#define println USBHost::println_


void MIDIDevice::init() void MIDIDevice::init()
{ {

+ 4
- 4
print.cpp View File



#ifdef USBHOST_PRINT_DEBUG #ifdef USBHOST_PRINT_DEBUG


void USBHost::print(const Transfer_t *transfer)
void USBHost::print_(const Transfer_t *transfer)
{ {
if (!((uint32_t)transfer & 0xFFFFFFE0)) return; if (!((uint32_t)transfer & 0xFFFFFFE0)) return;
Serial.print("Transfer @ "); Serial.print("Transfer @ ");
Serial.println(); Serial.println();
} }


void USBHost::print(const Transfer_t *first, const Transfer_t *last)
void USBHost::print_(const Transfer_t *first, const Transfer_t *last)
{ {
Serial.print("Transfer Followup List "); Serial.print("Transfer Followup List ");
Serial.print((uint32_t)first, HEX); Serial.print((uint32_t)first, HEX);
} }
} }


void USBHost::print(const Pipe_t *pipe)
void USBHost::print_(const Pipe_t *pipe)
{ {
if (!((uint32_t)pipe & 0xFFFFFFE0)) return; if (!((uint32_t)pipe & 0xFFFFFFE0)) return;
Serial.print("Pipe "); Serial.print("Pipe ");
Serial.println(); Serial.println();
const Transfer_t *t = (Transfer_t *)pipe->qh.next; const Transfer_t *t = (Transfer_t *)pipe->qh.next;
while (((uint32_t)t & 0xFFFFFFE0)) { while (((uint32_t)t & 0xFFFFFFE0)) {
print(t);
print_(t);
t = (Transfer_t *)t->qtd.next; t = (Transfer_t *)t->qtd.next;
} }
//Serial.print(); //Serial.print();

+ 2
- 4
serial.cpp View File

#include <Arduino.h> #include <Arduino.h>
#include "USBHost_t36.h" // Read this header first for key info #include "USBHost_t36.h" // Read this header first for key info


// quick hack - ultimately USBHost print & println need to be renamed
#define print USBHost::print
#define println USBHost::println

#define print USBHost::print_
#define println USBHost::println_


/************************************************************/ /************************************************************/
// Initialization and claiming of devices & interfaces // Initialization and claiming of devices & interfaces

Loading…
Cancel
Save