Janitorial, whitespace fixes. No new code.

This commit is contained in:
Andrew J. Kroll 2013-12-25 05:09:57 -05:00
parent b8fb19fb90
commit f1af9b08ec
54 changed files with 1370 additions and 1310 deletions

5
BTD.h
View file

@ -262,12 +262,15 @@ public:
virtual bool isReady() {
return bPollEnable;
};
/**
* Used by the USB core to check what this driver support.
* @param klass The device's USB class.
* @return Returns true if the device's USB class matches this driver.
*/
virtual boolean DEVCLASSOK(uint8_t klass) { return (klass == USB_CLASS_WIRELESS_CTRL); }
virtual boolean DEVCLASSOK(uint8_t klass) {
return (klass == USB_CLASS_WIRELESS_CTRL);
}
/**
* Used by the USB core to check what this driver support.

View file

@ -22,8 +22,7 @@
BTHID::BTHID(BTD *p, bool pair, const char *pin) :
pBtd(p), // pointer to USB class instance - mandatory
protocolMode(HID_BOOT_PROTOCOL)
{
protocolMode(HID_BOOT_PROTOCOL) {
for(uint8_t i = 0; i < NUM_PARSERS; i++)
pRptParser[i] = NULL;
@ -376,6 +375,7 @@ void BTHID::Run() {
/************************************************************/
/* HID Commands */
/************************************************************/
void BTHID::setProtocol() {
#ifdef DEBUG_USB_HOST

View file

@ -48,6 +48,7 @@ public:
virtual void Reset();
/** Used this to disconnect any of the controllers. */
virtual void disconnect();
/**@}*/
HIDReportParser *GetReportParser(uint8_t id) {

View file

@ -143,6 +143,7 @@ public:
* @param value See: ::LED enum.
*/
void setLedRaw(uint8_t value);
/** Turn all LEDs off. */
void setLedOff() {
setLedRaw(0);

View file

@ -220,6 +220,7 @@ public:
* @param value See: ::LED enum.
*/
void setLedRaw(uint8_t value);
/** Turn all LEDs off. */
void setLedOff() {
setLedRaw(0);

View file

@ -723,18 +723,22 @@ bool SPP::checkFcs(uint8_t *data, uint8_t fcs) {
/* Serial commands */
#if defined(ARDUINO) && ARDUINO >=100
size_t SPP::write(uint8_t data) {
return write(&data, 1);
}
#else
void SPP::write(uint8_t data) {
write(&data, 1);
}
#endif
#if defined(ARDUINO) && ARDUINO >=100
size_t SPP::write(const uint8_t *data, size_t size) {
#else
void SPP::write(const uint8_t *data, size_t size) {
#endif
for(uint8_t i = 0; i < size; i++) {

1
SPP.h
View file

@ -98,6 +98,7 @@ public:
* @return Return the number of bytes ready to be read.
*/
virtual int available(void);
/** Send out all bytes in the buffer. */
virtual void flush(void) {
send();

View file

@ -229,8 +229,8 @@ uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, ui
*nbytesptr = 0;
regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
while (1) // use a 'return' to exit this loop
{
// use a 'break' to exit this loop
while(1) {
rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS.
if(rcode == hrTOGERR) {
// yes, we flip it wrong here so that next time it is actually correct!
@ -807,4 +807,3 @@ uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) {
}
#endif // defined(USB_METHODS_INLINE)

View file

@ -104,14 +104,38 @@ typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega
class USBDeviceConfig {
public:
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed) { return 0; }
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {return 0; }
virtual uint8_t Release() { return 0; }
virtual uint8_t Poll() { return 0; }
virtual uint8_t GetAddress() { return 0; }
virtual void ResetHubPort(uint8_t port) { return; } // Note used for hubs only!
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { return false; }
virtual boolean DEVCLASSOK(uint8_t klass) { return false; }
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0;
}
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
return 0;
}
virtual uint8_t Release() {
return 0;
}
virtual uint8_t Poll() {
return 0;
}
virtual uint8_t GetAddress() {
return 0;
}
virtual void ResetHubPort(uint8_t port) {
return;
} // Note used for hubs only!
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
return false;
}
virtual boolean DEVCLASSOK(uint8_t klass) {
return false;
}
};
/* USB Setup Packet Structure */
@ -251,4 +275,3 @@ inline uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) {
#endif // defined(USB_METHODS_INLINE)
#endif /* USBCORE_H */

View file

@ -878,6 +878,7 @@ void WII::setLedRaw(uint8_t value) {
HIDBuffer[2] = value | (HIDBuffer[2] & 0x01); // Keep the rumble bit
HID_Command(HIDBuffer, 3);
}
void WII::setLedOff(LED a) {
HIDBuffer[1] = 0x11;
HIDBuffer[2] &= ~(pgm_read_byte(&LEDS[(uint8_t)a]));

7
Wii.h
View file

@ -85,6 +85,7 @@ public:
/**@}*/
/** @name Wii Controller functions */
/** Call this to start the paring sequence with a controller */
void pair(void) {
if(pBtd)
@ -147,6 +148,7 @@ public:
* @param value See: ::LED enum.
*/
void setLedRaw(uint8_t value);
/** Turn all LEDs off. */
void setLedOff() {
setLedRaw(0);
@ -180,6 +182,7 @@ public:
* @return The battery level in the range 0-255.
*/
uint8_t getBatteryLevel();
/**
* Return the Wiimote state.
* @return See: http://wiibrew.org/wiki/Wiimote#0x20:_Status.
@ -211,20 +214,24 @@ public:
/* IMU Data, might be usefull if you need to do something more advanced than just calculating the angle */
/**@{*/
/** Pitch and roll calculated from the accelerometer inside the Wiimote. */
double getWiimotePitch() {
return (atan2(accYwiimote, accZwiimote) + PI) * RAD_TO_DEG;
};
double getWiimoteRoll() {
return (atan2(accXwiimote, accZwiimote) + PI) * RAD_TO_DEG;
};
/**@}*/
/**@{*/
/** Pitch and roll calculated from the accelerometer inside the Nunchuck. */
double getNunchuckPitch() {
return (atan2(accYnunchuck, accZnunchuck) + PI) * RAD_TO_DEG;
};
double getNunchuckRoll() {
return (atan2(accXnunchuck, accZnunchuck) + PI) * RAD_TO_DEG;
};

View file

@ -111,6 +111,7 @@ class AddressPoolImpl : public AddressPool {
};
// Returns thePool index for a given address
uint8_t FindAddressIndex(uint8_t address = 0) {
for(uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++) {
if(thePool[i].address.devAddress == address)
@ -120,6 +121,7 @@ class AddressPoolImpl : public AddressPool {
};
// Returns thePool child index for a given parent
uint8_t FindChildIndex(UsbDeviceAddress addr, uint8_t start = 1) {
for(uint8_t i = (start < 1 || start >= MAX_DEVICES_ALLOWED) ? 1 : start; i < MAX_DEVICES_ALLOWED; i++) {
if(thePool[i].address.bmParent == addr.bmAddress)
@ -129,6 +131,7 @@ class AddressPoolImpl : public AddressPool {
};
// Frees address entry specified by index parameter
void FreeAddressByIndex(uint8_t index) {
// Zero field is reserved and should not be affected
if(index == 0)
@ -148,6 +151,7 @@ class AddressPoolImpl : public AddressPool {
}
// Initializes the whole address pool at once
void InitAllAddresses() {
for(uint8_t i = 1; i < MAX_DEVICES_ALLOWED; i++)
InitEntry(i);
@ -172,6 +176,7 @@ public:
};
// Returns a pointer to a specified address entry
virtual UsbDevice* GetUsbDevicePtr(uint8_t addr) {
if(!addr)
return thePool;
@ -182,6 +187,7 @@ public:
};
// Performs an operation specified by pfunc for each addressed device
void ForEachUsbDevice(UsbDeviceHandleFunc pfunc) {
if(!pfunc)
return;
@ -192,6 +198,7 @@ public:
};
// Allocates new address
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub = false, uint8_t port = 0) {
/* if (parent != 0 && port == 0)
USB_HOST_SERIAL.println("PRT:0"); */
@ -243,6 +250,7 @@ public:
};
// Empties pool entry
virtual void FreeAddress(uint8_t addr) {
// if the root hub is disconnected all the addresses should be initialized
if(addr == 0x41) {

View file

@ -114,8 +114,7 @@ typedef struct {
uint8_t bDataBits; // Data bits (5, 6, 7, 8 or 16)
} LINE_CODING;
typedef struct
{
typedef struct {
uint8_t bmRequestType; // 0xa1 for class-specific notifications
uint8_t bNotification;
uint16_t wValue;

View file

@ -208,5 +208,3 @@ Fail:
// //}
// return rcode;
//}

View file

@ -58,7 +58,10 @@ class ConfigDescParser : public USBReadParser {
void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc);
public:
void SetOR(void) { UseOr = true; }
void SetOR(void) {
UseOr = true;
}
ConfigDescParser(UsbConfigXtracter *xtractor);
virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset);
};
@ -75,7 +78,6 @@ UseOr(false) {
theSkipper.Initialize(&theBuffer);
};
template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>
void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset) {
uint16_t cntdn = (uint16_t)len;

View file

@ -1,6 +1,7 @@
#include "hid.h"
//get HID report descriptor
/* WRONG! Endpoint is _ALWAYS_ ZERO for HID! We want the _INTERFACE_ value here!
uint8_t HID::GetReportDescr(uint8_t ep, USBReadParser *parser) {
const uint8_t constBufLen = 64;

1
hid.h
View file

@ -140,7 +140,6 @@ public:
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) = 0;
};
class HID : public USBDeviceConfig, public UsbConfigXtracter {
protected:
USB *pUsb; // USB class instance pointer

View file

@ -126,8 +126,7 @@ public:
itemPrefix(0),
rptSize(0),
rptCount(0),
pfUsage(NULL)
{
pfUsage(NULL) {
theBuffer.pValue = varBuffer;
valParser.Initialize(&theBuffer);
theSkipper.Initialize(&theBuffer);

View file

@ -63,6 +63,7 @@
* Debug macros: Strings are stored in progmem (flash) instead of RAM.
*/
#define USBTRACE(s) (Notify(PSTR(s), 0x80))
#define USBTRACE1(s,l) (Notify(PSTR(s), l))
#define USBTRACE2(s,r) (Notify(PSTR(s), 0x80), D_PrintHex((r), 0x80), Notify(PSTR("\r\n"), 0x80))
#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l))

View file

@ -224,11 +224,13 @@ inline void Max_LCD::command(uint8_t value) {
}
#if defined(ARDUINO) && ARDUINO >=100
inline size_t Max_LCD::write(uint8_t value) {
LCD_sendchar(value);
return 1; // Assume success
}
#else
inline void Max_LCD::write(uint8_t value) {
LCD_sendchar(value);
}

View file

@ -62,8 +62,7 @@ e-mail : support@circuitsathome.com
#define LCD_5x10DOTS 0x04
#define LCD_5x8DOTS 0x00
class Max_LCD : public Print
{
class Max_LCD : public Print {
USB *pUsb;
public:

View file

@ -64,6 +64,7 @@ void E_Notify(double d, int lvl) {
}
#ifdef DEBUG_USB_HOST
void NotifyFailGetDevDescr(void) {
Notify(PSTR("\r\ngetDevDescr "), 0x80);
}
@ -71,6 +72,7 @@ void NotifyFailGetDevDescr(void) {
void NotifyFailSetDevTblEntry(void) {
Notify(PSTR("\r\nsetDevTblEn "), 0x80);
}
void NotifyFailGetConfDescr(void) {
Notify(PSTR("\r\ngetConf "), 0x80);
}

View file

@ -22,14 +22,19 @@ e-mail : support@circuitsathome.com
extern int UsbDEBUGlvl;
// This parser does absolutely nothing with the data, just swallows it.
template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>
class SinkParser : public BASE_CLASS {
public:
SinkParser() {};
void Initialize() {};
void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {};
SinkParser() {
};
void Initialize() {
};
void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset) {
};
};

View file

@ -195,10 +195,14 @@ public:
virtual uint8_t Release();
virtual uint8_t Poll();
virtual void ResetHubPort(uint8_t port);
virtual uint8_t GetAddress() {
return bAddress;
};
virtual boolean DEVCLASSOK(uint8_t klass) { return (klass == 0x09); }
virtual boolean DEVCLASSOK(uint8_t klass) {
return (klass == 0x09);
}
};