Fix all demos, fix all wrong uses of virtual keyword, some spacing cleanup.

This commit is contained in:
Andrew J. Kroll 2014-11-10 01:35:13 -05:00
parent 80230570cc
commit 196a0b69be
63 changed files with 425 additions and 258 deletions

18
BTD.h
View file

@ -214,13 +214,13 @@ public:
* Used to pass acldata to the Bluetooth service. * Used to pass acldata to the Bluetooth service.
* @param ACLData Pointer to the incoming acldata. * @param ACLData Pointer to the incoming acldata.
*/ */
virtual void ACLData(uint8_t* ACLData); virtual void ACLData(uint8_t* ACLData){};
/** Used to run the different state machines in the Bluetooth service. */ /** Used to run the different state machines in the Bluetooth service. */
virtual void Run(); virtual void Run(){};
/** Used to reset the Bluetooth service. */ /** Used to reset the Bluetooth service. */
virtual void Reset(); virtual void Reset(){};
/** Used to disconnect both the L2CAP Channel and the HCI Connection for the Bluetooth service. */ /** Used to disconnect both the L2CAP Channel and the HCI Connection for the Bluetooth service. */
virtual void disconnect(); virtual void disconnect(){};
}; };
/** /**
@ -243,7 +243,7 @@ public:
* @param lowspeed Speed of the device. * @param lowspeed Speed of the device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
/** /**
* Initialize the Bluetooth dongle. * Initialize the Bluetooth dongle.
* @param parent Hub number. * @param parent Hub number.
@ -251,17 +251,17 @@ public:
* @param lowspeed Speed of the device. * @param lowspeed Speed of the device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
/** /**
* Release the USB device. * Release the USB device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Release(); uint8_t Release();
/** /**
* Poll the USB Input endpoints and run the state machines. * Poll the USB Input endpoints and run the state machines.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Poll(); uint8_t Poll();
/** /**
* Get the device address. * Get the device address.
@ -315,7 +315,7 @@ public:
* @param proto Interface Protocol. * @param proto Interface Protocol.
* @param ep Endpoint Descriptor. * @param ep Endpoint Descriptor.
*/ */
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
/**@}*/ /**@}*/
/** Disconnects both the L2CAP Channel and the HCI Connection for all Bluetooth services. */ /** Disconnects both the L2CAP Channel and the HCI Connection for all Bluetooth services. */

View file

@ -41,13 +41,13 @@ public:
* Used to pass acldata to the services. * Used to pass acldata to the services.
* @param ACLData Incoming acldata. * @param ACLData Incoming acldata.
*/ */
virtual void ACLData(uint8_t* ACLData); void ACLData(uint8_t* ACLData);
/** Used to run part of the state machine. */ /** Used to run part of the state machine. */
virtual void Run(); void Run();
/** Use this to reset the service. */ /** Use this to reset the service. */
virtual void Reset(); void Reset();
/** Used this to disconnect the devices. */ /** Used this to disconnect the devices. */
virtual void disconnect(); void disconnect();
/**@}*/ /**@}*/
/** /**

View file

@ -45,13 +45,13 @@ public:
* Used to pass acldata to the services. * Used to pass acldata to the services.
* @param ACLData Incoming acldata. * @param ACLData Incoming acldata.
*/ */
virtual void ACLData(uint8_t* ACLData); void ACLData(uint8_t* ACLData);
/** Used to run part of the state machine. */ /** Used to run part of the state machine. */
virtual void Run(); void Run();
/** Use this to reset the service. */ /** Use this to reset the service. */
virtual void Reset(); void Reset();
/** Used this to disconnect any of the controllers. */ /** Used this to disconnect any of the controllers. */
virtual void disconnect(); void disconnect();
/**@}*/ /**@}*/
/** @name PS3 Controller functions */ /** @name PS3 Controller functions */

View file

@ -74,17 +74,17 @@ public:
* @param lowspeed Speed of the device. * @param lowspeed Speed of the device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
/** /**
* Release the USB device. * Release the USB device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Release(); uint8_t Release();
/** /**
* Poll the USB Input endpoins and run the state machines. * Poll the USB Input endpoins and run the state machines.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Poll(); uint8_t Poll();
/** /**
* Get the device address. * Get the device address.

View file

@ -143,14 +143,14 @@ protected:
* @param len The length of the incoming data. * @param len The length of the incoming data.
* @param buf Pointer to the data buffer. * @param buf Pointer to the data buffer.
*/ */
virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
/** /**
* Called when a device is successfully initialized. * Called when a device is successfully initialized.
* Use attachOnInit(void (*funcOnInit)(void)) to call your own function. * Use attachOnInit(void (*funcOnInit)(void)) to call your own function.
* This is useful for instance if you want to set the LEDs in a specific way. * This is useful for instance if you want to set the LEDs in a specific way.
*/ */
virtual uint8_t OnInitSuccessful(); uint8_t OnInitSuccessful();
/**@}*/ /**@}*/
/** Used to reset the different buffers to their default values */ /** Used to reset the different buffers to their default values */

22
SPP.h
View file

@ -83,13 +83,13 @@ public:
* Used to pass acldata to the services. * Used to pass acldata to the services.
* @param ACLData Incoming acldata. * @param ACLData Incoming acldata.
*/ */
virtual void ACLData(uint8_t* ACLData); void ACLData(uint8_t* ACLData);
/** Used to establish the connection automatically. */ /** Used to establish the connection automatically. */
virtual void Run(); void Run();
/** Use this to reset the service. */ /** Use this to reset the service. */
virtual void Reset(); void Reset();
/** Used this to disconnect the virtual serial port. */ /** Used this to disconnect the virtual serial port. */
virtual void disconnect(); void disconnect();
/**@}*/ /**@}*/
/** @name Serial port profile (SPP) Print functions */ /** @name Serial port profile (SPP) Print functions */
@ -97,7 +97,7 @@ public:
* Get number of bytes waiting to be read. * Get number of bytes waiting to be read.
* @return Return the number of bytes ready to be read. * @return Return the number of bytes ready to be read.
*/ */
virtual int available(void); int available(void);
/** Send out all bytes in the buffer. */ /** Send out all bytes in the buffer. */
virtual void flush(void) { virtual void flush(void) {
@ -107,12 +107,12 @@ public:
* Used to read the next value in the buffer without advancing to the next one. * Used to read the next value in the buffer without advancing to the next one.
* @return Return the byte. Will return -1 if no bytes are available. * @return Return the byte. Will return -1 if no bytes are available.
*/ */
virtual int peek(void); int peek(void);
/** /**
* Used to read the buffer. * Used to read the buffer.
* @return Return the byte. Will return -1 if no bytes are available. * @return Return the byte. Will return -1 if no bytes are available.
*/ */
virtual int read(void); int read(void);
#if defined(ARDUINO) && ARDUINO >=100 #if defined(ARDUINO) && ARDUINO >=100
/** /**
@ -120,14 +120,14 @@ public:
* @param data The byte to write. * @param data The byte to write.
* @return Return the number of bytes written. * @return Return the number of bytes written.
*/ */
virtual size_t write(uint8_t data); size_t write(uint8_t data);
/** /**
* Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called. * Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called.
* @param data The data array to send. * @param data The data array to send.
* @param size Size of the data. * @param size Size of the data.
* @return Return the number of bytes written. * @return Return the number of bytes written.
*/ */
virtual size_t write(const uint8_t* data, size_t size); size_t write(const uint8_t* data, size_t size);
/** Pull in write(const char *str) from Print */ /** Pull in write(const char *str) from Print */
using Print::write; using Print::write;
#else #else
@ -135,13 +135,13 @@ public:
* Writes the byte to send to a buffer. The message is send when either send() or after Usb.Task() is called. * Writes the byte to send to a buffer. The message is send when either send() or after Usb.Task() is called.
* @param data The byte to write. * @param data The byte to write.
*/ */
virtual void write(uint8_t data); void write(uint8_t data);
/** /**
* Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called. * Writes the bytes to send to a buffer. The message is send when either send() or after Usb.Task() is called.
* @param data The data array to send. * @param data The data array to send.
* @param size Size of the data. * @param size Size of the data.
*/ */
virtual void write(const uint8_t* data, size_t size); void write(const uint8_t* data, size_t size);
#endif #endif
/** Discard all the bytes in the buffer. */ /** Discard all the bytes in the buffer. */

8
Wii.h
View file

@ -59,13 +59,13 @@ public:
* Used to pass acldata to the services. * Used to pass acldata to the services.
* @param ACLData Incoming acldata. * @param ACLData Incoming acldata.
*/ */
virtual void ACLData(uint8_t* ACLData); void ACLData(uint8_t* ACLData);
/** Used to run part of the state machine. */ /** Used to run part of the state machine. */
virtual void Run(); void Run();
/** Use this to reset the service. */ /** Use this to reset the service. */
virtual void Reset(); void Reset();
/** Used this to disconnect any of the controllers. */ /** Used this to disconnect any of the controllers. */
virtual void disconnect(); void disconnect();
/**@}*/ /**@}*/
/** @name Wii Controller functions */ /** @name Wii Controller functions */

View file

@ -65,17 +65,17 @@ public:
* @param lowspeed Speed of the device. * @param lowspeed Speed of the device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
/** /**
* Release the USB device. * Release the USB device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Release(); uint8_t Release();
/** /**
* Poll the USB Input endpoins and run the state machines. * Poll the USB Input endpoins and run the state machines.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Poll(); uint8_t Poll();
/** /**
* Get the device address. * Get the device address.

View file

@ -71,7 +71,7 @@ public:
* @param lowspeed Speed of the device. * @param lowspeed Speed of the device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
/** /**
* Initialize the Xbox wireless receiver. * Initialize the Xbox wireless receiver.
* @param parent Hub number. * @param parent Hub number.
@ -79,17 +79,17 @@ public:
* @param lowspeed Speed of the device. * @param lowspeed Speed of the device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
/** /**
* Release the USB device. * Release the USB device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Release(); uint8_t Release();
/** /**
* Poll the USB Input endpoins and run the state machines. * Poll the USB Input endpoins and run the state machines.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Poll(); uint8_t Poll();
/** /**
* Get the device address. * Get the device address.

View file

@ -71,17 +71,17 @@ public:
* @param lowspeed Speed of the device. * @param lowspeed Speed of the device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
/** /**
* Release the USB device. * Release the USB device.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Release(); uint8_t Release();
/** /**
* Poll the USB Input endpoins and run the state machines. * Poll the USB Input endpoins and run the state machines.
* @return 0 on success. * @return 0 on success.
*/ */
virtual uint8_t Poll(); uint8_t Poll();
/** /**
* Get the device address. * Get the device address.

8
adk.h
View file

@ -96,9 +96,9 @@ public:
// USBDeviceConfig implementation // USBDeviceConfig implementation
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t Release(); uint8_t Release();
virtual uint8_t Poll() { virtual uint8_t Poll() {
return 0; return 0;
@ -117,7 +117,7 @@ public:
}; };
//UsbConfigXtracter implementation //UsbConfigXtracter implementation
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
}; //class ADK : public USBDeviceConfig ... }; //class ADK : public USBDeviceConfig ...
/* get ADK protocol version */ /* get ADK protocol version */

View file

@ -127,7 +127,9 @@ class ACM;
class CDCAsyncOper { class CDCAsyncOper {
public: public:
virtual uint8_t OnInit(ACM *pacm) = 0;
virtual uint8_t OnInit(ACM *pacm) {
};
//virtual void OnDataRcvd(ACM *pacm, uint8_t nbytes, uint8_t *dataptr) = 0; //virtual void OnDataRcvd(ACM *pacm, uint8_t nbytes, uint8_t *dataptr) = 0;
//virtual void OnDisconnected(ACM *pacm) = 0; //virtual void OnDisconnected(ACM *pacm) = 0;
}; };
@ -173,9 +175,9 @@ public:
uint8_t SndData(uint16_t nbytes, uint8_t *dataptr); uint8_t SndData(uint16_t nbytes, uint8_t *dataptr);
// USBDeviceConfig implementation // USBDeviceConfig implementation
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t Release(); uint8_t Release();
virtual uint8_t Poll(); uint8_t Poll();
virtual uint8_t GetAddress() { virtual uint8_t GetAddress() {
return bAddress; return bAddress;
@ -186,7 +188,7 @@ public:
}; };
// UsbConfigXtracter implementation // UsbConfigXtracter implementation
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
}; };
#endif // __CDCACM_H__ #endif // __CDCACM_H__

View file

@ -78,8 +78,12 @@ class FTDI;
class FTDIAsyncOper { class FTDIAsyncOper {
public: public:
virtual uint8_t OnInit(FTDI *pftdi) = 0;
virtual uint8_t OnRelease(FTDI *pftdi) = 0; virtual uint8_t OnInit(FTDI *pftdi) {
};
virtual uint8_t OnRelease(FTDI *pftdi) {
};
}; };
@ -119,16 +123,16 @@ public:
uint8_t SndData(uint16_t nbytes, uint8_t *dataptr); uint8_t SndData(uint16_t nbytes, uint8_t *dataptr);
// USBDeviceConfig implementation // USBDeviceConfig implementation
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t Release(); uint8_t Release();
virtual uint8_t Poll(); uint8_t Poll();
virtual uint8_t GetAddress() { virtual uint8_t GetAddress() {
return bAddress; return bAddress;
}; };
// UsbConfigXtracter implementation // UsbConfigXtracter implementation
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) { virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
return (vid == FTDI_VID && pid == FTDI_PID); return (vid == FTDI_VID && pid == FTDI_PID);

View file

@ -19,69 +19,61 @@ e-mail : support@circuitsathome.com
#include "cdcacm.h" #include "cdcacm.h"
#define PL_VID 0x067B #define PL_VID 0x067B
#define PL_PID ( 0x2303 || 0x0609 ) #define PL_PID ( 0x2303 || 0x0609 )
//#define PL_PID 0x0609 //#define PL_PID 0x0609
#define PROLIFIC_REV_H 0x0202 #define PROLIFIC_REV_H 0x0202
#define PROLIFIC_REV_X 0x0300 #define PROLIFIC_REV_X 0x0300
#define PROLIFIC_REV_HX_CHIP_D 0x0400 #define PROLIFIC_REV_HX_CHIP_D 0x0400
#define PROLIFIC_REV_1 0x0001 #define PROLIFIC_REV_1 0x0001
#define kXOnChar '\x11' #define kXOnChar '\x11'
#define kXOffChar '\x13' #define kXOffChar '\x13'
#define SPECIAL_SHIFT (5) #define SPECIAL_SHIFT (5)
#define SPECIAL_MASK ((1<<SPECIAL_SHIFT) - 1) #define SPECIAL_MASK ((1<<SPECIAL_SHIFT) - 1)
#define STATE_ALL ( PD_RS232_S_MASK | PD_S_MASK ) #define STATE_ALL ( PD_RS232_S_MASK | PD_S_MASK )
#define FLOW_RX_AUTO ( PD_RS232_A_RFR | PD_RS232_A_DTR | PD_RS232_A_RXO ) #define FLOW_RX_AUTO ( PD_RS232_A_RFR | PD_RS232_A_DTR | PD_RS232_A_RXO )
#define FLOW_TX_AUTO ( PD_RS232_A_CTS | PD_RS232_A_DSR | PD_RS232_A_TXO | PD_RS232_A_DCD ) #define FLOW_TX_AUTO ( PD_RS232_A_CTS | PD_RS232_A_DSR | PD_RS232_A_TXO | PD_RS232_A_DCD )
#define CAN_BE_AUTO ( FLOW_RX_AUTO | FLOW_TX_AUTO ) #define CAN_BE_AUTO ( FLOW_RX_AUTO | FLOW_TX_AUTO )
#define CAN_NOTIFY ( PD_RS232_N_MASK ) #define CAN_NOTIFY ( PD_RS232_N_MASK )
#define EXTERNAL_MASK ( PD_S_MASK | (PD_RS232_S_MASK & ~PD_RS232_S_LOOP) ) #define EXTERNAL_MASK ( PD_S_MASK | (PD_RS232_S_MASK & ~PD_RS232_S_LOOP) )
#define INTERNAL_DELAY ( PD_RS232_S_LOOP ) #define INTERNAL_DELAY ( PD_RS232_S_LOOP )
#define DEFAULT_AUTO ( PD_RS232_A_DTR | PD_RS232_A_RFR | PD_RS232_A_CTS | PD_RS232_A_DSR ) #define DEFAULT_AUTO ( PD_RS232_A_DTR | PD_RS232_A_RFR | PD_RS232_A_CTS | PD_RS232_A_DSR )
#define DEFAULT_NOTIFY 0x00 #define DEFAULT_NOTIFY 0x00
#define DEFAULT_STATE ( PD_S_TX_ENABLE | PD_S_RX_ENABLE | PD_RS232_A_TXO | PD_RS232_A_RXO ) #define DEFAULT_STATE ( PD_S_TX_ENABLE | PD_S_RX_ENABLE | PD_RS232_A_TXO | PD_RS232_A_RXO )
#define CONTINUE_SEND 1 #define CONTINUE_SEND 1
#define PAUSE_SEND 2 #define PAUSE_SEND 2
#define kRxAutoFlow ((UInt32)( PD_RS232_A_RFR | PD_RS232_A_DTR | PD_RS232_A_RXO )) #define kRxAutoFlow ((UInt32)( PD_RS232_A_RFR | PD_RS232_A_DTR | PD_RS232_A_RXO ))
#define kTxAutoFlow ((UInt32)( PD_RS232_A_CTS | PD_RS232_A_DSR | PD_RS232_A_TXO | PD_RS232_A_DCD )) #define kTxAutoFlow ((UInt32)( PD_RS232_A_CTS | PD_RS232_A_DSR | PD_RS232_A_TXO | PD_RS232_A_DCD ))
#define kControl_StateMask ((UInt32)( PD_RS232_S_CTS | PD_RS232_S_DSR | PD_RS232_S_CAR | PD_RS232_S_RI )) #define kControl_StateMask ((UInt32)( PD_RS232_S_CTS | PD_RS232_S_DSR | PD_RS232_S_CAR | PD_RS232_S_RI ))
#define kRxQueueState ((UInt32)( PD_S_RXQ_EMPTY | PD_S_RXQ_LOW_WATER | PD_S_RXQ_HIGH_WATER | PD_S_RXQ_FULL )) #define kRxQueueState ((UInt32)( PD_S_RXQ_EMPTY | PD_S_RXQ_LOW_WATER | PD_S_RXQ_HIGH_WATER | PD_S_RXQ_FULL ))
#define kTxQueueState ((UInt32)( PD_S_TXQ_EMPTY | PD_S_TXQ_LOW_WATER | PD_S_TXQ_HIGH_WATER | PD_S_TXQ_FULL )) #define kTxQueueState ((UInt32)( PD_S_TXQ_EMPTY | PD_S_TXQ_LOW_WATER | PD_S_TXQ_HIGH_WATER | PD_S_TXQ_FULL ))
#define kCONTROL_DTR 0x01 #define kCONTROL_DTR 0x01
#define kCONTROL_RTS 0x02 #define kCONTROL_RTS 0x02
enum tXO_State { #define kStateTransientMask 0x74
kXOnSent = -2, #define kBreakError 0x04
kXOffSent = -1, #define kFrameError 0x10
kXO_Idle = 0, #define kParityError 0x20
kXOffNeeded = 1, #define kOverrunError 0x40
kXOnNeeded = 2
};
#define kStateTransientMask 0x74 #define kCTS 0x80
#define kBreakError 0x04 #define kDSR 0x02
#define kFrameError 0x10 #define kRI 0x08
#define kParityError 0x20 #define kDCD 0x01
#define kOverrunError 0x40 #define kHandshakeInMask ((UInt32)( PD_RS232_S_CTS | PD_RS232_S_DSR | PD_RS232_S_CAR | PD_RS232_S_RI ))
#define kCTS 0x80 #define VENDOR_WRITE_REQUEST_TYPE 0x40
#define kDSR 0x02 #define VENDOR_WRITE_REQUEST 0x01
#define kRI 0x08
#define kDCD 0x01
#define kHandshakeInMask ((UInt32)( PD_RS232_S_CTS | PD_RS232_S_DSR | PD_RS232_S_CAR | PD_RS232_S_RI ))
#define VENDOR_WRITE_REQUEST_TYPE 0x40 #define VENDOR_READ_REQUEST_TYPE 0xc0
#define VENDOR_WRITE_REQUEST 0x01 #define VENDOR_READ_REQUEST 0x01
#define VENDOR_READ_REQUEST_TYPE 0xc0
#define VENDOR_READ_REQUEST 0x01
// Device Configuration Registers (DCR0, DCR1, DCR2) // Device Configuration Registers (DCR0, DCR1, DCR2)
#define SET_DCR0 0x00 #define SET_DCR0 0x00
@ -104,6 +96,17 @@ enum tXO_State {
#define RESET_DOWNSTREAM_DATA_PIPE 0x08 #define RESET_DOWNSTREAM_DATA_PIPE 0x08
#define RESET_UPSTREAM_DATA_PIPE 0x09 #define RESET_UPSTREAM_DATA_PIPE 0x09
#define PL_MAX_ENDPOINTS 4
enum tXO_State {
kXOnSent = -2,
kXOffSent = -1,
kXO_Idle = 0,
kXOffNeeded = 1,
kXOnNeeded = 2
};
enum pl2303_type { enum pl2303_type {
unknown, unknown,
type_1, /* don't know the difference between type 0 and */ type_1, /* don't know the difference between type 0 and */
@ -113,8 +116,6 @@ enum pl2303_type {
}; };
#define PL_MAX_ENDPOINTS 4
class PL2303 : public ACM { class PL2303 : public ACM {
uint16_t wPLType; // Type of chip uint16_t wPLType; // Type of chip
@ -122,7 +123,7 @@ public:
PL2303(USB *pusb, CDCAsyncOper *pasync); PL2303(USB *pusb, CDCAsyncOper *pasync);
// USBDeviceConfig implementation // USBDeviceConfig implementation
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
//virtual uint8_t Release(); //virtual uint8_t Release();
//virtual uint8_t Poll(); //virtual uint8_t Poll();
//virtual uint8_t GetAddress() { return bAddress; }; //virtual uint8_t GetAddress() { return bAddress; };

View file

@ -24,7 +24,9 @@ class UsbConfigXtracter {
public: public:
//virtual void ConfigXtract(const USB_CONFIGURATION_DESCRIPTOR *conf) = 0; //virtual void ConfigXtract(const USB_CONFIGURATION_DESCRIPTOR *conf) = 0;
//virtual void InterfaceXtract(uint8_t conf, const USB_INTERFACE_DESCRIPTOR *iface) = 0; //virtual void InterfaceXtract(uint8_t conf, const USB_INTERFACE_DESCRIPTOR *iface) = 0;
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep) = 0;
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep) {
};
}; };
#define CP_MASK_COMPARE_CLASS 1 #define CP_MASK_COMPARE_CLASS 1
@ -63,7 +65,7 @@ public:
UseOr = true; UseOr = true;
} }
ConfigDescParser(UsbConfigXtracter *xtractor); ConfigDescParser(UsbConfigXtracter *xtractor);
virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset); void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset);
}; };
template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK> template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>

View file

@ -11,6 +11,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -30,7 +31,9 @@ MouseRptParser mousePrs;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); // Halt while (1); // Halt

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -24,7 +25,9 @@ boolean printAngle;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -10,6 +10,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -28,7 +29,9 @@ void setup() {
} }
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -15,6 +15,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -33,7 +34,9 @@ String output = ""; // We will store the data in this string
void setup() { void setup() {
Serial.begin(115200); // This wil lprint the debugging from the libraries Serial.begin(115200); // This wil lprint the debugging from the libraries
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -10,6 +10,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -29,7 +30,9 @@ uint8_t oldL2Value, oldR2Value;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); // Halt while (1); // Halt

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -23,7 +24,9 @@ boolean firstMessage = true;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -6,9 +6,10 @@
#include <SPP.h> #include <SPP.h>
#include <usbhub.h> #include <usbhub.h>
// Satisfy IDE, which only needs to see the include statement in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -26,7 +27,9 @@ void setup() {
SerialBT[i] = new SPP(&Btd); // This will set the name to the default: "Arduino" and the pin to "0000" for all connections SerialBT[i] = new SPP(&Btd); // This will set the name to the default: "Arduino" and the pin to "0000" for all connections
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); // Halt while (1); // Halt

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -23,7 +24,9 @@ bool printAngle;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -16,6 +16,7 @@ Otherwise, wire up a IR LED yourself.
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
#ifndef WIICAMERA // Used to check if WIICAMERA is defined #ifndef WIICAMERA // Used to check if WIICAMERA is defined
@ -35,7 +36,9 @@ uint8_t printObjects;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -10,6 +10,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -28,7 +29,9 @@ void setup() {
} }
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -21,7 +22,9 @@ WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wiimo
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -3,6 +3,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
class KbdRptParser : public KeyboardReportParser class KbdRptParser : public KeyboardReportParser
@ -10,11 +11,11 @@ class KbdRptParser : public KeyboardReportParser
void PrintKey(uint8_t mod, uint8_t key); void PrintKey(uint8_t mod, uint8_t key);
protected: protected:
virtual void OnControlKeysChanged(uint8_t before, uint8_t after); void OnControlKeysChanged(uint8_t before, uint8_t after);
virtual void OnKeyDown (uint8_t mod, uint8_t key); void OnKeyDown (uint8_t mod, uint8_t key);
virtual void OnKeyUp (uint8_t mod, uint8_t key); void OnKeyUp (uint8_t mod, uint8_t key);
virtual void OnKeyPressed(uint8_t key); void OnKeyPressed(uint8_t key);
}; };
void KbdRptParser::PrintKey(uint8_t m, uint8_t key) void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
@ -105,7 +106,9 @@ KbdRptParser Prs;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -1,16 +1,21 @@
#include <hidboot.h> #include <hidboot.h>
#include <usbhub.h> #include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
class MouseRptParser : public MouseReportParser class MouseRptParser : public MouseReportParser
{ {
protected: protected:
virtual void OnMouseMove (MOUSEINFO *mi); void OnMouseMove(MOUSEINFO *mi);
virtual void OnLeftButtonUp (MOUSEINFO *mi); void OnLeftButtonUp(MOUSEINFO *mi);
virtual void OnLeftButtonDown (MOUSEINFO *mi); void OnLeftButtonDown(MOUSEINFO *mi);
virtual void OnRightButtonUp (MOUSEINFO *mi); void OnRightButtonUp(MOUSEINFO *mi);
virtual void OnRightButtonDown (MOUSEINFO *mi); void OnRightButtonDown(MOUSEINFO *mi);
virtual void OnMiddleButtonUp (MOUSEINFO *mi); void OnMiddleButtonUp(MOUSEINFO *mi);
virtual void OnMiddleButtonDown (MOUSEINFO *mi); void OnMiddleButtonDown(MOUSEINFO *mi);
}; };
void MouseRptParser::OnMouseMove(MOUSEINFO *mi) void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
{ {
@ -49,11 +54,10 @@ class KbdRptParser : public KeyboardReportParser
void PrintKey(uint8_t mod, uint8_t key); void PrintKey(uint8_t mod, uint8_t key);
protected: protected:
virtual void OnControlKeysChanged(uint8_t before, uint8_t after); void OnControlKeysChanged(uint8_t before, uint8_t after);
void OnKeyDown (uint8_t mod, uint8_t key);
virtual void OnKeyDown (uint8_t mod, uint8_t key); void OnKeyUp (uint8_t mod, uint8_t key);
virtual void OnKeyUp (uint8_t mod, uint8_t key); void OnKeyPressed(uint8_t key);
virtual void OnKeyPressed(uint8_t key);
}; };
void KbdRptParser::PrintKey(uint8_t m, uint8_t key) void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
@ -148,7 +152,9 @@ MouseRptParser MousePrs;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -3,18 +3,19 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
class MouseRptParser : public MouseReportParser class MouseRptParser : public MouseReportParser
{ {
protected: protected:
virtual void OnMouseMove (MOUSEINFO *mi); void OnMouseMove (MOUSEINFO *mi);
virtual void OnLeftButtonUp (MOUSEINFO *mi); void OnLeftButtonUp (MOUSEINFO *mi);
virtual void OnLeftButtonDown (MOUSEINFO *mi); void OnLeftButtonDown (MOUSEINFO *mi);
virtual void OnRightButtonUp (MOUSEINFO *mi); void OnRightButtonUp (MOUSEINFO *mi);
virtual void OnRightButtonDown (MOUSEINFO *mi); void OnRightButtonDown (MOUSEINFO *mi);
virtual void OnMiddleButtonUp (MOUSEINFO *mi); void OnMiddleButtonUp (MOUSEINFO *mi);
virtual void OnMiddleButtonDown (MOUSEINFO *mi); void OnMiddleButtonDown (MOUSEINFO *mi);
}; };
void MouseRptParser::OnMouseMove(MOUSEINFO *mi) void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
{ {
@ -59,7 +60,9 @@ MouseRptParser Prs;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -1,6 +1,11 @@
#include <hid.h> #include <hid.h>
#include <hiduniversal.h> #include <hiduniversal.h>
#include <usbhub.h> #include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
#include "hidjoystickrptparser.h" #include "hidjoystickrptparser.h"
@ -12,7 +17,9 @@ JoystickReportParser Joy(&JoyEvents);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -6,6 +6,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
class HIDUniversal2 : public HIDUniversal class HIDUniversal2 : public HIDUniversal
@ -14,7 +15,7 @@ public:
HIDUniversal2(USB *usb) : HIDUniversal(usb) {}; HIDUniversal2(USB *usb) : HIDUniversal(usb) {};
protected: protected:
virtual uint8_t OnInitSuccessful(); uint8_t OnInitSuccessful();
}; };
uint8_t HIDUniversal2::OnInitSuccessful() uint8_t HIDUniversal2::OnInitSuccessful()
@ -54,7 +55,9 @@ UniversalReportParser Uni;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -8,6 +8,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -19,7 +20,9 @@ JoystickReportParser Joy(&JoyEvents);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -21,7 +22,9 @@ ScaleReportParser Scale(&ScaleEvents);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -1,7 +1,7 @@
#if !defined(__SCALERPTPARSER_H__) #if !defined(__SCALERPTPARSER_H__)
#define __SCALERPTPARSER_H__ #define __SCALERPTPARSER_H__
#include <Max_LCD.h> #include <max_LCD.h>
#include <hid.h> #include <hid.h>
/* Scale status constants */ /* Scale status constants */
@ -19,22 +19,22 @@ struct ScaleEventData
{ {
uint8_t reportID; //must be 3 uint8_t reportID; //must be 3
uint8_t status; uint8_t status;
uint8_t unit; uint8_t unit;
int8_t exp; //scale factor for the weight int8_t exp; //scale factor for the weight
uint16_t weight; // uint16_t weight; //
}; };
class ScaleEvents class ScaleEvents
{ {
Max_LCD* pLcd; Max_LCD* pLcd;
void LcdPrint( const char* str ); void LcdPrint( const char* str );
public: public:
ScaleEvents( Max_LCD* pLCD ); ScaleEvents( Max_LCD* pLCD );
virtual void OnScaleChanged(const ScaleEventData *evt); virtual void OnScaleChanged(const ScaleEventData *evt);
}; };

View file

@ -8,6 +8,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -20,7 +21,9 @@ uint8_t state = 0;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -19,7 +20,9 @@ uint8_t oldL2Value, oldR2Value;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); // Halt while (1); // Halt

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -16,7 +17,9 @@ PSBuzz Buzz(&Usb);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); // Halt while (1); // Halt

View file

@ -4,6 +4,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -49,7 +50,9 @@ void PrintAddress(uint8_t addr)
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)
@ -336,7 +339,7 @@ void printunkdescr( uint8_t* descr_ptr )
/* Print a string from Program Memory directly to save RAM */ /* Print a string from Program Memory directly to save RAM */
void printProgStr(const prog_char str[]) void printProgStr(prog_char str[])
{ {
char c; char c;
if(!str) return; if(!str) return;

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -17,7 +18,9 @@ XBOXOLD Xbox(&Usb);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); // halt while (1); // halt

View file

@ -9,6 +9,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -16,7 +17,9 @@ XBOXRECV Xbox(&Usb);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -8,6 +8,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -15,7 +16,9 @@ XBOXUSB Xbox(&Usb);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print(F("\r\nOSC did not start")); Serial.print(F("\r\nOSC did not start"));
while (1); //halt while (1); //halt

View file

@ -6,12 +6,13 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
class ACMAsyncOper : public CDCAsyncOper class ACMAsyncOper : public CDCAsyncOper
{ {
public: public:
virtual uint8_t OnInit(ACM *pacm); uint8_t OnInit(ACM *pacm);
}; };
uint8_t ACMAsyncOper::OnInit(ACM *pacm) uint8_t ACMAsyncOper::OnInit(ACM *pacm)
@ -48,7 +49,9 @@ ACM Acm(&Usb, &AsyncOper);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -2,6 +2,27 @@
// The code for the Android application is heavily based on this guide: http://allaboutee.com/2011/12/31/arduino-adk-board-blink-an-led-with-your-phone-code-and-explanation/ by Miguel // The code for the Android application is heavily based on this guide: http://allaboutee.com/2011/12/31/arduino-adk-board-blink-an-led-with-your-phone-code-and-explanation/ by Miguel
#include <adk.h> #include <adk.h>
//
// CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ!
//
// Pin 13 is occupied by the SCK pin on various Arduino boards,
// including Uno, Duemilanove, etc., so use a different pin for those boards.
//
// CAUTION! WARNING! ATTENTION! VORSICHT! ADVARSEL! ¡CUIDADO! ВНИМАНИЕ!
//
#if defined(LED_BUILTIN)
#define LED LED_BUILTIN // Use built in LED
#else
#define LED 9 // Set to something here that makes sense for your board.
#endif
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb; USB Usb;
ADK adk(&Usb, "TKJElectronics", // Manufacturer Name ADK adk(&Usb, "TKJElectronics", // Manufacturer Name
"ArduinoBlinkLED", // Model Name "ArduinoBlinkLED", // Model Name
@ -10,14 +31,14 @@ ADK adk(&Usb, "TKJElectronics", // Manufacturer Name
"http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory) "http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory)
"123456789"); // Serial Number (optional) "123456789"); // Serial Number (optional)
#define LED LED_BUILTIN // Use built in LED - note that pin 13 is occupied by the SCK pin on a normal Arduino (Uno, Duemilanove etc.), so use a different pin
uint32_t timer; uint32_t timer;
boolean connected; boolean connected;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print("\r\nOSCOKIRQ failed to assert"); Serial.print("\r\nOSCOKIRQ failed to assert");
while (1); // halt while (1); // halt

View file

@ -4,10 +4,15 @@
#include <adk.h> #include <adk.h>
#include <hidboot.h> #include <hidboot.h>
#include <usbhub.h> #include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb; USB Usb;
USBHub Hub1(&Usb); USBHub Hub1(&Usb);
USBHub Hub2(&Usb); USBHub Hub2(&Usb);
HIDBoot<HID_PROTOCOL_KEYBOARD> Keyboard(&Usb); HIDBoot<HID_PROTOCOL_KEYBOARD> Keyboard(&Usb);
ADK adk(&Usb,"Circuits@Home, ltd.", ADK adk(&Usb,"Circuits@Home, ltd.",
@ -20,22 +25,22 @@ ADK adk(&Usb,"Circuits@Home, ltd.",
class KbdRptParser : public KeyboardReportParser class KbdRptParser : public KeyboardReportParser
{ {
protected: protected:
virtual void OnKeyDown (uint8_t mod, uint8_t key); void OnKeyDown (uint8_t mod, uint8_t key);
virtual void OnKeyPressed(uint8_t key); void OnKeyPressed(uint8_t key);
}; };
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key) void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{ {
uint8_t c = OemToAscii(mod, key); uint8_t c = OemToAscii(mod, key);
if (c) if (c)
OnKeyPressed(c); OnKeyPressed(c);
} }
/* what to do when symbol arrives */ /* what to do when symbol arrives */
void KbdRptParser::OnKeyPressed(uint8_t key) void KbdRptParser::OnKeyPressed(uint8_t key)
{ {
const char* new_line = "\n"; const char* new_line = "\n";
uint8_t rcode; uint8_t rcode;
@ -44,36 +49,38 @@ uint8_t keylcl;
if( adk.isReady() == false ) { if( adk.isReady() == false ) {
return; return;
} }
keylcl = key; keylcl = key;
if( keylcl == 0x13 ) { if( keylcl == 0x13 ) {
rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line ); rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line );
} }
else { else {
rcode = adk.SndData( 1, &keylcl ); rcode = adk.SndData( 1, &keylcl );
} }
Serial.print((char) keylcl ); Serial.print((char) keylcl );
Serial.print(" : "); Serial.print(" : ");
Serial.println( keylcl, HEX ); Serial.println( keylcl, HEX );
}; };
KbdRptParser Prs; KbdRptParser Prs;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("\r\nADK demo start"); Serial.println("\r\nADK demo start");
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.println("OSCOKIRQ failed to assert"); Serial.println("OSCOKIRQ failed to assert");
while(1); //halt while(1); //halt
}//if (Usb.Init() == -1... }//if (Usb.Init() == -1...
Keyboard.SetReportParser(0, (HIDReportParser*)&Prs); Keyboard.SetReportParser(0, (HIDReportParser*)&Prs);
delay( 200 ); delay( 200 );
} }

View file

@ -1,5 +1,10 @@
#include <adk.h> #include <adk.h>
#include <usbhub.h> #include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb; USB Usb;
USBHub hub0(&Usb); USBHub hub0(&Usb);
@ -16,9 +21,6 @@ uint8_t b, b1;
#define LED1_RED 3 #define LED1_RED 3
#define BUTTON1 2 #define BUTTON1 2
void setup();
void loop();
void init_buttons() void init_buttons()
{ {
pinMode(BUTTON1, INPUT); pinMode(BUTTON1, INPUT);
@ -37,9 +39,11 @@ void init_leds()
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("\r\nADK demo start"); Serial.println("\r\nADK demo start");
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.println("OSCOKIRQ failed to assert"); Serial.println("OSCOKIRQ failed to assert");
while(1); //halt while(1); //halt
@ -56,17 +60,17 @@ void loop()
uint8_t rcode; uint8_t rcode;
uint8_t msg[3] = { 0x00 }; uint8_t msg[3] = { 0x00 };
Usb.Task(); Usb.Task();
if( adk.isReady() == false ) { if( adk.isReady() == false ) {
analogWrite(LED1_RED, 255); analogWrite(LED1_RED, 255);
return; return;
} }
uint16_t len = sizeof(msg); uint16_t len = sizeof(msg);
rcode = adk.RcvData(&len, msg); rcode = adk.RcvData(&len, msg);
if( rcode ) { if( rcode ) {
USBTRACE2("Data rcv. :", rcode ); USBTRACE2("Data rcv. :", rcode );
} }
if(len > 0) { if(len > 0) {
USBTRACE("\r\nData Packet."); USBTRACE("\r\nData Packet.");
// assumes only one command per packet // assumes only one command per packet
@ -75,10 +79,10 @@ void loop()
case 0: case 0:
analogWrite(LED1_RED, 255 - msg[2]); analogWrite(LED1_RED, 255 - msg[2]);
break; break;
}//switch( msg[1]... }//switch( msg[1]...
}//if (msg[0] == 0x2... }//if (msg[0] == 0x2...
}//if( len > 0... }//if( len > 0...
msg[0] = 0x1; msg[0] = 0x1;
b = digitalRead(BUTTON1); b = digitalRead(BUTTON1);
@ -94,5 +98,5 @@ void loop()
}//if (b != b1... }//if (b != b1...
delay( 10 ); delay( 10 );
} }

View file

@ -1,5 +1,10 @@
#include <adk.h> #include <adk.h>
#include <usbhub.h> #include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb; USB Usb;
//USBHub Hub(&Usb); //USBHub Hub(&Usb);
@ -14,9 +19,11 @@ ADK adk(&Usb,"Circuits@Home, ltd.",
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("\r\nADK demo start"); Serial.println("\r\nADK demo start");
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.println("OSCOKIRQ failed to assert"); Serial.println("OSCOKIRQ failed to assert");
while(1); //halt while(1); //halt
@ -27,31 +34,31 @@ void loop()
{ {
uint8_t rcode; uint8_t rcode;
uint8_t msg[64] = { 0x00 }; uint8_t msg[64] = { 0x00 };
const char* recv = "Received: "; const char* recv = "Received: ";
Usb.Task(); Usb.Task();
if( adk.isReady() == false ) { if( adk.isReady() == false ) {
return; return;
} }
uint16_t len = 64; uint16_t len = 64;
rcode = adk.RcvData(&len, msg); rcode = adk.RcvData(&len, msg);
if( rcode & ( rcode != hrNAK )) { if( rcode & ( rcode != hrNAK )) {
USBTRACE2("Data rcv. :", rcode ); USBTRACE2("Data rcv. :", rcode );
} }
if(len > 0) { if(len > 0) {
USBTRACE("\r\nData Packet."); USBTRACE("\r\nData Packet.");
for( uint8_t i = 0; i < len; i++ ) { for( uint8_t i = 0; i < len; i++ ) {
Serial.print((char)msg[i]); Serial.print((char)msg[i]);
} }
/* sending back what was received */ /* sending back what was received */
rcode = adk.SndData( strlen( recv ), (uint8_t *)recv ); rcode = adk.SndData( strlen( recv ), (uint8_t *)recv );
rcode = adk.SndData( strlen(( char * )msg ), msg ); rcode = adk.SndData( strlen(( char * )msg ), msg );
}//if( len > 0 )... }//if( len > 0 )...
delay( 1000 ); delay( 1000 );
} }

View file

@ -1,5 +1,10 @@
#include <adk.h> #include <adk.h>
#include <usbhub.h> #include <usbhub.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb; USB Usb;
@ -13,9 +18,11 @@ ADK adk(&Usb,"Circuits@Home, ltd.",
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("\r\nADK demo start"); Serial.println("\r\nADK demo start");
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.println("OSCOKIRQ failed to assert"); Serial.println("OSCOKIRQ failed to assert");
while(1); //halt while(1); //halt
@ -27,16 +34,16 @@ void loop()
uint8_t buf[ 12 ] = { 0 }; //buffer to convert unsigned long to ASCII uint8_t buf[ 12 ] = { 0 }; //buffer to convert unsigned long to ASCII
const char* sec_ela = " seconds elapsed\r"; const char* sec_ela = " seconds elapsed\r";
uint8_t rcode; uint8_t rcode;
Usb.Task(); Usb.Task();
if( adk.isReady() == false ) { if( adk.isReady() == false ) {
return; return;
} }
ultoa( millis()/1000, (char *)buf, 10 ); ultoa( millis()/1000, (char *)buf, 10 );
rcode = adk.SndData( strlen((char *)buf), buf ); rcode = adk.SndData( strlen((char *)buf), buf );
rcode = adk.SndData( strlen( sec_ela), (uint8_t *)sec_ela ); rcode = adk.SndData( strlen( sec_ela), (uint8_t *)sec_ela );
delay( 1000 ); delay( 1000 );
} }

View file

@ -5,12 +5,13 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
class FTDIAsync : public FTDIAsyncOper class FTDIAsync : public FTDIAsyncOper
{ {
public: public:
virtual uint8_t OnInit(FTDI *pftdi); uint8_t OnInit(FTDI *pftdi);
}; };
uint8_t FTDIAsync::OnInit(FTDI *pftdi) uint8_t FTDIAsync::OnInit(FTDI *pftdi)
@ -42,7 +43,9 @@ uint32_t next_time;
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -3,6 +3,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
USB Usb; USB Usb;
@ -45,7 +46,9 @@ void PrintAddress(uint8_t addr)
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)
@ -332,7 +335,7 @@ void printunkdescr( uint8_t* descr_ptr )
/* Print a string from Program Memory directly to save RAM */ /* Print a string from Program Memory directly to save RAM */
void printProgStr(const prog_char str[]) void printProgStr(prog_char str[])
{ {
char c; char c;
if(!str) return; if(!str) return;

View file

@ -4,6 +4,11 @@
// pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3] // pinout: D[4-7] -> GPOUT[4-7], RS-> GPOUT[2], E ->GPOUT[3]
#include <max_LCD.h> #include <max_LCD.h>
// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#include <SPI.h>
#endif
USB Usb; USB Usb;
Max_LCD lcd(&Usb); Max_LCD lcd(&Usb);

View file

@ -7,12 +7,13 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
class PLAsyncOper : public CDCAsyncOper class PLAsyncOper : public CDCAsyncOper
{ {
public: public:
virtual uint8_t OnInit(ACM *pacm); uint8_t OnInit(ACM *pacm);
}; };
uint8_t PLAsyncOper::OnInit(ACM *pacm) uint8_t PLAsyncOper::OnInit(ACM *pacm)
@ -50,7 +51,9 @@ PL2303 Pl(&Usb, &AsyncOper);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -8,11 +8,12 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
class PLAsyncOper : public CDCAsyncOper { class PLAsyncOper : public CDCAsyncOper {
public: public:
virtual uint8_t OnInit(ACM *pacm); uint8_t OnInit(ACM *pacm);
}; };
uint8_t PLAsyncOper::OnInit(ACM *pacm) { uint8_t PLAsyncOper::OnInit(ACM *pacm) {
@ -49,7 +50,9 @@ uint32_t read_delay;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
while(!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection #if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if(Usb.Init() == -1) if(Usb.Init() == -1)

View file

@ -14,6 +14,7 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
/* This sample code demonstrates the normal use of a TinyGPS object. /* This sample code demonstrates the normal use of a TinyGPS object.
@ -24,7 +25,7 @@
class PLAsyncOper : public CDCAsyncOper class PLAsyncOper : public CDCAsyncOper
{ {
public: public:
virtual uint8_t OnInit(ACM *pacm); uint8_t OnInit(ACM *pacm);
}; };
uint8_t PLAsyncOper::OnInit(ACM *pacm) uint8_t PLAsyncOper::OnInit(ACM *pacm)
@ -68,7 +69,9 @@ void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version()); Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
Serial.println("by Mikal Hart"); Serial.println("by Mikal Hart");

View file

@ -8,12 +8,13 @@
// Satisfy IDE, which only needs to see the include statment in the ino. // Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude #ifdef dobogusinclude
#include <spi4teensy3.h> #include <spi4teensy3.h>
#include <SPI.h>
#endif #endif
class PLAsyncOper : public CDCAsyncOper class PLAsyncOper : public CDCAsyncOper
{ {
public: public:
virtual uint8_t OnInit(ACM *pacm); uint8_t OnInit(ACM *pacm);
}; };
uint8_t PLAsyncOper::OnInit(ACM *pacm) uint8_t PLAsyncOper::OnInit(ACM *pacm)
@ -50,7 +51,9 @@ PL2303 Pl(&Usb, &AsyncOper);
void setup() void setup()
{ {
Serial.begin( 115200 ); Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start"); Serial.println("Start");
if (Usb.Init() == -1) if (Usb.Init() == -1)

View file

@ -36,7 +36,7 @@ public:
byteTotal = 0; byteTotal = 0;
}; };
virtual void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset);
}; };
template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE> template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE>

5
hid.h
View file

@ -156,7 +156,7 @@ protected:
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr); void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc); void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc);
virtual HIDReportParser* GetReportParser(uint8_t id); virtual HIDReportParser* GetReportParser(uint8_t id) {};
public: public:
@ -166,7 +166,8 @@ public:
const USB* GetUsb() { const USB* GetUsb() {
return pUsb; return pUsb;
}; };
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs);
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) {};
uint8_t SetProtocol(uint8_t iface, uint8_t protocol); uint8_t SetProtocol(uint8_t iface, uint8_t protocol);
uint8_t GetProtocol(uint8_t iface, uint8_t* dataptr); uint8_t GetProtocol(uint8_t iface, uint8_t* dataptr);

View file

@ -157,27 +157,6 @@ void KeyboardReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
prevState.bInfo[i] = buf[i]; prevState.bInfo[i] = buf[i];
}; };
uint8_t KeyboardReportParser::HandleLockingKeys(HID *hid, uint8_t key) {
uint8_t old_keys = kbdLockingKeys.bLeds;
switch (key) {
case UHS_HID_BOOT_KEY_NUM_LOCK:
kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock;
break;
case UHS_HID_BOOT_KEY_CAPS_LOCK:
kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock;
break;
case UHS_HID_BOOT_KEY_SCROLL_LOCK:
kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock;
break;
}
if (old_keys != kbdLockingKeys.bLeds && hid)
return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &kbdLockingKeys.bLeds));
return 0;
}
const uint8_t KeyboardReportParser::numKeys[10] PROGMEM = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')'}; const uint8_t KeyboardReportParser::numKeys[10] PROGMEM = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')'};
const uint8_t KeyboardReportParser::symKeysUp[12] PROGMEM = {'_', '+', '{', '}', '|', '~', ':', '"', '~', '<', '>', '?'}; const uint8_t KeyboardReportParser::symKeysUp[12] PROGMEM = {'_', '+', '{', '}', '|', '~', ':', '"', '~', '<', '>', '?'};
const uint8_t KeyboardReportParser::symKeysLo[12] PROGMEM = {'-', '=', '[', ']', '\\', ' ', ';', '\'', '`', ',', '.', '/'}; const uint8_t KeyboardReportParser::symKeysLo[12] PROGMEM = {'-', '=', '[', ']', '\\', ' ', ';', '\'', '`', ',', '.', '/'};

View file

@ -56,7 +56,7 @@ class MouseReportParser : public HIDReportParser {
} prevState; } prevState;
public: public:
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
protected: protected:
@ -144,10 +144,30 @@ public:
kbdLockingKeys.bLeds = 0; kbdLockingKeys.bLeds = 0;
}; };
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
protected: protected:
virtual uint8_t HandleLockingKeys(HID* hid, uint8_t key);
virtual uint8_t HandleLockingKeys(HID* hid, uint8_t key) {
uint8_t old_keys = kbdLockingKeys.bLeds;
switch(key) {
case UHS_HID_BOOT_KEY_NUM_LOCK:
kbdLockingKeys.kbdLeds.bmNumLock = ~kbdLockingKeys.kbdLeds.bmNumLock;
break;
case UHS_HID_BOOT_KEY_CAPS_LOCK:
kbdLockingKeys.kbdLeds.bmCapsLock = ~kbdLockingKeys.kbdLeds.bmCapsLock;
break;
case UHS_HID_BOOT_KEY_SCROLL_LOCK:
kbdLockingKeys.kbdLeds.bmScrollLock = ~kbdLockingKeys.kbdLeds.bmScrollLock;
break;
}
if(old_keys != kbdLockingKeys.bLeds && hid)
return (hid->SetReport(0, 0/*hid->GetIface()*/, 2, 0, 1, &kbdLockingKeys.bLeds));
return 0;
};
virtual void OnControlKeysChanged(uint8_t before, uint8_t after) { virtual void OnControlKeysChanged(uint8_t before, uint8_t after) {
}; };
@ -204,15 +224,16 @@ public:
}; };
// USBDeviceConfig implementation // USBDeviceConfig implementation
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t Release(); uint8_t Release();
virtual uint8_t Poll(); uint8_t Poll();
virtual uint8_t GetAddress() { virtual uint8_t GetAddress() {
return bAddress; return bAddress;
}; };
// UsbConfigXtracter implementation // UsbConfigXtracter implementation
// Method should be defined here if virtual.
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
virtual boolean DEVCLASSOK(uint8_t klass) { virtual boolean DEVCLASSOK(uint8_t klass) {

View file

@ -111,6 +111,7 @@ protected:
uint16_t totalSize; // Report size in bits uint16_t totalSize; // Report size in bits
// Method should be defined here if virtual.
virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn); virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn);
UsagePageFunc pfUsage; UsagePageFunc pfUsage;
@ -132,7 +133,7 @@ public:
theSkipper.Initialize(&theBuffer); theSkipper.Initialize(&theBuffer);
}; };
virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset); void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset);
enum { enum {
enErrorSuccess = 0 enErrorSuccess = 0
@ -156,6 +157,7 @@ class ReportDescParser2 : public ReportDescParserBase {
uint8_t bLen; // Report length uint8_t bLen; // Report length
protected: protected:
// Method should be defined here if virtual.
virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn); virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn);
public: public:
@ -167,6 +169,7 @@ public:
class UniversalReportParser : public HIDReportParser { class UniversalReportParser : public HIDReportParser {
public: public:
// Method should be defined here if virtual.
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
}; };

View file

@ -69,7 +69,7 @@ protected:
uint16_t PID, VID; // PID and VID of connected device uint16_t PID, VID; // PID and VID of connected device
// HID implementation // HID implementation
virtual HIDReportParser* GetReportParser(uint8_t id); HIDReportParser* GetReportParser(uint8_t id);
virtual uint8_t OnInitSuccessful() { virtual uint8_t OnInitSuccessful() {
return 0; return 0;
@ -83,12 +83,12 @@ public:
HIDUniversal(USB *p); HIDUniversal(USB *p);
// HID implementation // HID implementation
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs); bool SetReportParser(uint8_t id, HIDReportParser *prs);
// USBDeviceConfig implementation // USBDeviceConfig implementation
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t Release(); uint8_t Release();
virtual uint8_t Poll(); uint8_t Poll();
virtual uint8_t GetAddress() { virtual uint8_t GetAddress() {
return bAddress; return bAddress;
@ -99,7 +99,7 @@ public:
}; };
// UsbConfigXtracter implementation // UsbConfigXtracter implementation
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
}; };
#endif // __HIDUNIVERSAL_H__ #endif // __HIDUNIVERSAL_H__

View file

@ -519,18 +519,18 @@ public:
uint16_t GetSectorSize(uint8_t lun); uint16_t GetSectorSize(uint8_t lun);
// USBDeviceConfig implementation // USBDeviceConfig implementation
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed); uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t Release(); uint8_t Release();
virtual uint8_t Poll(); uint8_t Poll();
virtual uint8_t GetAddress() { virtual uint8_t GetAddress() {
return bAddress; return bAddress;
}; };
// UsbConfigXtracter implementation // UsbConfigXtracter implementation
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
virtual boolean DEVCLASSOK(uint8_t klass) { virtual boolean DEVCLASSOK(uint8_t klass) {
return (klass == USB_CLASS_MASS_STORAGE); return (klass == USB_CLASS_MASS_STORAGE);

View file

@ -88,10 +88,10 @@ public:
void command(uint8_t); void command(uint8_t);
#if defined(ARDUINO) && ARDUINO >=100 #if defined(ARDUINO) && ARDUINO >=100
virtual size_t write(uint8_t); size_t write(uint8_t);
using Print::write; using Print::write;
#else #else
virtual void write(uint8_t); void write(uint8_t);
#endif #endif
private: private:

View file

@ -191,10 +191,10 @@ public:
void PrintHubStatus(); void PrintHubStatus();
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed); uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
virtual uint8_t Release(); uint8_t Release();
virtual uint8_t Poll(); uint8_t Poll();
virtual void ResetHubPort(uint8_t port); void ResetHubPort(uint8_t port);
virtual uint8_t GetAddress() { virtual uint8_t GetAddress() {
return bAddress; return bAddress;