mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
debugging macro fixes
This commit is contained in:
parent
387a4ab5f4
commit
814c2baf55
17 changed files with 208 additions and 64 deletions
27
BTD.cpp
27
BTD.cpp
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BTD.h"
|
#include "BTD.h"
|
||||||
#define DEBUG // Uncomment to print data for debugging
|
// #define DEBUG // Uncomment to print data for debugging -- NO! see message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
|
|
||||||
const uint8_t BTD::BTD_CONTROL_PIPE = 0;
|
const uint8_t BTD::BTD_CONTROL_PIPE = 0;
|
||||||
|
@ -217,30 +217,40 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
|
#endif
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
NotifyFailUnknownDevice(VID,PID);
|
#ifdef DEBUG
|
||||||
|
NotifyFailUnknownDevice(VID, PID);
|
||||||
|
#endif
|
||||||
pUsb->setAddr(bAddress, 0, 0); // Reset address
|
pUsb->setAddr(bAddress, 0, 0); // Reset address
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80);
|
||||||
#endif
|
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
@ -427,7 +437,7 @@ void BTD::HCI_event_task() {
|
||||||
|
|
||||||
case EV_REMOTE_NAME_COMPLETE:
|
case EV_REMOTE_NAME_COMPLETE:
|
||||||
if (!hcibuf[2]) { // check if reading is OK
|
if (!hcibuf[2]) { // check if reading is OK
|
||||||
for (uint8_t i = 0; i < min(sizeof(remote_name),sizeof(hcibuf)-9); i++)
|
for (uint8_t i = 0; i < min(sizeof (remote_name), sizeof (hcibuf) - 9); i++)
|
||||||
remote_name[i] = hcibuf[9 + i];
|
remote_name[i] = hcibuf[9 + i];
|
||||||
hci_event_flag |= HCI_FLAG_REMOTE_NAME_COMPLETE;
|
hci_event_flag |= HCI_FLAG_REMOTE_NAME_COMPLETE;
|
||||||
}
|
}
|
||||||
|
@ -941,15 +951,14 @@ void BTD::hci_pin_code_request_reply() {
|
||||||
hcibuf[8] = disc_bdaddr[5];
|
hcibuf[8] = disc_bdaddr[5];
|
||||||
if (pairWithWii) {
|
if (pairWithWii) {
|
||||||
hcibuf[9] = 6; // Pin length is the length of the Bluetooth address
|
hcibuf[9] = 6; // Pin length is the length of the Bluetooth address
|
||||||
if(wiiUProController) {
|
if (wiiUProController) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nParing with Wii U Pro Controller"), 0x80);
|
Notify(PSTR("\r\nParing with Wii U Pro Controller"), 0x80);
|
||||||
#endif
|
#endif
|
||||||
for(uint8_t i = 0; i < 6; i++)
|
for (uint8_t i = 0; i < 6; i++)
|
||||||
hcibuf[10 + i] = my_bdaddr[i]; // The pin is the Bluetooth dongles Bluetooth address backwards
|
hcibuf[10 + i] = my_bdaddr[i]; // The pin is the Bluetooth dongles Bluetooth address backwards
|
||||||
}
|
} else {
|
||||||
else {
|
for (uint8_t i = 0; i < 6; i++)
|
||||||
for(uint8_t i = 0; i < 6; i++)
|
|
||||||
hcibuf[10 + i] = disc_bdaddr[i]; // The pin is the Wiimote's Bluetooth address backwards
|
hcibuf[10 + i] = disc_bdaddr[i]; // The pin is the Wiimote's Bluetooth address backwards
|
||||||
}
|
}
|
||||||
for (uint8_t i = 16; i < 26; i++)
|
for (uint8_t i = 16; i < 26; i++)
|
||||||
|
|
22
PS3USB.cpp
22
PS3USB.cpp
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PS3USB.h"
|
#include "PS3USB.h"
|
||||||
#define DEBUG // Uncomment to print data for debugging
|
//#define DEBUG // Uncomment to print data for debugging -- NO! see message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers
|
//#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers
|
||||||
|
|
||||||
|
@ -221,25 +221,32 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
|
#endif
|
||||||
goto Fail;
|
goto Fail;
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
NotifyFailUnknownDevice(VID,PID);
|
#ifdef DEBUG
|
||||||
|
NotifyFailUnknownDevice(VID, PID);
|
||||||
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
Fail:
|
Fail:
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
|
||||||
#endif
|
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
@ -427,7 +434,7 @@ void PS3USB::setRumbleOff() {
|
||||||
|
|
||||||
void PS3USB::setRumbleOn(Rumble mode) {
|
void PS3USB::setRumbleOn(Rumble mode) {
|
||||||
if ((mode & 0x30) > 0x00) {
|
if ((mode & 0x30) > 0x00) {
|
||||||
uint8_t power[2] = { 0xff, 0x00 }; // Defaults to RumbleLow
|
uint8_t power[2] = {0xff, 0x00}; // Defaults to RumbleLow
|
||||||
if (mode == RumbleHigh) {
|
if (mode == RumbleHigh) {
|
||||||
power[0] = 0x00;
|
power[0] = 0x00;
|
||||||
power[1] = 0xff;
|
power[1] = 0xff;
|
||||||
|
@ -448,14 +455,17 @@ void PS3USB::setLedRaw(uint8_t value) {
|
||||||
writeBuf[9] = value;
|
writeBuf[9] = value;
|
||||||
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3USB::setLedOff(LED a) {
|
void PS3USB::setLedOff(LED a) {
|
||||||
writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1));
|
writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1));
|
||||||
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3USB::setLedOn(LED a) {
|
void PS3USB::setLedOn(LED a) {
|
||||||
writeBuf[9] |= (uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1);
|
writeBuf[9] |= (uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1);
|
||||||
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3USB::setLedToggle(LED a) {
|
void PS3USB::setLedToggle(LED a) {
|
||||||
writeBuf[9] ^= (uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1);
|
writeBuf[9] ^= (uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1);
|
||||||
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
|
||||||
|
|
14
XBOXRECV.cpp
14
XBOXRECV.cpp
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "XBOXRECV.h"
|
#include "XBOXRECV.h"
|
||||||
#define DEBUG // Uncomment to print data for debugging
|
//#define DEBUG // Uncomment to print data for debugging -- NO! see message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
||||||
|
|
||||||
|
@ -120,8 +120,8 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
bAddress = 0;
|
bAddress = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
Notify(PSTR("\r\nsetAddr: "), 0x80);
|
||||||
#endif
|
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
|
#endif
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
|
@ -218,26 +218,34 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
|
#endif
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailUnknownDevice(VID,PID);
|
NotifyFailUnknownDevice(VID,PID);
|
||||||
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
||||||
#endif
|
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
14
XBOXUSB.cpp
14
XBOXUSB.cpp
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "XBOXUSB.h"
|
#include "XBOXUSB.h"
|
||||||
#define DEBUG // Uncomment to print data for debugging
|
//#define DEBUG // Uncomment to print data for debugging -- NO! see message.h
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
||||||
|
|
||||||
|
@ -183,25 +183,33 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
FailUnknownDevice:
|
FailUnknownDevice:
|
||||||
NotifyFailUnknownDevice(VID,PID);
|
#ifdef DEBUG
|
||||||
|
NotifyFailUnknownDevice(VID, PID);
|
||||||
|
#endif
|
||||||
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
|
||||||
#endif
|
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
16
adk.cpp
16
adk.cpp
|
@ -227,33 +227,45 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetProto:
|
FailGetProto:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("\r\ngetProto:");
|
USBTRACE("\r\ngetProto:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSwAcc:
|
FailSwAcc:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("\r\nswAcc:");
|
USBTRACE("\r\nswAcc:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
SwAttempt:
|
SwAttempt:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("\r\nAccessory mode switch attempt");
|
USBTRACE("\r\nAccessory mode switch attempt");
|
||||||
// goto Fail;
|
#endif
|
||||||
|
|
||||||
//FailOnInit:
|
//FailOnInit:
|
||||||
// USBTRACE("OnInit:");
|
// USBTRACE("OnInit:");
|
||||||
// goto Fail;
|
// goto Fail;
|
||||||
|
|
12
cdcacm.cpp
12
cdcacm.cpp
|
@ -183,26 +183,38 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
12
cdcftdi.cpp
12
cdcftdi.cpp
|
@ -178,26 +178,38 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,26 +155,38 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ public:
|
||||||
|
|
||||||
template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
|
template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
|
||||||
void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
|
void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
|
||||||
#ifdef DEBUG
|
|
||||||
if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
|
if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug.
|
||||||
for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
|
for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) {
|
||||||
if(!byteCount) {
|
if(!byteCount) {
|
||||||
|
@ -56,7 +55,6 @@ void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __HEXDUMP_H__
|
#endif // __HEXDUMP_H__
|
||||||
|
|
16
hidboot.h
16
hidboot.h
|
@ -390,32 +390,44 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetProtocol:
|
FailSetProtocol:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("SetProto:");
|
USBTRACE("SetProto:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetIdle:
|
FailSetIdle:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("SetIdle:");
|
USBTRACE("SetIdle:");
|
||||||
goto Fail;
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,27 +221,39 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr();
|
NotifyFailGetDevDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
FailSetIdle:
|
FailSetIdle:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("SetIdle:");
|
USBTRACE("SetIdle:");
|
||||||
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,9 +174,10 @@ uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
||||||
|
|
||||||
FailGetDevDescr:
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetDevDescr(rcode);
|
NotifyFailGetDevDescr(rcode);
|
||||||
|
#endif
|
||||||
rcode = USB_ERROR_FailGetDevDescr;
|
rcode = USB_ERROR_FailGetDevDescr;
|
||||||
goto Fail;
|
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
Release();
|
Release();
|
||||||
|
@ -188,6 +189,7 @@ boolean BulkOnly::WriteProtected(uint8_t lun) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for write protect.
|
// Check for write protect.
|
||||||
|
|
||||||
uint8_t BulkOnly::Page3F(uint8_t lun) {
|
uint8_t BulkOnly::Page3F(uint8_t lun) {
|
||||||
uint8_t buf[192];
|
uint8_t buf[192];
|
||||||
for (int i = 0; i < 192; i++) {
|
for (int i = 0; i < 192; i++) {
|
||||||
|
@ -205,7 +207,7 @@ uint8_t BulkOnly::Page3F(uint8_t lun) {
|
||||||
Notify(PSTR(" "), 0x80);
|
Notify(PSTR(" "), 0x80);
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
if(WriteOk[lun]) {
|
if (WriteOk[lun]) {
|
||||||
Notify(PSTR(" Writes Allowed"), 0x80);
|
Notify(PSTR(" Writes Allowed"), 0x80);
|
||||||
} else {
|
} else {
|
||||||
Notify(PSTR(" Writes Denied"), 0x80);
|
Notify(PSTR(" Writes Denied"), 0x80);
|
||||||
|
@ -358,30 +360,44 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FailSetConfDescr:
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetConfDescr();
|
NotifyFailSetConfDescr();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailOnInit:
|
FailOnInit:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("OnInit:");
|
USBTRACE("OnInit:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetMaxLUN:
|
FailGetMaxLUN:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("GetMaxLUN:");
|
USBTRACE("GetMaxLUN:");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailInvalidSectorSize:
|
FailInvalidSectorSize:
|
||||||
|
#ifdef DEBUG
|
||||||
USBTRACE("Sector Size is NOT VALID: ");
|
USBTRACE("Sector Size is NOT VALID: ");
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailSetDevTblEntry:
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailSetDevTblEntry();
|
NotifyFailSetDevTblEntry();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
FailGetConfDescr:
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFailGetConfDescr();
|
NotifyFailGetConfDescr();
|
||||||
|
#endif
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
|
#ifdef DEBUG
|
||||||
NotifyFail(rcode);
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
Release();
|
Release();
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
@ -449,7 +465,6 @@ uint8_t BulkOnly::Poll() {
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t BulkOnly::GetMaxLUN(uint8_t *plun) {
|
uint8_t BulkOnly::GetMaxLUN(uint8_t *plun) {
|
||||||
uint8_t ret = pUsb->ctrlReq(bAddress, 0, bmREQ_MASSIN, MASS_REQ_GET_MAX_LUN, 0, 0, bIface, 1, 1, plun, NULL);
|
uint8_t ret = pUsb->ctrlReq(bAddress, 0, bmREQ_MASSIN, MASS_REQ_GET_MAX_LUN, 0, 0, bIface, 1, 1, plun, NULL);
|
||||||
|
|
||||||
|
@ -465,7 +480,7 @@ uint8_t BulkOnly::ClearEpHalt(uint8_t index) {
|
||||||
|
|
||||||
uint8_t ret = 0;
|
uint8_t ret = 0;
|
||||||
|
|
||||||
while(ret = (pUsb->ctrlReq(bAddress, 0, USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT,
|
while (ret = (pUsb->ctrlReq(bAddress, 0, USB_SETUP_HOST_TO_DEVICE | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_ENDPOINT,
|
||||||
USB_REQUEST_CLEAR_FEATURE, USB_FEATURE_ENDPOINT_HALT, 0, ((index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr), 0, 0, NULL, NULL))
|
USB_REQUEST_CLEAR_FEATURE, USB_FEATURE_ENDPOINT_HALT, 0, ((index == epDataInIndex) ? (0x80 | epInfo[index].epAddr) : epInfo[index].epAddr), 0, 0, NULL, NULL))
|
||||||
== 0x01) delay(6);
|
== 0x01) delay(6);
|
||||||
|
|
||||||
|
@ -490,6 +505,7 @@ uint8_t BulkOnly::Reset() {
|
||||||
#endif
|
#endif
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t BulkOnly::ResetRecovery() {
|
uint8_t BulkOnly::ResetRecovery() {
|
||||||
Notify(PSTR("\r\nResetRecovery\r\n"), 0x80);
|
Notify(PSTR("\r\nResetRecovery\r\n"), 0x80);
|
||||||
Notify(PSTR("-----------------\r\n"), 0x80);
|
Notify(PSTR("-----------------\r\n"), 0x80);
|
||||||
|
@ -821,7 +837,7 @@ uint8_t BulkOnly::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t block
|
||||||
|
|
||||||
uint8_t BulkOnly::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) {
|
uint8_t BulkOnly::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) {
|
||||||
if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA;
|
if (!LUNOk[lun]) return MASS_ERR_NO_MEDIA;
|
||||||
if(!WriteOk[lun]) return MASS_ERR_WRITE_PROTECTED;
|
if (!WriteOk[lun]) return MASS_ERR_WRITE_PROTECTED;
|
||||||
Notify(PSTR("\r\nWrite LUN:\t"), 0x80);
|
Notify(PSTR("\r\nWrite LUN:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (lun, 0x90);
|
PrintHex<uint8_t > (lun, 0x90);
|
||||||
//printf("LUN=%i LBA=%8.8X BLOCKS=%i SIZE=%i\r\n", lun, addr, blocks, bsize);
|
//printf("LUN=%i LBA=%8.8X BLOCKS=%i SIZE=%i\r\n", lun, addr, blocks, bsize);
|
||||||
|
@ -917,7 +933,7 @@ uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void
|
||||||
pcbw->bmReserved2 = 0;
|
pcbw->bmReserved2 = 0;
|
||||||
ErrorMessage<uint32_t > (PSTR("CBW.dCBWTag"), pcbw->dCBWTag);
|
ErrorMessage<uint32_t > (PSTR("CBW.dCBWTag"), pcbw->dCBWTag);
|
||||||
|
|
||||||
while((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw)) == hrBUSY) delay(1);
|
while ((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw)) == hrBUSY) delay(1);
|
||||||
|
|
||||||
ret = HandleUsbError(usberr, epDataOutIndex);
|
ret = HandleUsbError(usberr, epDataOutIndex);
|
||||||
//ret = HandleUsbError(pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw), epDataOutIndex);
|
//ret = HandleUsbError(pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw), epDataOutIndex);
|
||||||
|
@ -928,14 +944,14 @@ uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void
|
||||||
if (!write) {
|
if (!write) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
uint8_t rbuf[bytes];
|
uint8_t rbuf[bytes];
|
||||||
while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, rbuf)) == hrBUSY) delay(1);
|
while ((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, rbuf)) == hrBUSY) delay(1);
|
||||||
if (usberr == hrSUCCESS) ((USBReadParser*)buf)->Parse(bytes, rbuf, 0);
|
if (usberr == hrSUCCESS) ((USBReadParser*)buf)->Parse(bytes, rbuf, 0);
|
||||||
} else {
|
} else {
|
||||||
while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*)buf)) == hrBUSY) delay(1);
|
while ((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*)buf)) == hrBUSY) delay(1);
|
||||||
}
|
}
|
||||||
ret = HandleUsbError(usberr, epDataInIndex);
|
ret = HandleUsbError(usberr, epDataInIndex);
|
||||||
} else {
|
} else {
|
||||||
while((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, bytes, (uint8_t*)buf)) == hrBUSY) delay(1);
|
while ((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, bytes, (uint8_t*)buf)) == hrBUSY) delay(1);
|
||||||
ret = HandleUsbError(usberr, epDataOutIndex);
|
ret = HandleUsbError(usberr, epDataOutIndex);
|
||||||
}
|
}
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -949,7 +965,7 @@ uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void
|
||||||
bytes = sizeof (CommandStatusWrapper);
|
bytes = sizeof (CommandStatusWrapper);
|
||||||
int tries = 2;
|
int tries = 2;
|
||||||
while (tries--) {
|
while (tries--) {
|
||||||
while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*) & csw)) == hrBUSY) delay(1);
|
while ((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*) & csw)) == hrBUSY) delay(1);
|
||||||
if (!usberr) break;
|
if (!usberr) break;
|
||||||
ClearEpHalt(epDataInIndex);
|
ClearEpHalt(epDataInIndex);
|
||||||
//HandleUsbError(usberr, epDataInIndex);
|
//HandleUsbError(usberr, epDataInIndex);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#if !defined(__MASSTORAGE_H__)
|
#if !defined(__MASSTORAGE_H__)
|
||||||
#define __MASSTORAGE_H__
|
#define __MASSTORAGE_H__
|
||||||
|
|
||||||
#define DEBUG
|
|
||||||
|
|
||||||
//<RANT>
|
//<RANT>
|
||||||
// @Oleg -- Perhaps we need a central 'config.h', many of these includes and
|
// @Oleg -- Perhaps we need a central 'config.h', many of these includes and
|
||||||
|
@ -19,6 +18,7 @@
|
||||||
#include "usbhost.h"
|
#include "usbhost.h"
|
||||||
#include "usb_ch9.h"
|
#include "usb_ch9.h"
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
|
#include <message.h>
|
||||||
|
|
||||||
#if defined(ARDUINO) && ARDUINO >=100
|
#if defined(ARDUINO) && ARDUINO >=100
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
13
message.cpp
13
message.cpp
|
@ -15,14 +15,13 @@ Web : http://www.circuitsathome.com
|
||||||
e-mail : support@circuitsathome.com
|
e-mail : support@circuitsathome.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEBUG
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
// 0x80 is the default (i.e. trace) to turn off set this global to something lower.
|
// 0x80 is the default (i.e. trace) to turn off set this global to something lower.
|
||||||
// this allows for 126 other debugging levels.
|
// this allows for 126 other debugging levels.
|
||||||
// TO-DO: Allow assignment to a different serial port
|
// TO-DO: Allow assignment to a different serial port
|
||||||
int UsbDEBUGlvl = 0x80;
|
int UsbDEBUGlvl = 0x80;
|
||||||
|
|
||||||
void Notifyc(char c, int lvl) {
|
void E_Notifyc(char c, int lvl) {
|
||||||
if (UsbDEBUGlvl < lvl) return;
|
if (UsbDEBUGlvl < lvl) return;
|
||||||
#if defined(ARDUINO) && ARDUINO >=100
|
#if defined(ARDUINO) && ARDUINO >=100
|
||||||
Serial.print(c);
|
Serial.print(c);
|
||||||
|
@ -32,22 +31,23 @@ void Notifyc(char c, int lvl) {
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notify(char const * msg, int lvl) {
|
void E_Notify(char const * msg, int lvl) {
|
||||||
if (UsbDEBUGlvl < lvl) return;
|
if (UsbDEBUGlvl < lvl) return;
|
||||||
if (!msg) return;
|
if (!msg) return;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
while ((c = pgm_read_byte(msg++))) Notifyc(c, lvl);
|
while ((c = pgm_read_byte(msg++))) E_Notifyc(c, lvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyStr(char const * msg, int lvl) {
|
void E_NotifyStr(char const * msg, int lvl) {
|
||||||
if (UsbDEBUGlvl < lvl) return;
|
if (UsbDEBUGlvl < lvl) return;
|
||||||
if (!msg) return;
|
if (!msg) return;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
while (c = *msg++) Notifyc(c, lvl);
|
while (c = *msg++) E_Notifyc(c, lvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
void NotifyFailGetDevDescr(void) {
|
void NotifyFailGetDevDescr(void) {
|
||||||
Notify(PSTR("\r\ngetDevDescr"), 0x80);
|
Notify(PSTR("\r\ngetDevDescr"), 0x80);
|
||||||
}
|
}
|
||||||
|
@ -96,3 +96,4 @@ void NotifyFail(uint8_t rcode) {
|
||||||
PrintHex<uint8_t > (rcode, 0x80);
|
PrintHex<uint8_t > (rcode, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
31
message.h
31
message.h
|
@ -17,20 +17,24 @@ e-mail : support@circuitsathome.com
|
||||||
#if !defined(__MESSAGE_H__)
|
#if !defined(__MESSAGE_H__)
|
||||||
#define __MESSAGE_H__
|
#define __MESSAGE_H__
|
||||||
|
|
||||||
|
// uncomment to activate
|
||||||
|
#define DEBUG
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
extern int UsbDEBUGlvl;
|
extern int UsbDEBUGlvl;
|
||||||
|
|
||||||
#include "printhex.h"
|
#include "printhex.h"
|
||||||
|
void E_Notify(char const * msg, int lvl);
|
||||||
|
void E_NotifyStr(char const * msg, int lvl);
|
||||||
|
|
||||||
void Notify(char const * msg, int lvl);
|
|
||||||
void NotifyStr(char const * msg, int lvl);
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
#define Notify E_Notify
|
||||||
|
#define NotifyStr E_NotifyStr
|
||||||
void NotifyFailGetDevDescr(uint8_t reason);
|
void NotifyFailGetDevDescr(uint8_t reason);
|
||||||
void NotifyFailSetDevTblEntry(uint8_t reason);
|
void NotifyFailSetDevTblEntry(uint8_t reason);
|
||||||
void NotifyFailGetConfDescr(uint8_t reason);
|
void NotifyFailGetConfDescr(uint8_t reason);
|
||||||
|
|
||||||
void NotifyFailGetDevDescr(void);
|
void NotifyFailGetDevDescr(void);
|
||||||
void NotifyFailSetDevTblEntry(void);
|
void NotifyFailSetDevTblEntry(void);
|
||||||
void NotifyFailGetConfDescr(void);
|
void NotifyFailGetConfDescr(void);
|
||||||
|
@ -38,28 +42,37 @@ void NotifyFailSetConfDescr(void);
|
||||||
void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
|
void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
|
||||||
void NotifyFail(uint8_t rcode);
|
void NotifyFail(uint8_t rcode);
|
||||||
#else
|
#else
|
||||||
#define NotifyFailGetDevDescr()
|
#define Notify(...) ((void)0)
|
||||||
#define NotifyFailSetDevTblEntry()
|
#define NotifyStr(...) ((void)0)
|
||||||
#define NotifyFailGetConfDescr()
|
#define NotifyFailGetDevDescr(...) ((void)0)
|
||||||
#define NotifyFailSetConfDescr()
|
#define NotifyFailSetDevTblEntry(...) ((void)0)
|
||||||
#define NotifyFailUnknownDevice(VID, PID)
|
#define NotifyFailGetConfDescr(...) ((void)0)
|
||||||
#define NotifyFail(rcode)
|
#define NotifyFailGetDevDescr(...) ((void)0)
|
||||||
|
#define NotifyFailSetDevTblEntry(...) ((void)0)
|
||||||
|
#define NotifyFailGetConfDescr(...) ((void)0)
|
||||||
|
#define NotifyFailSetConfDescr(...) ((void)0)
|
||||||
|
#define NotifyFailUnknownDevice(...) ((void)0)
|
||||||
|
#define NotifyFail(...) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class ERROR_TYPE>
|
template <class ERROR_TYPE>
|
||||||
void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
|
void ErrorMessage(uint8_t level, char const * msg, ERROR_TYPE rcode = 0) {
|
||||||
|
#ifdef DEBUG
|
||||||
Notify(msg, level);
|
Notify(msg, level);
|
||||||
Notify(PSTR(": "), level);
|
Notify(PSTR(": "), level);
|
||||||
PrintHex<ERROR_TYPE > (rcode, level);
|
PrintHex<ERROR_TYPE > (rcode, level);
|
||||||
Notify(PSTR("\r\n"), level);
|
Notify(PSTR("\r\n"), level);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ERROR_TYPE>
|
template <class ERROR_TYPE>
|
||||||
void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
|
void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
|
||||||
|
#ifdef DEBUG
|
||||||
Notify(msg, 0x80);
|
Notify(msg, 0x80);
|
||||||
Notify(PSTR(": "), 0x80);
|
Notify(PSTR(": "), 0x80);
|
||||||
PrintHex<ERROR_TYPE > (rcode, 0x80);
|
PrintHex<ERROR_TYPE > (rcode, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "hexdump.h"
|
#include "hexdump.h"
|
||||||
|
|
|
@ -19,9 +19,9 @@ e-mail : support@circuitsathome.com
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "printhex.h"
|
|
||||||
#include "hexdump.h"
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
//#include "printhex.h"
|
||||||
|
//#include "hexdump.h"
|
||||||
|
|
||||||
#if defined(ARDUINO) && ARDUINO >=100
|
#if defined(ARDUINO) && ARDUINO >=100
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
17
printhex.h
17
printhex.h
|
@ -22,30 +22,36 @@ e-mail : support@circuitsathome.com
|
||||||
#else
|
#else
|
||||||
#include <WProgram.h>
|
#include <WProgram.h>
|
||||||
#endif
|
#endif
|
||||||
void Notifyc(char c, int lvl);
|
|
||||||
|
void E_Notifyc(char c, int lvl);
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintHex(T val, int lvl) {
|
void PrintHex(T val, int lvl) {
|
||||||
|
#ifdef DEBUG
|
||||||
int num_nibbles = sizeof(T) * 2;
|
int num_nibbles = sizeof(T) * 2;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
|
char v = 48 + (((val >> (num_nibbles - 1) * 4)) & 0x0f);
|
||||||
if(v > 57) v += 7;
|
if(v > 57) v += 7;
|
||||||
Notifyc(v, lvl);
|
E_Notifyc(v, lvl);
|
||||||
} while(--num_nibbles);
|
} while(--num_nibbles);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintBin(T val, int lvl) {
|
void PrintBin(T val, int lvl) {
|
||||||
|
#ifdef DEBUG
|
||||||
for(T mask = (((T) 1) << ((sizeof(T) << 3) - 1)); mask; mask >>= 1)
|
for(T mask = (((T) 1) << ((sizeof(T) << 3) - 1)); mask; mask >>= 1)
|
||||||
if(val & mask)
|
if(val & mask)
|
||||||
Notifyc('1', lvl);
|
E_Notifyc('1', lvl);
|
||||||
else
|
else
|
||||||
Notifyc('0', lvl);
|
E_Notifyc('0', lvl);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void SerialPrintHex(T val) {
|
void SerialPrintHex(T val) {
|
||||||
|
#ifdef DEBUG
|
||||||
int num_nibbles = sizeof(T) * 2;
|
int num_nibbles = sizeof(T) * 2;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -53,10 +59,12 @@ void SerialPrintHex(T val) {
|
||||||
if(v > 57) v += 7;
|
if(v > 57) v += 7;
|
||||||
Serial.print(v);
|
Serial.print(v);
|
||||||
} while(--num_nibbles);
|
} while(--num_nibbles);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void PrintHex2(Print *prn, T val) {
|
void PrintHex2(Print *prn, T val) {
|
||||||
|
#ifdef DEBUG
|
||||||
T mask = (((T) 1) << (((sizeof(T) << 1) - 1) << 2));
|
T mask = (((T) 1) << (((sizeof(T) << 1) - 1) << 2));
|
||||||
|
|
||||||
while(mask > 1) {
|
while(mask > 1) {
|
||||||
|
@ -66,6 +74,7 @@ void PrintHex2(Print *prn, T val) {
|
||||||
mask >>= 4;
|
mask >>= 4;
|
||||||
}
|
}
|
||||||
prn->print((T) val, HEX);
|
prn->print((T) val, HEX);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __PRINTHEX_H__
|
#endif // __PRINTHEX_H__
|
||||||
|
|
Loading…
Reference in a new issue