mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Merge branch 'SPI' into Galileo
Conflicts: avrpins.h settings.h usbhost.h
This commit is contained in:
commit
73f791c859
83 changed files with 1225 additions and 696 deletions
6
BTD.cpp
6
BTD.cpp
|
@ -380,6 +380,12 @@ uint8_t BTD::Poll() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void BTD::disconnect() {
|
||||
for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++)
|
||||
if(btService[i])
|
||||
btService[i]->disconnect();
|
||||
};
|
||||
|
||||
void BTD::HCI_event_task() {
|
||||
uint16_t length = BULK_MAXPKTSIZE; // Request more than 16 bytes anyway, the inTransfer routine will take care of this
|
||||
uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ BTD_EVENT_PIPE ].epAddr, &length, hcibuf); // Input on endpoint 1
|
||||
|
|
149
BTD.h
149
BTD.h
|
@ -189,73 +189,7 @@
|
|||
|
||||
#define PAIR 1
|
||||
|
||||
/* acl_handle_ok or it's a new connection */
|
||||
#if 0
|
||||
#define UHS_ACL_HANDLE_OK(x, y) ((uint16_t)(x[0]) | (uint16_t)(x[1] << 8)) == (y | 0x2000U)
|
||||
#else
|
||||
/*
|
||||
* Better implementation.
|
||||
* o One place for this code, it is reused four times in the source.
|
||||
* Perhaps it is better as a function.
|
||||
* o This should be faster since the && operation can early exit, this means
|
||||
* the shift would only be performed if the first byte matches.
|
||||
* o Casting is eliminated.
|
||||
* o How does this compare in code size? No difference. It is a free optimization.
|
||||
*/
|
||||
#define UHS_ACL_HANDLE_OK(x, y) ((x[0] == (y & 0xff)) && (x[1] == ((y >> 8) | 0x20)))
|
||||
#endif
|
||||
|
||||
class BTD;
|
||||
|
||||
/** All Bluetooth services should inherit this class. */
|
||||
class BluetoothService {
|
||||
public:
|
||||
BluetoothService(BTD *p) : pBtd(p) {};
|
||||
/**
|
||||
* Used to pass acldata to the Bluetooth service.
|
||||
* @param ACLData Pointer to the incoming acldata.
|
||||
*/
|
||||
virtual void ACLData(uint8_t* ACLData) = 0;
|
||||
/** Used to run the different state machines in the Bluetooth service. */
|
||||
virtual void Run() = 0;
|
||||
/** Used to reset the Bluetooth service. */
|
||||
virtual void Reset() = 0;
|
||||
/** Used to disconnect both the L2CAP Channel and the HCI Connection for the Bluetooth service. */
|
||||
virtual void disconnect() = 0;
|
||||
|
||||
/**
|
||||
* Used to call your own function when the device is successfully initialized.
|
||||
* @param funcOnInit Function to call.
|
||||
*/
|
||||
void attachOnInit(void (*funcOnInit)(void)) {
|
||||
pFuncOnInit = funcOnInit; // TODO: This really belong in a class of it's own as it is repeated several times
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called when a device is successfully initialized.
|
||||
* 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.
|
||||
*/
|
||||
virtual void onInit() = 0;
|
||||
|
||||
// TODO: Implement "UHS_ACL_HANDLE_OK" function
|
||||
|
||||
/** Pointer to function called in onInit(). */
|
||||
void (*pFuncOnInit)(void);
|
||||
|
||||
/** Pointer to BTD instance. */
|
||||
BTD *pBtd;
|
||||
|
||||
/** The HCI Handle for the connection. */
|
||||
uint16_t hci_handle;
|
||||
|
||||
/** L2CAP flags of received Bluetooth events. */
|
||||
uint32_t l2cap_event_flag;
|
||||
|
||||
/** Identifier for L2CAP commands. */
|
||||
uint8_t identifier;
|
||||
};
|
||||
class BluetoothService;
|
||||
|
||||
/**
|
||||
* The Bluetooth Dongle class will take care of all the USB communication
|
||||
|
@ -277,7 +211,7 @@ public:
|
|||
* @param lowspeed Speed of the device.
|
||||
* @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.
|
||||
* @param parent Hub number.
|
||||
|
@ -285,17 +219,17 @@ public:
|
|||
* @param lowspeed Speed of the device.
|
||||
* @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.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Release();
|
||||
uint8_t Release();
|
||||
/**
|
||||
* Poll the USB Input endpoints and run the state machines.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Poll();
|
||||
|
||||
/**
|
||||
* Get the device address.
|
||||
|
@ -318,7 +252,7 @@ public:
|
|||
* @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) {
|
||||
virtual bool DEVCLASSOK(uint8_t klass) {
|
||||
return (klass == USB_CLASS_WIRELESS_CTRL);
|
||||
};
|
||||
|
||||
|
@ -329,7 +263,7 @@ public:
|
|||
* @param pid The device's PID.
|
||||
* @return Returns true if the device's VID and PID matches this driver.
|
||||
*/
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
if(vid == IOGEAR_GBU521_VID && pid == IOGEAR_GBU521_PID)
|
||||
return true;
|
||||
if(my_bdaddr[0] != 0x00 || my_bdaddr[1] != 0x00 || my_bdaddr[2] != 0x00 || my_bdaddr[3] != 0x00 || my_bdaddr[4] != 0x00 || my_bdaddr[5] != 0x00) { // Check if Bluetooth address is set
|
||||
|
@ -349,29 +283,25 @@ public:
|
|||
* @param proto Interface Protocol.
|
||||
* @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. */
|
||||
void disconnect() {
|
||||
for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++)
|
||||
if(btService[i])
|
||||
btService[i]->disconnect();
|
||||
};
|
||||
void disconnect();
|
||||
|
||||
/**
|
||||
* Register Bluetooth dongle members/services.
|
||||
* @param pService Pointer to BluetoothService class instance.
|
||||
* @return The service ID on success or -1 on fail.
|
||||
*/
|
||||
int8_t registerServiceClass(BluetoothService *pService) {
|
||||
int8_t registerBluetoothService(BluetoothService *pService) {
|
||||
for(uint8_t i = 0; i < BTD_NUM_SERVICES; i++) {
|
||||
if(!btService[i]) {
|
||||
btService[i] = pService;
|
||||
return i; // Return ID
|
||||
}
|
||||
}
|
||||
return -1; // ErrorregisterServiceClass
|
||||
return -1; // Error registering BluetoothService
|
||||
};
|
||||
|
||||
/** @name HCI Commands */
|
||||
|
@ -628,4 +558,61 @@ private:
|
|||
void setBdaddr(uint8_t* BDADDR);
|
||||
void setMoveBdaddr(uint8_t* BDADDR);
|
||||
};
|
||||
|
||||
/** All Bluetooth services should inherit this class. */
|
||||
class BluetoothService {
|
||||
public:
|
||||
BluetoothService(BTD *p) : pBtd(p) {
|
||||
if(pBtd)
|
||||
pBtd->registerBluetoothService(this); // Register it as a Bluetooth service
|
||||
};
|
||||
/**
|
||||
* Used to pass acldata to the Bluetooth service.
|
||||
* @param ACLData Pointer to the incoming acldata.
|
||||
*/
|
||||
virtual void ACLData(uint8_t* ACLData) = 0;
|
||||
/** Used to run the different state machines in the Bluetooth service. */
|
||||
virtual void Run() = 0;
|
||||
/** Used to reset the Bluetooth service. */
|
||||
virtual void Reset() = 0;
|
||||
/** Used to disconnect both the L2CAP Channel and the HCI Connection for the Bluetooth service. */
|
||||
virtual void disconnect() = 0;
|
||||
|
||||
/**
|
||||
* Used to call your own function when the device is successfully initialized.
|
||||
* @param funcOnInit Function to call.
|
||||
*/
|
||||
void attachOnInit(void (*funcOnInit)(void)) {
|
||||
pFuncOnInit = funcOnInit; // TODO: This really belong in a class of it's own as it is repeated several times
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called when a device is successfully initialized.
|
||||
* 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.
|
||||
*/
|
||||
virtual void onInit() = 0;
|
||||
|
||||
/** Used to check if the incoming L2CAP data matches the HCI Handle */
|
||||
bool checkHciHandle(uint8_t *buf, uint16_t handle) {
|
||||
return (buf[0] == (handle & 0xFF)) && (buf[1] == ((handle >> 8) | 0x20));
|
||||
}
|
||||
|
||||
/** Pointer to function called in onInit(). */
|
||||
void (*pFuncOnInit)(void);
|
||||
|
||||
/** Pointer to BTD instance. */
|
||||
BTD *pBtd;
|
||||
|
||||
/** The HCI Handle for the connection. */
|
||||
uint16_t hci_handle;
|
||||
|
||||
/** L2CAP flags of received Bluetooth events. */
|
||||
uint32_t l2cap_event_flag;
|
||||
|
||||
/** Identifier for L2CAP commands. */
|
||||
uint8_t identifier;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,9 +26,6 @@ protocolMode(HID_BOOT_PROTOCOL) {
|
|||
for(uint8_t i = 0; i < NUM_PARSERS; i++)
|
||||
pRptParser[i] = NULL;
|
||||
|
||||
if(pBtd)
|
||||
pBtd->registerServiceClass(this); // Register it as a Bluetooth service
|
||||
|
||||
pBtd->pairWithHIDDevice = pair;
|
||||
pBtd->btdPin = pin;
|
||||
|
||||
|
@ -68,8 +65,8 @@ void BTHID::ACLData(uint8_t* l2capinbuf) {
|
|||
}
|
||||
}
|
||||
}
|
||||
//if((l2capinbuf[0] | (uint16_t)l2capinbuf[1] << 8) == (hci_handle | 0x2000U)) { // acl_handle_ok or it's a new connection
|
||||
if(UHS_ACL_HANDLE_OK(l2capinbuf, hci_handle)) { // acl_handle_ok or it's a new connection
|
||||
|
||||
if(checkHciHandle(l2capinbuf, hci_handle)) { // acl_handle_ok
|
||||
if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { // l2cap_control - Channel ID for ACL-U
|
||||
if(l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||
#ifdef DEBUG_USB_HOST
|
||||
|
|
10
BTHID.h
10
BTHID.h
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
/** @name BluetoothService implementation */
|
||||
/** Used this to disconnect the devices. */
|
||||
virtual void disconnect();
|
||||
void disconnect();
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
|
@ -94,17 +94,17 @@ protected:
|
|||
* Used to pass acldata to the services.
|
||||
* @param ACLData Incoming acldata.
|
||||
*/
|
||||
virtual void ACLData(uint8_t* ACLData);
|
||||
void ACLData(uint8_t* ACLData);
|
||||
/** Used to run part of the state machine. */
|
||||
virtual void Run();
|
||||
void Run();
|
||||
/** Use this to reset the service. */
|
||||
virtual void Reset();
|
||||
void Reset();
|
||||
/**
|
||||
* Called when a device is successfully initialized.
|
||||
* 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.
|
||||
*/
|
||||
virtual void onInit() {
|
||||
void onInit() {
|
||||
if(pFuncOnInit)
|
||||
pFuncOnInit(); // Call the user function
|
||||
OnInitBTHID();
|
||||
|
|
28
PS3BT.cpp
28
PS3BT.cpp
|
@ -23,9 +23,6 @@
|
|||
PS3BT::PS3BT(BTD *p, uint8_t btadr5, uint8_t btadr4, uint8_t btadr3, uint8_t btadr2, uint8_t btadr1, uint8_t btadr0) :
|
||||
BluetoothService(p) // Pointer to USB class instance - mandatory
|
||||
{
|
||||
if(pBtd)
|
||||
pBtd->registerServiceClass(this); // Register it as a Bluetooth service
|
||||
|
||||
pBtd->my_bdaddr[5] = btadr5; // Change to your dongle's Bluetooth address instead
|
||||
pBtd->my_bdaddr[4] = btadr4;
|
||||
pBtd->my_bdaddr[3] = btadr3;
|
||||
|
@ -232,8 +229,7 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
|||
activeConnection = true;
|
||||
hci_handle = pBtd->hci_handle; // Store the HCI Handle for the connection
|
||||
l2cap_state = L2CAP_WAIT;
|
||||
for(uint8_t i = 0; i < 30; i++)
|
||||
remote_name[i] = pBtd->remote_name[i]; // Store the remote name for the connection
|
||||
remote_name_first = pBtd->remote_name[0]; // Store the first letter in remote name for the connection
|
||||
#ifdef DEBUG_USB_HOST
|
||||
if(pBtd->hci_version < 3) { // Check the HCI Version of the Bluetooth dongle
|
||||
Notify(PSTR("\r\nYour dongle may not support reading the analog buttons, sensors and status\r\nYour HCI Version is: "), 0x80);
|
||||
|
@ -244,10 +240,10 @@ void PS3BT::ACLData(uint8_t* ACLData) {
|
|||
}
|
||||
}
|
||||
}
|
||||
//if((ACLData[0] | (uint16_t)ACLData[1] << 8) == (hci_handle | 0x2000U)) { //acl_handle_ok
|
||||
if(UHS_ACL_HANDLE_OK(ACLData, hci_handle)) { //acl_handle_ok
|
||||
|
||||
if(checkHciHandle(ACLData, hci_handle)) { // acl_handle_ok
|
||||
memcpy(l2capinbuf, ACLData, BULK_MAXPKTSIZE);
|
||||
if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { //l2cap_control - Channel ID for ACL-U
|
||||
if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { // l2cap_control - Channel ID for ACL-U
|
||||
if(l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||
|
@ -419,7 +415,7 @@ void PS3BT::L2CAP_task() {
|
|||
#ifdef DEBUG_USB_HOST
|
||||
Notify(PSTR("\r\nHID Interrupt Successfully Configured"), 0x80);
|
||||
#endif
|
||||
if(remote_name[0] == 'M') { // First letter in Motion Controller ('M')
|
||||
if(remote_name_first == 'M') { // First letter in Motion Controller ('M')
|
||||
memset(l2capinbuf, 0, BULK_MAXPKTSIZE); // Reset l2cap in buffer as it sometimes read it as a button has been pressed
|
||||
l2cap_state = TURN_ON_LED;
|
||||
} else
|
||||
|
@ -470,18 +466,18 @@ void PS3BT::Run() {
|
|||
|
||||
case TURN_ON_LED:
|
||||
if(millis() - timer > 1000) { // loop 1 second before sending the command
|
||||
if(remote_name[0] == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P')
|
||||
if(remote_name_first == 'P') { // First letter in PLAYSTATION(R)3 Controller ('P')
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Notify(PSTR("\r\nDualshock 3 Controller Enabled\r\n"), 0x80);
|
||||
#endif
|
||||
PS3Connected = true;
|
||||
} else if(remote_name[0] == 'N') { // First letter in Navigation Controller ('N')
|
||||
} else if(remote_name_first == 'N') { // First letter in Navigation Controller ('N')
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Notify(PSTR("\r\nNavigation Controller Enabled\r\n"), 0x80);
|
||||
#endif
|
||||
PS3NavigationConnected = true;
|
||||
} else if(remote_name[0] == 'M') { // First letter in Motion Controller ('M')
|
||||
timerBulbRumble = millis();
|
||||
} else if(remote_name_first == 'M') { // First letter in Motion Controller ('M')
|
||||
timer = millis();
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Notify(PSTR("\r\nMotion Controller Enabled\r\n"), 0x80);
|
||||
#endif
|
||||
|
@ -497,10 +493,10 @@ void PS3BT::Run() {
|
|||
break;
|
||||
|
||||
case L2CAP_DONE:
|
||||
if(PS3MoveConnected) { // The Bulb and rumble values, has to be send at aproximatly every 5th second for it to stay on
|
||||
if(millis() - timerBulbRumble > 4000) { // Send at least every 4th second
|
||||
if(PS3MoveConnected) { // The Bulb and rumble values, has to be send at approximately every 5th second for it to stay on
|
||||
if(millis() - timer > 4000) { // Send at least every 4th second
|
||||
HIDMove_Command(HIDMoveBuffer, HID_BUFFERSIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on
|
||||
timerBulbRumble = millis();
|
||||
timer = millis();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
16
PS3BT.h
16
PS3BT.h
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
/** @name BluetoothService implementation */
|
||||
/** Used this to disconnect any of the controllers. */
|
||||
virtual void disconnect();
|
||||
void disconnect();
|
||||
/**@}*/
|
||||
|
||||
/** @name PS3 Controller functions */
|
||||
|
@ -189,17 +189,17 @@ protected:
|
|||
* Used to pass acldata to the services.
|
||||
* @param ACLData Incoming acldata.
|
||||
*/
|
||||
virtual void ACLData(uint8_t* ACLData);
|
||||
void ACLData(uint8_t* ACLData);
|
||||
/** Used to run part of the state machine. */
|
||||
virtual void Run();
|
||||
void Run();
|
||||
/** Use this to reset the service. */
|
||||
virtual void Reset();
|
||||
void Reset();
|
||||
/**
|
||||
* Called when the controller is successfully initialized.
|
||||
* 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.
|
||||
*/
|
||||
virtual void onInit();
|
||||
void onInit();
|
||||
/**@}*/
|
||||
|
||||
private:
|
||||
|
@ -207,7 +207,7 @@ private:
|
|||
void L2CAP_task(); // L2CAP state machine
|
||||
|
||||
/* Variables filled from HCI event management */
|
||||
uint8_t remote_name[30]; // First 30 chars of remote name
|
||||
char remote_name_first; // First letter in remote name
|
||||
bool activeConnection; // Used to indicate if it's already has established a connection
|
||||
|
||||
/* Variables used by high level L2CAP task */
|
||||
|
@ -215,14 +215,12 @@ private:
|
|||
|
||||
uint32_t lastMessageTime; // Variable used to store the millis value of the last message.
|
||||
|
||||
uint32_t timer;
|
||||
|
||||
uint32_t ButtonState;
|
||||
uint32_t OldButtonState;
|
||||
uint32_t ButtonClickState;
|
||||
|
||||
uint32_t timer; // Timer used to limit time between messages and also used to continuously set PS3 Move controller Bulb and rumble values
|
||||
uint32_t timerHID; // Timer used see if there has to be a delay before a new HID command
|
||||
uint32_t timerBulbRumble; // used to continuously set PS3 Move controller Bulb and rumble values
|
||||
|
||||
uint8_t l2capinbuf[BULK_MAXPKTSIZE]; // General purpose buffer for L2CAP in data
|
||||
uint8_t HIDBuffer[HID_BUFFERSIZE]; // Used to store HID commands
|
||||
|
|
8
PS3USB.h
8
PS3USB.h
|
@ -65,17 +65,17 @@ public:
|
|||
* @param lowspeed Speed of the device.
|
||||
* @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.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Release();
|
||||
uint8_t Release();
|
||||
/**
|
||||
* Poll the USB Input endpoins and run the state machines.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Poll();
|
||||
|
||||
/**
|
||||
* Get the device address.
|
||||
|
@ -99,7 +99,7 @@ public:
|
|||
* @param pid The device's PID.
|
||||
* @return Returns true if the device's VID and PID matches this driver.
|
||||
*/
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return (vid == PS3_VID && (pid == PS3_PID || pid == PS3NAVIGATION_PID || pid == PS3MOVE_PID));
|
||||
};
|
||||
/**@}*/
|
||||
|
|
2
PS4USB.h
2
PS4USB.h
|
@ -119,7 +119,7 @@ protected:
|
|||
* @param pid The device's PID.
|
||||
* @return Returns true if the device's VID and PID matches this driver.
|
||||
*/
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return (vid == PS4_VID && pid == PS4_PID);
|
||||
};
|
||||
/**@}*/
|
||||
|
|
6
PSBuzz.h
6
PSBuzz.h
|
@ -143,14 +143,14 @@ protected:
|
|||
* @param len The length of the incoming data.
|
||||
* @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.
|
||||
* 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.
|
||||
*/
|
||||
virtual uint8_t OnInitSuccessful();
|
||||
uint8_t OnInitSuccessful();
|
||||
/**@}*/
|
||||
|
||||
/** Used to reset the different buffers to their default values */
|
||||
|
@ -169,7 +169,7 @@ protected:
|
|||
* @param pid The device's PID.
|
||||
* @return Returns true if the device's VID and PID matches this driver.
|
||||
*/
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return (vid == PSBUZZ_VID && pid == PSBUZZ_PID);
|
||||
};
|
||||
/**@}*/
|
||||
|
|
|
@ -71,7 +71,7 @@ Now quit the Arduino IDE and reopen it.
|
|||
|
||||
Now you should be able to go open all the examples codes by navigating to "File>Examples>USB\_Host\_Shield\_20" and then select the example you will like to open.
|
||||
|
||||
For more information visit the following site: <http://arduino.cc/en/Guide/Libraries>.
|
||||
For more information visit the following sites: <http://arduino.cc/en/Guide/Libraries> and <https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use>.
|
||||
|
||||
# How to use the library
|
||||
|
||||
|
@ -99,6 +99,8 @@ Currently the following boards are supported by the library:
|
|||
* Balanduino
|
||||
* Sanguino
|
||||
* Black Widdow
|
||||
* RedBearLab nRF51822
|
||||
* If you are using the RedBearLab nRF51822, then you must include the RedBearLab SPI library like so: ```#include <SPI.h>``` in your .ino file.
|
||||
|
||||
The following boards need to be activated manually in [settings.h](settings.h):
|
||||
|
||||
|
@ -283,6 +285,8 @@ More information about the controller can be found at the following sites:
|
|||
|
||||
The shield is using SPI for communicating with the MAX3421E USB host controller. It uses the SCK, MISO and MOSI pins via the ICSP on your board.
|
||||
|
||||
Note this means that it uses pin 13, 12, 11 on an Arduino Uno, so these pins can not be used for anything else!
|
||||
|
||||
Furthermore it uses one pin as SS and one INT pin. These are by default located on pin 10 and 9 respectively. They can easily be reconfigured in case you need to use them for something else by cutting the jumper on the shield and then solder a wire from the pad to the new pin.
|
||||
|
||||
After that you need modify the following entry in [UsbCore.h](UsbCore.h):
|
||||
|
|
9
SPP.cpp
9
SPP.cpp
|
@ -45,9 +45,6 @@ const uint8_t rfcomm_crc_table[256] PROGMEM = {/* reversed, 8-bit, poly=0x07 */
|
|||
SPP::SPP(BTD *p, const char* name, const char* pin) :
|
||||
BluetoothService(p) // Pointer to BTD class instance - mandatory
|
||||
{
|
||||
if(pBtd)
|
||||
pBtd->registerServiceClass(this); // Register it as a Bluetooth service
|
||||
|
||||
pBtd->btdName = name;
|
||||
pBtd->btdPin = pin;
|
||||
|
||||
|
@ -98,9 +95,9 @@ void SPP::ACLData(uint8_t* l2capinbuf) {
|
|||
}
|
||||
}
|
||||
}
|
||||
//if((l2capinbuf[0] | (uint16_t)l2capinbuf[1] << 8) == (hci_handle | 0x2000U)) { // acl_handle_ok
|
||||
if(UHS_ACL_HANDLE_OK(l2capinbuf, hci_handle)) { // acl_handle_ok
|
||||
if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { //l2cap_control - Channel ID for ACL-U
|
||||
|
||||
if(checkHciHandle(l2capinbuf, hci_handle)) { // acl_handle_ok
|
||||
if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { // l2cap_control - Channel ID for ACL-U
|
||||
if(l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||
|
|
26
SPP.h
26
SPP.h
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
/** @name BluetoothService implementation */
|
||||
/** Used this to disconnect the virtual serial port. */
|
||||
virtual void disconnect();
|
||||
void disconnect();
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
|
@ -88,22 +88,22 @@ public:
|
|||
* Get number of bytes waiting 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. */
|
||||
virtual void flush(void) {
|
||||
void flush(void) {
|
||||
send();
|
||||
};
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
virtual int peek(void);
|
||||
int peek(void);
|
||||
/**
|
||||
* Used to read the buffer.
|
||||
* @return Return the byte. Will return -1 if no bytes are available.
|
||||
*/
|
||||
virtual int read(void);
|
||||
int read(void);
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >=100
|
||||
/**
|
||||
|
@ -111,14 +111,14 @@ public:
|
|||
* @param data The byte to write.
|
||||
* @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.
|
||||
* @param data The data array to send.
|
||||
* @param size Size of the data.
|
||||
* @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 */
|
||||
using Print::write;
|
||||
#else
|
||||
|
@ -126,13 +126,13 @@ public:
|
|||
* 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.
|
||||
*/
|
||||
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.
|
||||
* @param data The data array to send.
|
||||
* @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
|
||||
|
||||
/** Discard all the bytes in the buffer. */
|
||||
|
@ -151,17 +151,17 @@ protected:
|
|||
* Used to pass acldata to the services.
|
||||
* @param ACLData Incoming acldata.
|
||||
*/
|
||||
virtual void ACLData(uint8_t* ACLData);
|
||||
void ACLData(uint8_t* ACLData);
|
||||
/** Used to establish the connection automatically. */
|
||||
virtual void Run();
|
||||
void Run();
|
||||
/** Use this to reset the service. */
|
||||
virtual void Reset();
|
||||
void Reset();
|
||||
/**
|
||||
* Called when a device is successfully initialized.
|
||||
* 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.
|
||||
*/
|
||||
virtual void onInit();
|
||||
void onInit();
|
||||
/**@}*/
|
||||
|
||||
private:
|
||||
|
|
13
Usb.cpp
13
Usb.cpp
|
@ -698,17 +698,20 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
// Allocate new address according to device class
|
||||
//bAddress = addrPool.AllocAddress(parent, false, port);
|
||||
|
||||
//if (!bAddress)
|
||||
// return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||
uint16_t vid = udd->idVendor;
|
||||
uint16_t pid = udd->idProduct;
|
||||
uint8_t klass = udd->bDeviceClass;
|
||||
|
||||
uint8_t subklass = udd->bDeviceSubClass;
|
||||
// Attempt to configure if VID/PID or device class matches with a driver
|
||||
// Qualify with subclass too.
|
||||
//
|
||||
// VID/PID & class tests default to false for drivers not yet ported
|
||||
// subclass defaults to true, so you don't have to define it if you don't have to.
|
||||
//
|
||||
for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
|
||||
if(!devConfig[devConfigIndex]) continue; // no driver
|
||||
if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed
|
||||
if(devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass)) {
|
||||
if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) {
|
||||
rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
|
||||
if(rcode != USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED)
|
||||
break;
|
||||
|
@ -724,7 +727,7 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
|
||||
if(!devConfig[devConfigIndex]) continue;
|
||||
if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed
|
||||
if(devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass)) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above
|
||||
if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above
|
||||
rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
|
||||
|
||||
//printf("ERROR ENUMERATING %2.2x\r\n", rcode);
|
||||
|
|
13
UsbCore.h
13
UsbCore.h
|
@ -143,13 +143,18 @@ public:
|
|||
return;
|
||||
} // Note used for hubs only!
|
||||
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual boolean DEVCLASSOK(uint8_t klass) {
|
||||
virtual bool DEVCLASSOK(uint8_t klass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool DEVSUBCLASSOK(uint8_t subklass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* USB Setup Packet Structure */
|
||||
|
@ -236,8 +241,8 @@ public:
|
|||
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr);
|
||||
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value);
|
||||
/**/
|
||||
uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, boolean direction);
|
||||
uint8_t ctrlStatus(uint8_t ep, boolean direction, uint16_t nak_limit);
|
||||
uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, bool direction);
|
||||
uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit);
|
||||
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data);
|
||||
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data);
|
||||
uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit);
|
||||
|
|
13
Wii.cpp
13
Wii.cpp
|
@ -85,17 +85,14 @@ const uint32_t WII_PROCONTROLLER_BUTTONS[] PROGMEM = {
|
|||
WII::WII(BTD *p, bool pair) :
|
||||
BluetoothService(p) // Pointer to USB class instance - mandatory
|
||||
{
|
||||
if(pBtd)
|
||||
pBtd->registerServiceClass(this); // Register it as a Bluetooth service
|
||||
|
||||
pBtd->pairWithWii = pair;
|
||||
|
||||
HIDBuffer[0] = 0xA2; // HID BT DATA_request (0xA0) | Report Type (Output 0x02)
|
||||
|
||||
/* Set device cid for the control and intterrupt channelse - LSB */
|
||||
control_dcid[0] = 0x60; //0x0060
|
||||
control_dcid[0] = 0x60; // 0x0060
|
||||
control_dcid[1] = 0x00;
|
||||
interrupt_dcid[0] = 0x61; //0x0061
|
||||
interrupt_dcid[0] = 0x61; // 0x0061
|
||||
interrupt_dcid[1] = 0x00;
|
||||
|
||||
Reset();
|
||||
|
@ -145,9 +142,9 @@ void WII::ACLData(uint8_t* l2capinbuf) {
|
|||
}
|
||||
}
|
||||
}
|
||||
//if((l2capinbuf[0] | (uint16_t)l2capinbuf[1] << 8) == (hci_handle | 0x2000U)) { // acl_handle_ok or it's a new connection
|
||||
if(UHS_ACL_HANDLE_OK(l2capinbuf, hci_handle)) { // acl_handle_ok or it's a new connection
|
||||
if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { //l2cap_control - Channel ID for ACL-U
|
||||
|
||||
if(checkHciHandle(l2capinbuf, hci_handle)) { // acl_handle_ok
|
||||
if((l2capinbuf[6] | (l2capinbuf[7] << 8)) == 0x0001U) { // l2cap_control - Channel ID for ACL-U
|
||||
if(l2capinbuf[8] == L2CAP_CMD_COMMAND_REJECT) {
|
||||
#ifdef DEBUG_USB_HOST
|
||||
Notify(PSTR("\r\nL2CAP Command Rejected - Reason: "), 0x80);
|
||||
|
|
10
Wii.h
10
Wii.h
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
/** @name BluetoothService implementation */
|
||||
/** Used this to disconnect any of the controllers. */
|
||||
virtual void disconnect();
|
||||
void disconnect();
|
||||
/**@}*/
|
||||
|
||||
/** @name Wii Controller functions */
|
||||
|
@ -381,17 +381,17 @@ protected:
|
|||
* Used to pass acldata to the services.
|
||||
* @param ACLData Incoming acldata.
|
||||
*/
|
||||
virtual void ACLData(uint8_t* ACLData);
|
||||
void ACLData(uint8_t* ACLData);
|
||||
/** Used to run part of the state machine. */
|
||||
virtual void Run();
|
||||
void Run();
|
||||
/** Use this to reset the service. */
|
||||
virtual void Reset();
|
||||
void Reset();
|
||||
/**
|
||||
* Called when the controller is successfully initialized.
|
||||
* 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.
|
||||
*/
|
||||
virtual void onInit();
|
||||
void onInit();
|
||||
/**@}*/
|
||||
|
||||
private:
|
||||
|
|
|
@ -59,17 +59,17 @@ public:
|
|||
* @param lowspeed Speed of the device.
|
||||
* @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.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Release();
|
||||
uint8_t Release();
|
||||
/**
|
||||
* Poll the USB Input endpoins and run the state machines.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Poll();
|
||||
|
||||
/**
|
||||
* Get the device address.
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
* @param pid The device's PID.
|
||||
* @return Returns true if the device's VID and PID matches this driver.
|
||||
*/
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID) && (pid == XBOX_OLD_PID1 || pid == XBOX_OLD_PID2 || pid == XBOX_OLD_PID3 || pid == XBOX_OLD_PID4));
|
||||
};
|
||||
/**@}*/
|
||||
|
|
10
XBOXRECV.h
10
XBOXRECV.h
|
@ -68,7 +68,7 @@ public:
|
|||
* @param lowspeed Speed of the device.
|
||||
* @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.
|
||||
* @param parent Hub number.
|
||||
|
@ -76,17 +76,17 @@ public:
|
|||
* @param lowspeed Speed of the device.
|
||||
* @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.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Release();
|
||||
uint8_t Release();
|
||||
/**
|
||||
* Poll the USB Input endpoins and run the state machines.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Poll();
|
||||
|
||||
/**
|
||||
* Get the device address.
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
* @param pid The device's PID.
|
||||
* @return Returns true if the device's VID and PID matches this driver.
|
||||
*/
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID) && (pid == XBOX_WIRELESS_RECEIVER_PID || pid == XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID));
|
||||
};
|
||||
/**@}*/
|
||||
|
|
|
@ -105,7 +105,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
|||
Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB"), 0x80);
|
||||
#endif
|
||||
goto FailUnknownDevice;
|
||||
} else if(PID != XBOX_WIRED_PID && PID != MADCATZ_WIRED_PID && PID != GAMESTOP_WIRED_PID && PID != AFTERGLOW_WIRED_PID) // Check PID
|
||||
} else if(PID != XBOX_WIRED_PID && PID != MADCATZ_WIRED_PID && PID != GAMESTOP_WIRED_PID && PID != AFTERGLOW_WIRED_PID && PID != JOYTECH_WIRED_PID) // Check PID
|
||||
goto FailUnknownDevice;
|
||||
|
||||
// Allocate new address according to device class
|
||||
|
|
11
XBOXUSB.h
11
XBOXUSB.h
|
@ -41,6 +41,7 @@
|
|||
#define XBOX_WIRELESS_RECEIVER_PID 0x0719 // Microsoft Wireless Gaming Receiver
|
||||
#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID 0x0291 // Third party Wireless Gaming Receiver
|
||||
#define MADCATZ_WIRED_PID 0xF016 // Mad Catz wired controller
|
||||
#define JOYTECH_WIRED_PID 0xBEEF // For Joytech wired controller
|
||||
#define GAMESTOP_WIRED_PID 0x0401 // Gamestop wired controller
|
||||
#define AFTERGLOW_WIRED_PID 0x0213 // Afterglow wired controller - it uses the same VID as a Gamestop controller
|
||||
|
||||
|
@ -65,17 +66,17 @@ public:
|
|||
* @param lowspeed Speed of the device.
|
||||
* @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.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Release();
|
||||
uint8_t Release();
|
||||
/**
|
||||
* Poll the USB Input endpoins and run the state machines.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Poll();
|
||||
|
||||
/**
|
||||
* Get the device address.
|
||||
|
@ -99,8 +100,8 @@ public:
|
|||
* @param pid The device's PID.
|
||||
* @return Returns true if the device's VID and PID matches this driver.
|
||||
*/
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID || vid == GAMESTOP_VID) && (pid == XBOX_WIRED_PID || pid == MADCATZ_WIRED_PID || pid == GAMESTOP_WIRED_PID || pid == AFTERGLOW_WIRED_PID));
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return ((vid == XBOX_VID || vid == MADCATZ_VID || vid == JOYTECH_VID || vid == GAMESTOP_VID) && (pid == XBOX_WIRED_PID || pid == MADCATZ_WIRED_PID || pid == GAMESTOP_WIRED_PID || pid == AFTERGLOW_WIRED_PID || pid == JOYTECH_WIRED_PID));
|
||||
};
|
||||
/**@}*/
|
||||
|
||||
|
|
10
adk.h
10
adk.h
|
@ -96,9 +96,9 @@ public:
|
|||
|
||||
|
||||
// USBDeviceConfig implementation
|
||||
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
virtual uint8_t Release();
|
||||
uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Release();
|
||||
|
||||
virtual uint8_t Poll() {
|
||||
return 0;
|
||||
|
@ -112,12 +112,12 @@ public:
|
|||
return ready;
|
||||
};
|
||||
|
||||
virtual boolean VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return (vid == ADK_VID && (pid == ADK_PID || pid == ADB_PID));
|
||||
};
|
||||
|
||||
//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 ...
|
||||
|
||||
/* get ADK protocol version */
|
||||
|
|
99
avrpins.h
99
avrpins.h
|
@ -959,6 +959,58 @@ MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected
|
|||
|
||||
#undef MAKE_PIN
|
||||
|
||||
#elif defined(RBL_NRF51822)
|
||||
|
||||
#define MAKE_PIN(className, pin) \
|
||||
class className { \
|
||||
public: \
|
||||
static void Set() { \
|
||||
nrf_gpio_pin_set(pin); \
|
||||
} \
|
||||
static void Clear() { \
|
||||
nrf_gpio_pin_clear(pin); \
|
||||
} \
|
||||
static void SetDirRead() { \
|
||||
nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL); \
|
||||
} \
|
||||
static void SetDirWrite() { \
|
||||
nrf_gpio_cfg_output(pin); \
|
||||
} \
|
||||
static uint8_t IsSet() { \
|
||||
return (uint8_t)nrf_gpio_pin_read(pin); \
|
||||
} \
|
||||
};
|
||||
|
||||
// See: pin_transform.c in RBL nRF51822 SDK
|
||||
MAKE_PIN(P0, Pin_nRF51822_to_Arduino(D0));
|
||||
MAKE_PIN(P1, Pin_nRF51822_to_Arduino(D1));
|
||||
MAKE_PIN(P2, Pin_nRF51822_to_Arduino(D2));
|
||||
MAKE_PIN(P3, Pin_nRF51822_to_Arduino(D3));
|
||||
MAKE_PIN(P4, Pin_nRF51822_to_Arduino(D4));
|
||||
MAKE_PIN(P5, Pin_nRF51822_to_Arduino(D5));
|
||||
MAKE_PIN(P6, Pin_nRF51822_to_Arduino(D6));
|
||||
MAKE_PIN(P7, Pin_nRF51822_to_Arduino(D7));
|
||||
MAKE_PIN(P8, Pin_nRF51822_to_Arduino(D8));
|
||||
MAKE_PIN(P9, Pin_nRF51822_to_Arduino(D9)); // INT
|
||||
MAKE_PIN(P10, Pin_nRF51822_to_Arduino(D10)); // SS
|
||||
MAKE_PIN(P11, Pin_nRF51822_to_Arduino(D11));
|
||||
MAKE_PIN(P12, Pin_nRF51822_to_Arduino(D12));
|
||||
MAKE_PIN(P13, Pin_nRF51822_to_Arduino(D13));
|
||||
MAKE_PIN(P14, Pin_nRF51822_to_Arduino(D14));
|
||||
MAKE_PIN(P15, Pin_nRF51822_to_Arduino(D15));
|
||||
MAKE_PIN(P17, Pin_nRF51822_to_Arduino(D17)); // MISO
|
||||
MAKE_PIN(P18, Pin_nRF51822_to_Arduino(D18)); // MOSI
|
||||
MAKE_PIN(P16, Pin_nRF51822_to_Arduino(D16)); // CLK
|
||||
MAKE_PIN(P19, Pin_nRF51822_to_Arduino(D19));
|
||||
MAKE_PIN(P20, Pin_nRF51822_to_Arduino(D20));
|
||||
MAKE_PIN(P21, Pin_nRF51822_to_Arduino(D21));
|
||||
MAKE_PIN(P22, Pin_nRF51822_to_Arduino(D22));
|
||||
MAKE_PIN(P23, Pin_nRF51822_to_Arduino(D23));
|
||||
MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24));
|
||||
|
||||
#undef MAKE_PIN
|
||||
|
||||
|
||||
#else
|
||||
#error "Please define board in avrpins.h"
|
||||
|
||||
|
@ -1019,4 +1071,49 @@ MAKE_PIN(P19, 19); // A5
|
|||
|
||||
#endif
|
||||
|
||||
#endif // _avrpins_h_
|
||||
#if defined(__MIPSEL__)
|
||||
// MIPSEL (MIPS architecture using a little endian byte order)
|
||||
|
||||
// MIPS size_t = 4
|
||||
#define pgm_read_pointer(p) pgm_read_dword(p)
|
||||
|
||||
#define MAKE_PIN(className, pin) \
|
||||
class className { \
|
||||
public: \
|
||||
static void Set() { \
|
||||
digitalWrite(pin, HIGH);\
|
||||
} \
|
||||
static void Clear() { \
|
||||
digitalWrite(pin, LOW); \
|
||||
} \
|
||||
static void SetDirRead() { \
|
||||
pinMode(pin, INPUT); \
|
||||
} \
|
||||
static void SetDirWrite() { \
|
||||
pinMode(pin, OUTPUT); \
|
||||
} \
|
||||
static uint8_t IsSet() { \
|
||||
return digitalRead(pin); \
|
||||
} \
|
||||
};
|
||||
|
||||
// 0 .. 13 - Digital pins
|
||||
MAKE_PIN(P0, 0); // RX
|
||||
MAKE_PIN(P1, 1); // TX
|
||||
MAKE_PIN(P2, 2); //
|
||||
MAKE_PIN(P3, 3); //
|
||||
MAKE_PIN(P4, 4); //
|
||||
MAKE_PIN(P5, 5); //
|
||||
MAKE_PIN(P6, 6); //
|
||||
MAKE_PIN(P7, 7); //
|
||||
MAKE_PIN(P8, 8); //
|
||||
MAKE_PIN(P9, 9); //
|
||||
MAKE_PIN(P10, 10); //
|
||||
MAKE_PIN(P11, 11); //
|
||||
MAKE_PIN(P12, 12); //
|
||||
MAKE_PIN(P13, 13); //
|
||||
|
||||
#undef MAKE_PIN
|
||||
#endif
|
||||
|
||||
#endif //_avrpins_h_
|
||||
|
|
12
cdcacm.h
12
cdcacm.h
|
@ -127,7 +127,9 @@ class ACM;
|
|||
|
||||
class CDCAsyncOper {
|
||||
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 OnDisconnected(ACM *pacm) = 0;
|
||||
};
|
||||
|
@ -173,9 +175,9 @@ public:
|
|||
uint8_t SndData(uint16_t nbytes, uint8_t *dataptr);
|
||||
|
||||
// USBDeviceConfig implementation
|
||||
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
virtual uint8_t Release();
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Release();
|
||||
uint8_t Poll();
|
||||
|
||||
virtual uint8_t GetAddress() {
|
||||
return bAddress;
|
||||
|
@ -186,7 +188,7 @@ public:
|
|||
};
|
||||
|
||||
// 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__
|
||||
|
|
|
@ -246,7 +246,7 @@ uint8_t FTDI::Release() {
|
|||
bNumEP = 1;
|
||||
qNextPollTime = 0;
|
||||
bPollEnable = false;
|
||||
return 0;
|
||||
return pAsync->OnRelease(this);
|
||||
}
|
||||
|
||||
uint8_t FTDI::Poll() {
|
||||
|
|
20
cdcftdi.h
20
cdcftdi.h
|
@ -78,7 +78,12 @@ class FTDI;
|
|||
|
||||
class FTDIAsyncOper {
|
||||
public:
|
||||
virtual uint8_t OnInit(FTDI *pftdi) = 0;
|
||||
|
||||
virtual uint8_t OnInit(FTDI *pftdi) {
|
||||
};
|
||||
|
||||
virtual uint8_t OnRelease(FTDI *pftdi) {
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
@ -118,16 +123,21 @@ public:
|
|||
uint8_t SndData(uint16_t nbytes, uint8_t *dataptr);
|
||||
|
||||
// USBDeviceConfig implementation
|
||||
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
virtual uint8_t Release();
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Release();
|
||||
uint8_t Poll();
|
||||
|
||||
virtual uint8_t GetAddress() {
|
||||
return bAddress;
|
||||
};
|
||||
|
||||
// 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 bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||
return (vid == FTDI_VID && pid == FTDI_PID);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // __CDCFTDI_H__
|
||||
|
|
111
cdcprolific.h
111
cdcprolific.h
|
@ -19,69 +19,61 @@ e-mail : support@circuitsathome.com
|
|||
|
||||
#include "cdcacm.h"
|
||||
|
||||
#define PL_VID 0x067B
|
||||
#define PL_PID ( 0x2303 || 0x0609 )
|
||||
#define PL_VID 0x067B
|
||||
#define PL_PID ( 0x2303 || 0x0609 )
|
||||
|
||||
//#define PL_PID 0x0609
|
||||
//#define PL_PID 0x0609
|
||||
|
||||
#define PROLIFIC_REV_H 0x0202
|
||||
#define PROLIFIC_REV_X 0x0300
|
||||
#define PROLIFIC_REV_HX_CHIP_D 0x0400
|
||||
#define PROLIFIC_REV_1 0x0001
|
||||
#define PROLIFIC_REV_H 0x0202
|
||||
#define PROLIFIC_REV_X 0x0300
|
||||
#define PROLIFIC_REV_HX_CHIP_D 0x0400
|
||||
#define PROLIFIC_REV_1 0x0001
|
||||
|
||||
#define kXOnChar '\x11'
|
||||
#define kXOffChar '\x13'
|
||||
#define kXOnChar '\x11'
|
||||
#define kXOffChar '\x13'
|
||||
|
||||
#define SPECIAL_SHIFT (5)
|
||||
#define SPECIAL_MASK ((1<<SPECIAL_SHIFT) - 1)
|
||||
#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_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_NOTIFY ( PD_RS232_N_MASK )
|
||||
#define EXTERNAL_MASK ( PD_S_MASK | (PD_RS232_S_MASK & ~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_NOTIFY 0x00
|
||||
#define DEFAULT_STATE ( PD_S_TX_ENABLE | PD_S_RX_ENABLE | PD_RS232_A_TXO | PD_RS232_A_RXO )
|
||||
#define SPECIAL_SHIFT (5)
|
||||
#define SPECIAL_MASK ((1<<SPECIAL_SHIFT) - 1)
|
||||
#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_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_NOTIFY ( PD_RS232_N_MASK )
|
||||
#define EXTERNAL_MASK ( PD_S_MASK | (PD_RS232_S_MASK & ~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_NOTIFY 0x00
|
||||
#define DEFAULT_STATE ( PD_S_TX_ENABLE | PD_S_RX_ENABLE | PD_RS232_A_TXO | PD_RS232_A_RXO )
|
||||
|
||||
#define CONTINUE_SEND 1
|
||||
#define PAUSE_SEND 2
|
||||
#define CONTINUE_SEND 1
|
||||
#define PAUSE_SEND 2
|
||||
|
||||
#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 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 kTxQueueState ((UInt32)( PD_S_TXQ_EMPTY | PD_S_TXQ_LOW_WATER | PD_S_TXQ_HIGH_WATER | PD_S_TXQ_FULL ))
|
||||
#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 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 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_RTS 0x02
|
||||
#define kCONTROL_DTR 0x01
|
||||
#define kCONTROL_RTS 0x02
|
||||
|
||||
enum tXO_State {
|
||||
kXOnSent = -2,
|
||||
kXOffSent = -1,
|
||||
kXO_Idle = 0,
|
||||
kXOffNeeded = 1,
|
||||
kXOnNeeded = 2
|
||||
};
|
||||
#define kStateTransientMask 0x74
|
||||
#define kBreakError 0x04
|
||||
#define kFrameError 0x10
|
||||
#define kParityError 0x20
|
||||
#define kOverrunError 0x40
|
||||
|
||||
#define kStateTransientMask 0x74
|
||||
#define kBreakError 0x04
|
||||
#define kFrameError 0x10
|
||||
#define kParityError 0x20
|
||||
#define kOverrunError 0x40
|
||||
#define kCTS 0x80
|
||||
#define kDSR 0x02
|
||||
#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 kCTS 0x80
|
||||
#define kDSR 0x02
|
||||
#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_WRITE_REQUEST 0x01
|
||||
|
||||
#define VENDOR_WRITE_REQUEST_TYPE 0x40
|
||||
#define VENDOR_WRITE_REQUEST 0x01
|
||||
|
||||
#define VENDOR_READ_REQUEST_TYPE 0xc0
|
||||
#define VENDOR_READ_REQUEST 0x01
|
||||
#define VENDOR_READ_REQUEST_TYPE 0xc0
|
||||
#define VENDOR_READ_REQUEST 0x01
|
||||
|
||||
// Device Configuration Registers (DCR0, DCR1, DCR2)
|
||||
#define SET_DCR0 0x00
|
||||
|
@ -104,6 +96,17 @@ enum tXO_State {
|
|||
#define RESET_DOWNSTREAM_DATA_PIPE 0x08
|
||||
#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 {
|
||||
unknown,
|
||||
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 {
|
||||
uint16_t wPLType; // Type of chip
|
||||
|
||||
|
@ -122,7 +123,7 @@ public:
|
|||
PL2303(USB *pusb, CDCAsyncOper *pasync);
|
||||
|
||||
// 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 Poll();
|
||||
//virtual uint8_t GetAddress() { return bAddress; };
|
||||
|
|
|
@ -24,7 +24,9 @@ class UsbConfigXtracter {
|
|||
public:
|
||||
//virtual void ConfigXtract(const USB_CONFIGURATION_DESCRIPTOR *conf) = 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
|
||||
|
@ -63,7 +65,7 @@ public:
|
|||
UseOr = true;
|
||||
}
|
||||
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>
|
||||
|
|
|
@ -9,9 +9,10 @@
|
|||
#include "KeyboardParser.h"
|
||||
#include "MouseParser.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -31,7 +32,9 @@ MouseRptParser mousePrs;
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); // Halt
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include <PS3BT.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -20,12 +21,14 @@ BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
|
|||
PS3BT PS3(&Btd); // This will just create the instance
|
||||
//PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch
|
||||
|
||||
boolean printTemperature;
|
||||
boolean printAngle;
|
||||
bool printTemperature;
|
||||
bool printAngle;
|
||||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
#include <PS3BT.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -19,8 +20,8 @@ USB Usb;
|
|||
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
|
||||
PS3BT *PS3[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM!
|
||||
const uint8_t length = sizeof(PS3) / sizeof(PS3[0]); // Get the lenght of the array
|
||||
boolean printAngle[length];
|
||||
boolean oldControllerState[length];
|
||||
bool printAngle[length];
|
||||
bool oldControllerState[length];
|
||||
|
||||
void setup() {
|
||||
for (uint8_t i = 0; i < length; i++) {
|
||||
|
@ -29,7 +30,9 @@ void setup() {
|
|||
}
|
||||
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
#include <SPP.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -29,12 +30,14 @@ SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the
|
|||
PS3BT PS3(&Btd); // This will just create the instance
|
||||
//PS3BT PS3(&Btd, 0x00, 0x15, 0x83, 0x3D, 0x0A, 0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch
|
||||
|
||||
boolean firstMessage = true;
|
||||
bool firstMessage = true;
|
||||
String output = ""; // We will store the data in this string
|
||||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include <PS4BT.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -24,12 +25,14 @@ PS4BT PS4(&Btd, PAIR);
|
|||
// After that you can simply create the instance like so and then press the PS button on the device
|
||||
//PS4BT PS4(&Btd);
|
||||
|
||||
boolean printAngle, printTouch;
|
||||
bool printAngle, printTouch;
|
||||
uint8_t oldL2Value, oldR2Value;
|
||||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); // Halt
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include <SPP.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -20,11 +21,13 @@ BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
|
|||
SPP SerialBT(&Btd); // This will set the name to the defaults: "Arduino" and the pin to "0000"
|
||||
//SPP SerialBT(&Btd, "Lauszus's Arduino", "1234"); // You can also set the name and pin like so
|
||||
|
||||
boolean firstMessage = true;
|
||||
bool firstMessage = true;
|
||||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include <SPP.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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;
|
||||
|
@ -20,14 +21,16 @@ BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
|
|||
const uint8_t length = 2; // Set the number of instances here
|
||||
SPP *SerialBT[length]; // We will use this pointer to store the instances, you can easily make it larger if you like, but it will use a lot of RAM!
|
||||
|
||||
boolean firstMessage[length] = { true }; // Set all to true
|
||||
bool firstMessage[length] = { true }; // Set all to true
|
||||
|
||||
void setup() {
|
||||
for (uint8_t i = 0; i < length; i++)
|
||||
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);
|
||||
#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
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); // Halt
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include <Wii.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -24,7 +25,9 @@ bool printAngle;
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -14,9 +14,10 @@ Otherwise, wire up a IR LED yourself.
|
|||
#include <Wii.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIICAMERA // Used to check if WIICAMERA is defined
|
||||
|
@ -36,7 +37,9 @@ uint8_t printObjects;
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
#include <Wii.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -19,8 +20,8 @@ USB Usb;
|
|||
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
|
||||
WII *Wii[2]; // We will use this pointer to store the two instance, you can easily make it larger if you like, but it will use a lot of RAM!
|
||||
const uint8_t length = sizeof(Wii) / sizeof(Wii[0]); // Get the lenght of the array
|
||||
boolean printAngle[length];
|
||||
boolean oldControllerState[length];
|
||||
bool printAngle[length];
|
||||
bool oldControllerState[length];
|
||||
|
||||
void setup() {
|
||||
for (uint8_t i = 0; i < length; i++) {
|
||||
|
@ -29,7 +30,9 @@ void setup() {
|
|||
}
|
||||
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include <Wii.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -22,7 +23,9 @@ WII Wii(&Btd, PAIR); // This will start an inquiry and then pair with your Wiimo
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -1,98 +1,99 @@
|
|||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
class KbdRptParser : public KeyboardReportParser
|
||||
{
|
||||
void PrintKey(uint8_t mod, uint8_t key);
|
||||
void PrintKey(uint8_t mod, uint8_t key);
|
||||
|
||||
protected:
|
||||
virtual void OnControlKeysChanged(uint8_t before, uint8_t after);
|
||||
protected:
|
||||
void OnControlKeysChanged(uint8_t before, uint8_t after);
|
||||
|
||||
virtual void OnKeyDown (uint8_t mod, uint8_t key);
|
||||
virtual void OnKeyUp (uint8_t mod, uint8_t key);
|
||||
virtual void OnKeyPressed(uint8_t key);
|
||||
void OnKeyDown (uint8_t mod, uint8_t key);
|
||||
void OnKeyUp (uint8_t mod, uint8_t key);
|
||||
void OnKeyPressed(uint8_t key);
|
||||
};
|
||||
|
||||
void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
|
||||
{
|
||||
MODIFIERKEYS mod;
|
||||
*((uint8_t*)&mod) = m;
|
||||
Serial.print((mod.bmLeftCtrl == 1) ? "C" : " ");
|
||||
Serial.print((mod.bmLeftShift == 1) ? "S" : " ");
|
||||
Serial.print((mod.bmLeftAlt == 1) ? "A" : " ");
|
||||
Serial.print((mod.bmLeftGUI == 1) ? "G" : " ");
|
||||
MODIFIERKEYS mod;
|
||||
*((uint8_t*)&mod) = m;
|
||||
Serial.print((mod.bmLeftCtrl == 1) ? "C" : " ");
|
||||
Serial.print((mod.bmLeftShift == 1) ? "S" : " ");
|
||||
Serial.print((mod.bmLeftAlt == 1) ? "A" : " ");
|
||||
Serial.print((mod.bmLeftGUI == 1) ? "G" : " ");
|
||||
|
||||
Serial.print(" >");
|
||||
PrintHex<uint8_t>(key, 0x80);
|
||||
Serial.print("< ");
|
||||
Serial.print(" >");
|
||||
PrintHex<uint8_t>(key, 0x80);
|
||||
Serial.print("< ");
|
||||
|
||||
Serial.print((mod.bmRightCtrl == 1) ? "C" : " ");
|
||||
Serial.print((mod.bmRightShift == 1) ? "S" : " ");
|
||||
Serial.print((mod.bmRightAlt == 1) ? "A" : " ");
|
||||
Serial.println((mod.bmRightGUI == 1) ? "G" : " ");
|
||||
Serial.print((mod.bmRightCtrl == 1) ? "C" : " ");
|
||||
Serial.print((mod.bmRightShift == 1) ? "S" : " ");
|
||||
Serial.print((mod.bmRightAlt == 1) ? "A" : " ");
|
||||
Serial.println((mod.bmRightGUI == 1) ? "G" : " ");
|
||||
};
|
||||
|
||||
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
|
||||
{
|
||||
Serial.print("DN ");
|
||||
PrintKey(mod, key);
|
||||
uint8_t c = OemToAscii(mod, key);
|
||||
Serial.print("DN ");
|
||||
PrintKey(mod, key);
|
||||
uint8_t c = OemToAscii(mod, key);
|
||||
|
||||
if (c)
|
||||
OnKeyPressed(c);
|
||||
if (c)
|
||||
OnKeyPressed(c);
|
||||
}
|
||||
|
||||
void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) {
|
||||
|
||||
MODIFIERKEYS beforeMod;
|
||||
*((uint8_t*)&beforeMod) = before;
|
||||
MODIFIERKEYS beforeMod;
|
||||
*((uint8_t*)&beforeMod) = before;
|
||||
|
||||
MODIFIERKEYS afterMod;
|
||||
*((uint8_t*)&afterMod) = after;
|
||||
MODIFIERKEYS afterMod;
|
||||
*((uint8_t*)&afterMod) = after;
|
||||
|
||||
if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) {
|
||||
Serial.println("LeftCtrl changed");
|
||||
}
|
||||
if (beforeMod.bmLeftShift != afterMod.bmLeftShift) {
|
||||
Serial.println("LeftShift changed");
|
||||
}
|
||||
if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) {
|
||||
Serial.println("LeftAlt changed");
|
||||
}
|
||||
if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) {
|
||||
Serial.println("LeftGUI changed");
|
||||
}
|
||||
if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) {
|
||||
Serial.println("LeftCtrl changed");
|
||||
}
|
||||
if (beforeMod.bmLeftShift != afterMod.bmLeftShift) {
|
||||
Serial.println("LeftShift changed");
|
||||
}
|
||||
if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) {
|
||||
Serial.println("LeftAlt changed");
|
||||
}
|
||||
if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) {
|
||||
Serial.println("LeftGUI changed");
|
||||
}
|
||||
|
||||
if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) {
|
||||
Serial.println("RightCtrl changed");
|
||||
}
|
||||
if (beforeMod.bmRightShift != afterMod.bmRightShift) {
|
||||
Serial.println("RightShift changed");
|
||||
}
|
||||
if (beforeMod.bmRightAlt != afterMod.bmRightAlt) {
|
||||
Serial.println("RightAlt changed");
|
||||
}
|
||||
if (beforeMod.bmRightGUI != afterMod.bmRightGUI) {
|
||||
Serial.println("RightGUI changed");
|
||||
}
|
||||
if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) {
|
||||
Serial.println("RightCtrl changed");
|
||||
}
|
||||
if (beforeMod.bmRightShift != afterMod.bmRightShift) {
|
||||
Serial.println("RightShift changed");
|
||||
}
|
||||
if (beforeMod.bmRightAlt != afterMod.bmRightAlt) {
|
||||
Serial.println("RightAlt changed");
|
||||
}
|
||||
if (beforeMod.bmRightGUI != afterMod.bmRightGUI) {
|
||||
Serial.println("RightGUI changed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key)
|
||||
{
|
||||
Serial.print("UP ");
|
||||
PrintKey(mod, key);
|
||||
Serial.print("UP ");
|
||||
PrintKey(mod, key);
|
||||
}
|
||||
|
||||
void KbdRptParser::OnKeyPressed(uint8_t key)
|
||||
{
|
||||
Serial.print("ASCII: ");
|
||||
Serial.println((char)key);
|
||||
Serial.print("ASCII: ");
|
||||
Serial.println((char)key);
|
||||
};
|
||||
|
||||
USB Usb;
|
||||
|
@ -105,22 +106,24 @@ KbdRptParser Prs;
|
|||
|
||||
void setup()
|
||||
{
|
||||
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
|
||||
Serial.println("Start");
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
Serial.println("OSC did not start.");
|
||||
if (Usb.Init() == -1)
|
||||
Serial.println("OSC did not start.");
|
||||
|
||||
delay( 200 );
|
||||
delay( 200 );
|
||||
|
||||
next_time = millis() + 5000;
|
||||
next_time = millis() + 5000;
|
||||
|
||||
HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs);
|
||||
HidKeyboard.SetReportParser(0, (HIDReportParser*)&Prs);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Usb.Task();
|
||||
Usb.Task();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,147 +1,147 @@
|
|||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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
|
||||
{
|
||||
protected:
|
||||
virtual void OnMouseMove (MOUSEINFO *mi);
|
||||
virtual void OnLeftButtonUp (MOUSEINFO *mi);
|
||||
virtual void OnLeftButtonDown (MOUSEINFO *mi);
|
||||
virtual void OnRightButtonUp (MOUSEINFO *mi);
|
||||
virtual void OnRightButtonDown (MOUSEINFO *mi);
|
||||
virtual void OnMiddleButtonUp (MOUSEINFO *mi);
|
||||
virtual void OnMiddleButtonDown (MOUSEINFO *mi);
|
||||
protected:
|
||||
void OnMouseMove(MOUSEINFO *mi);
|
||||
void OnLeftButtonUp(MOUSEINFO *mi);
|
||||
void OnLeftButtonDown(MOUSEINFO *mi);
|
||||
void OnRightButtonUp(MOUSEINFO *mi);
|
||||
void OnRightButtonDown(MOUSEINFO *mi);
|
||||
void OnMiddleButtonUp(MOUSEINFO *mi);
|
||||
void OnMiddleButtonDown(MOUSEINFO *mi);
|
||||
};
|
||||
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
|
||||
{
|
||||
Serial.print("dx=");
|
||||
Serial.print(mi->dX, DEC);
|
||||
Serial.print(" dy=");
|
||||
Serial.println(mi->dY, DEC);
|
||||
Serial.print("dx=");
|
||||
Serial.print(mi->dX, DEC);
|
||||
Serial.print(" dy=");
|
||||
Serial.println(mi->dY, DEC);
|
||||
};
|
||||
void MouseRptParser::OnLeftButtonUp (MOUSEINFO *mi)
|
||||
{
|
||||
Serial.println("L Butt Up");
|
||||
Serial.println("L Butt Up");
|
||||
};
|
||||
void MouseRptParser::OnLeftButtonDown (MOUSEINFO *mi)
|
||||
{
|
||||
Serial.println("L Butt Dn");
|
||||
Serial.println("L Butt Dn");
|
||||
};
|
||||
void MouseRptParser::OnRightButtonUp (MOUSEINFO *mi)
|
||||
{
|
||||
Serial.println("R Butt Up");
|
||||
Serial.println("R Butt Up");
|
||||
};
|
||||
void MouseRptParser::OnRightButtonDown (MOUSEINFO *mi)
|
||||
{
|
||||
Serial.println("R Butt Dn");
|
||||
Serial.println("R Butt Dn");
|
||||
};
|
||||
void MouseRptParser::OnMiddleButtonUp (MOUSEINFO *mi)
|
||||
{
|
||||
Serial.println("M Butt Up");
|
||||
Serial.println("M Butt Up");
|
||||
};
|
||||
void MouseRptParser::OnMiddleButtonDown (MOUSEINFO *mi)
|
||||
{
|
||||
Serial.println("M Butt Dn");
|
||||
Serial.println("M Butt Dn");
|
||||
};
|
||||
|
||||
class KbdRptParser : public KeyboardReportParser
|
||||
{
|
||||
void PrintKey(uint8_t mod, uint8_t key);
|
||||
void PrintKey(uint8_t mod, uint8_t key);
|
||||
|
||||
protected:
|
||||
virtual void OnControlKeysChanged(uint8_t before, uint8_t after);
|
||||
|
||||
virtual void OnKeyDown (uint8_t mod, uint8_t key);
|
||||
virtual void OnKeyUp (uint8_t mod, uint8_t key);
|
||||
virtual void OnKeyPressed(uint8_t key);
|
||||
protected:
|
||||
void OnControlKeysChanged(uint8_t before, uint8_t after);
|
||||
void OnKeyDown (uint8_t mod, uint8_t key);
|
||||
void OnKeyUp (uint8_t mod, uint8_t key);
|
||||
void OnKeyPressed(uint8_t key);
|
||||
};
|
||||
|
||||
void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
|
||||
{
|
||||
MODIFIERKEYS mod;
|
||||
*((uint8_t*)&mod) = m;
|
||||
Serial.print((mod.bmLeftCtrl == 1) ? "C" : " ");
|
||||
Serial.print((mod.bmLeftShift == 1) ? "S" : " ");
|
||||
Serial.print((mod.bmLeftAlt == 1) ? "A" : " ");
|
||||
Serial.print((mod.bmLeftGUI == 1) ? "G" : " ");
|
||||
MODIFIERKEYS mod;
|
||||
*((uint8_t*)&mod) = m;
|
||||
Serial.print((mod.bmLeftCtrl == 1) ? "C" : " ");
|
||||
Serial.print((mod.bmLeftShift == 1) ? "S" : " ");
|
||||
Serial.print((mod.bmLeftAlt == 1) ? "A" : " ");
|
||||
Serial.print((mod.bmLeftGUI == 1) ? "G" : " ");
|
||||
|
||||
Serial.print(" >");
|
||||
PrintHex<uint8_t>(key, 0x80);
|
||||
Serial.print("< ");
|
||||
Serial.print(" >");
|
||||
PrintHex<uint8_t>(key, 0x80);
|
||||
Serial.print("< ");
|
||||
|
||||
Serial.print((mod.bmRightCtrl == 1) ? "C" : " ");
|
||||
Serial.print((mod.bmRightShift == 1) ? "S" : " ");
|
||||
Serial.print((mod.bmRightAlt == 1) ? "A" : " ");
|
||||
Serial.println((mod.bmRightGUI == 1) ? "G" : " ");
|
||||
Serial.print((mod.bmRightCtrl == 1) ? "C" : " ");
|
||||
Serial.print((mod.bmRightShift == 1) ? "S" : " ");
|
||||
Serial.print((mod.bmRightAlt == 1) ? "A" : " ");
|
||||
Serial.println((mod.bmRightGUI == 1) ? "G" : " ");
|
||||
};
|
||||
|
||||
void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
|
||||
{
|
||||
Serial.print("DN ");
|
||||
PrintKey(mod, key);
|
||||
uint8_t c = OemToAscii(mod, key);
|
||||
Serial.print("DN ");
|
||||
PrintKey(mod, key);
|
||||
uint8_t c = OemToAscii(mod, key);
|
||||
|
||||
if (c)
|
||||
OnKeyPressed(c);
|
||||
if (c)
|
||||
OnKeyPressed(c);
|
||||
}
|
||||
|
||||
void KbdRptParser::OnControlKeysChanged(uint8_t before, uint8_t after) {
|
||||
|
||||
MODIFIERKEYS beforeMod;
|
||||
*((uint8_t*)&beforeMod) = before;
|
||||
MODIFIERKEYS beforeMod;
|
||||
*((uint8_t*)&beforeMod) = before;
|
||||
|
||||
MODIFIERKEYS afterMod;
|
||||
*((uint8_t*)&afterMod) = after;
|
||||
MODIFIERKEYS afterMod;
|
||||
*((uint8_t*)&afterMod) = after;
|
||||
|
||||
if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) {
|
||||
Serial.println("LeftCtrl changed");
|
||||
}
|
||||
if (beforeMod.bmLeftShift != afterMod.bmLeftShift) {
|
||||
Serial.println("LeftShift changed");
|
||||
}
|
||||
if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) {
|
||||
Serial.println("LeftAlt changed");
|
||||
}
|
||||
if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) {
|
||||
Serial.println("LeftGUI changed");
|
||||
}
|
||||
if (beforeMod.bmLeftCtrl != afterMod.bmLeftCtrl) {
|
||||
Serial.println("LeftCtrl changed");
|
||||
}
|
||||
if (beforeMod.bmLeftShift != afterMod.bmLeftShift) {
|
||||
Serial.println("LeftShift changed");
|
||||
}
|
||||
if (beforeMod.bmLeftAlt != afterMod.bmLeftAlt) {
|
||||
Serial.println("LeftAlt changed");
|
||||
}
|
||||
if (beforeMod.bmLeftGUI != afterMod.bmLeftGUI) {
|
||||
Serial.println("LeftGUI changed");
|
||||
}
|
||||
|
||||
if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) {
|
||||
Serial.println("RightCtrl changed");
|
||||
}
|
||||
if (beforeMod.bmRightShift != afterMod.bmRightShift) {
|
||||
Serial.println("RightShift changed");
|
||||
}
|
||||
if (beforeMod.bmRightAlt != afterMod.bmRightAlt) {
|
||||
Serial.println("RightAlt changed");
|
||||
}
|
||||
if (beforeMod.bmRightGUI != afterMod.bmRightGUI) {
|
||||
Serial.println("RightGUI changed");
|
||||
}
|
||||
if (beforeMod.bmRightCtrl != afterMod.bmRightCtrl) {
|
||||
Serial.println("RightCtrl changed");
|
||||
}
|
||||
if (beforeMod.bmRightShift != afterMod.bmRightShift) {
|
||||
Serial.println("RightShift changed");
|
||||
}
|
||||
if (beforeMod.bmRightAlt != afterMod.bmRightAlt) {
|
||||
Serial.println("RightAlt changed");
|
||||
}
|
||||
if (beforeMod.bmRightGUI != afterMod.bmRightGUI) {
|
||||
Serial.println("RightGUI changed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key)
|
||||
{
|
||||
Serial.print("UP ");
|
||||
PrintKey(mod, key);
|
||||
Serial.print("UP ");
|
||||
PrintKey(mod, key);
|
||||
}
|
||||
|
||||
void KbdRptParser::OnKeyPressed(uint8_t key)
|
||||
{
|
||||
Serial.print("ASCII: ");
|
||||
Serial.println((char)key);
|
||||
Serial.print("ASCII: ");
|
||||
Serial.println((char)key);
|
||||
};
|
||||
|
||||
USB Usb;
|
||||
USBHub Hub(&Usb);
|
||||
|
||||
HIDBoot<HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE> HidComposite(&Usb);
|
||||
HIDBoot < HID_PROTOCOL_KEYBOARD | HID_PROTOCOL_MOUSE > HidComposite(&Usb);
|
||||
HIDBoot<HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb);
|
||||
HIDBoot<HID_PROTOCOL_MOUSE> HidMouse(&Usb);
|
||||
|
||||
|
@ -152,25 +152,27 @@ MouseRptParser MousePrs;
|
|||
|
||||
void setup()
|
||||
{
|
||||
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
|
||||
Serial.println("Start");
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
Serial.println("OSC did not start.");
|
||||
if (Usb.Init() == -1)
|
||||
Serial.println("OSC did not start.");
|
||||
|
||||
delay( 200 );
|
||||
delay( 200 );
|
||||
|
||||
//next_time = millis() + 5000;
|
||||
//next_time = millis() + 5000;
|
||||
|
||||
HidComposite.SetReportParser(0, (HIDReportParser*)&KbdPrs);
|
||||
HidComposite.SetReportParser(1,(HIDReportParser*)&MousePrs);
|
||||
HidKeyboard.SetReportParser(0, (HIDReportParser*)&KbdPrs);
|
||||
HidMouse.SetReportParser(0,(HIDReportParser*)&MousePrs);
|
||||
HidComposite.SetReportParser(0, (HIDReportParser*)&KbdPrs);
|
||||
HidComposite.SetReportParser(1, (HIDReportParser*)&MousePrs);
|
||||
HidKeyboard.SetReportParser(0, (HIDReportParser*)&KbdPrs);
|
||||
HidMouse.SetReportParser(0, (HIDReportParser*)&MousePrs);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Usb.Task();
|
||||
Usb.Task();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
class MouseRptParser : public MouseReportParser
|
||||
{
|
||||
protected:
|
||||
virtual void OnMouseMove (MOUSEINFO *mi);
|
||||
virtual void OnLeftButtonUp (MOUSEINFO *mi);
|
||||
virtual void OnLeftButtonDown (MOUSEINFO *mi);
|
||||
virtual void OnRightButtonUp (MOUSEINFO *mi);
|
||||
virtual void OnRightButtonDown (MOUSEINFO *mi);
|
||||
virtual void OnMiddleButtonUp (MOUSEINFO *mi);
|
||||
virtual void OnMiddleButtonDown (MOUSEINFO *mi);
|
||||
void OnMouseMove (MOUSEINFO *mi);
|
||||
void OnLeftButtonUp (MOUSEINFO *mi);
|
||||
void OnLeftButtonDown (MOUSEINFO *mi);
|
||||
void OnRightButtonUp (MOUSEINFO *mi);
|
||||
void OnRightButtonDown (MOUSEINFO *mi);
|
||||
void OnMiddleButtonUp (MOUSEINFO *mi);
|
||||
void OnMiddleButtonDown (MOUSEINFO *mi);
|
||||
};
|
||||
void MouseRptParser::OnMouseMove(MOUSEINFO *mi)
|
||||
{
|
||||
|
@ -60,7 +61,9 @@ MouseRptParser Prs;
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
#include <hiduniversal.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#include "hidjoystickrptparser.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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"
|
||||
|
||||
USB Usb;
|
||||
USBHub Hub(&Usb);
|
||||
HIDUniversal Hid(&Usb);
|
||||
|
@ -17,7 +18,9 @@ JoystickReportParser Joy(&JoyEvents);
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
#include <usbhub.h>
|
||||
#include "pgmstrings.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
class HIDUniversal2 : public HIDUniversal
|
||||
|
@ -15,7 +16,7 @@ public:
|
|||
HIDUniversal2(USB *usb) : HIDUniversal(usb) {};
|
||||
|
||||
protected:
|
||||
virtual uint8_t OnInitSuccessful();
|
||||
uint8_t OnInitSuccessful();
|
||||
};
|
||||
|
||||
uint8_t HIDUniversal2::OnInitSuccessful()
|
||||
|
@ -55,7 +56,9 @@ UniversalReportParser Uni;
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
#include "le3dp_rptparser.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -20,7 +21,9 @@ JoystickReportParser Joy(&JoyEvents);
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
|
||||
#include "scale_rptparser.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -22,7 +23,9 @@ ScaleReportParser Scale(&ScaleEvents);
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#if !defined(__SCALERPTPARSER_H__)
|
||||
#define __SCALERPTPARSER_H__
|
||||
|
||||
#include <Max_LCD.h>
|
||||
#include <max_LCD.h>
|
||||
#include <hid.h>
|
||||
|
||||
/* Scale status constants */
|
||||
|
@ -19,22 +19,22 @@ struct ScaleEventData
|
|||
{
|
||||
uint8_t reportID; //must be 3
|
||||
uint8_t status;
|
||||
uint8_t unit;
|
||||
uint8_t unit;
|
||||
int8_t exp; //scale factor for the weight
|
||||
uint16_t weight; //
|
||||
};
|
||||
|
||||
class ScaleEvents
|
||||
{
|
||||
|
||||
|
||||
Max_LCD* pLcd;
|
||||
|
||||
|
||||
void LcdPrint( const char* str );
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
ScaleEvents( Max_LCD* pLCD );
|
||||
|
||||
|
||||
virtual void OnScaleChanged(const ScaleEventData *evt);
|
||||
};
|
||||
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
#include <PS3USB.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -16,12 +17,14 @@ USB Usb;
|
|||
PS3USB PS3(&Usb); // This will just create the instance
|
||||
//PS3USB PS3(&Usb,0x00,0x15,0x83,0x3D,0x0A,0x57); // This will also store the bluetooth address - this can be obtained from the dongle when running the sketch
|
||||
|
||||
boolean printAngle;
|
||||
bool printAngle;
|
||||
uint8_t state = 0;
|
||||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -6,20 +6,23 @@
|
|||
|
||||
#include <PS4USB.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
PS4USB PS4(&Usb);
|
||||
|
||||
boolean printAngle, printTouch;
|
||||
bool printAngle, printTouch;
|
||||
uint8_t oldL2Value, oldR2Value;
|
||||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); // Halt
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
#include <PSBuzz.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -16,7 +17,9 @@ PSBuzz Buzz(&Usb);
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); // Halt
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
#include "pgmstrings.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -50,7 +51,9 @@ void PrintAddress(uint8_t addr)
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
@ -337,7 +340,7 @@ void printunkdescr( uint8_t* descr_ptr )
|
|||
|
||||
|
||||
/* Print a string from Program Memory directly to save RAM */
|
||||
void printProgStr(const prog_char str[])
|
||||
void printProgStr(prog_char str[])
|
||||
{
|
||||
char c;
|
||||
if(!str) return;
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
#include <XBOXOLD.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -18,7 +19,9 @@ XBOXOLD Xbox(&Usb);
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); // halt
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
|
||||
#include <XBOXRECV.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -17,7 +18,9 @@ XBOXRECV Xbox(&Usb);
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
#include <XBOXUSB.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -16,7 +17,9 @@ XBOXUSB Xbox(&Usb);
|
|||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
|
||||
#include "pgmstrings.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
class ACMAsyncOper : public CDCAsyncOper
|
||||
{
|
||||
public:
|
||||
virtual uint8_t OnInit(ACM *pacm);
|
||||
uint8_t OnInit(ACM *pacm);
|
||||
};
|
||||
|
||||
uint8_t ACMAsyncOper::OnInit(ACM *pacm)
|
||||
|
@ -48,7 +49,9 @@ ACM Acm(&Usb, &AsyncOper);
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
|
@ -2,9 +2,25 @@
|
|||
// 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>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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;
|
||||
|
@ -15,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)
|
||||
"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;
|
||||
boolean connected;
|
||||
bool connected;
|
||||
|
||||
void setup() {
|
||||
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
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print("\r\nOSCOKIRQ failed to assert");
|
||||
while (1); // halt
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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;
|
||||
USBHub Hub1(&Usb);
|
||||
USBHub Hub2(&Usb);
|
||||
USBHub Hub2(&Usb);
|
||||
HIDBoot<HID_PROTOCOL_KEYBOARD> Keyboard(&Usb);
|
||||
|
||||
ADK adk(&Usb,"Circuits@Home, ltd.",
|
||||
|
@ -25,22 +26,22 @@ ADK adk(&Usb,"Circuits@Home, ltd.",
|
|||
|
||||
class KbdRptParser : public KeyboardReportParser
|
||||
{
|
||||
|
||||
|
||||
protected:
|
||||
virtual void OnKeyDown (uint8_t mod, uint8_t key);
|
||||
virtual void OnKeyPressed(uint8_t key);
|
||||
void OnKeyDown (uint8_t mod, 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);
|
||||
|
||||
|
||||
if (c)
|
||||
OnKeyPressed(c);
|
||||
}
|
||||
|
||||
|
||||
/* what to do when symbol arrives */
|
||||
void KbdRptParser::OnKeyPressed(uint8_t key)
|
||||
void KbdRptParser::OnKeyPressed(uint8_t key)
|
||||
{
|
||||
const char* new_line = "\n";
|
||||
uint8_t rcode;
|
||||
|
@ -49,36 +50,38 @@ uint8_t keylcl;
|
|||
if( adk.isReady() == false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
keylcl = key;
|
||||
|
||||
|
||||
if( keylcl == 0x13 ) {
|
||||
rcode = adk.SndData( strlen( new_line ), (uint8_t *)new_line );
|
||||
}
|
||||
else {
|
||||
rcode = adk.SndData( 1, &keylcl );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Serial.print((char) keylcl );
|
||||
Serial.print(" : ");
|
||||
Serial.print(" : ");
|
||||
Serial.println( keylcl, HEX );
|
||||
};
|
||||
|
||||
|
||||
KbdRptParser Prs;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("\r\nADK demo start");
|
||||
|
||||
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.println("OSCOKIRQ failed to assert");
|
||||
while(1); //halt
|
||||
}//if (Usb.Init() == -1...
|
||||
|
||||
|
||||
Keyboard.SetReportParser(0, (HIDReportParser*)&Prs);
|
||||
|
||||
|
||||
delay( 200 );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include <adk.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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;
|
||||
|
@ -21,9 +22,6 @@ uint8_t b, b1;
|
|||
#define LED1_RED 3
|
||||
#define BUTTON1 2
|
||||
|
||||
void setup();
|
||||
void loop();
|
||||
|
||||
void init_buttons()
|
||||
{
|
||||
pinMode(BUTTON1, INPUT);
|
||||
|
@ -42,9 +40,11 @@ void init_leds()
|
|||
void setup()
|
||||
{
|
||||
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");
|
||||
|
||||
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.println("OSCOKIRQ failed to assert");
|
||||
while(1); //halt
|
||||
|
@ -61,17 +61,17 @@ void loop()
|
|||
uint8_t rcode;
|
||||
uint8_t msg[3] = { 0x00 };
|
||||
Usb.Task();
|
||||
|
||||
|
||||
if( adk.isReady() == false ) {
|
||||
analogWrite(LED1_RED, 255);
|
||||
return;
|
||||
}
|
||||
uint16_t len = sizeof(msg);
|
||||
|
||||
|
||||
rcode = adk.RcvData(&len, msg);
|
||||
if( rcode ) {
|
||||
USBTRACE2("Data rcv. :", rcode );
|
||||
}
|
||||
}
|
||||
if(len > 0) {
|
||||
USBTRACE("\r\nData Packet.");
|
||||
// assumes only one command per packet
|
||||
|
@ -80,10 +80,10 @@ void loop()
|
|||
case 0:
|
||||
analogWrite(LED1_RED, 255 - msg[2]);
|
||||
break;
|
||||
}//switch( msg[1]...
|
||||
}//switch( msg[1]...
|
||||
}//if (msg[0] == 0x2...
|
||||
}//if( len > 0...
|
||||
|
||||
|
||||
msg[0] = 0x1;
|
||||
|
||||
b = digitalRead(BUTTON1);
|
||||
|
@ -99,5 +99,5 @@ void loop()
|
|||
}//if (b != b1...
|
||||
|
||||
|
||||
delay( 10 );
|
||||
delay( 10 );
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include <adk.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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;
|
||||
|
@ -19,9 +20,11 @@ ADK adk(&Usb,"Circuits@Home, ltd.",
|
|||
void setup()
|
||||
{
|
||||
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");
|
||||
|
||||
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.println("OSCOKIRQ failed to assert");
|
||||
while(1); //halt
|
||||
|
@ -32,31 +35,31 @@ void loop()
|
|||
{
|
||||
uint8_t rcode;
|
||||
uint8_t msg[64] = { 0x00 };
|
||||
const char* recv = "Received: ";
|
||||
|
||||
const char* recv = "Received: ";
|
||||
|
||||
Usb.Task();
|
||||
|
||||
|
||||
if( adk.isReady() == false ) {
|
||||
return;
|
||||
}
|
||||
uint16_t len = 64;
|
||||
|
||||
|
||||
rcode = adk.RcvData(&len, msg);
|
||||
if( rcode & ( rcode != hrNAK )) {
|
||||
USBTRACE2("Data rcv. :", rcode );
|
||||
}
|
||||
}
|
||||
if(len > 0) {
|
||||
USBTRACE("\r\nData Packet.");
|
||||
|
||||
for( uint8_t i = 0; i < len; i++ ) {
|
||||
Serial.print((char)msg[i]);
|
||||
}
|
||||
/* sending back what was received */
|
||||
rcode = adk.SndData( strlen( recv ), (uint8_t *)recv );
|
||||
/* sending back what was received */
|
||||
rcode = adk.SndData( strlen( recv ), (uint8_t *)recv );
|
||||
rcode = adk.SndData( strlen(( char * )msg ), msg );
|
||||
|
||||
}//if( len > 0 )...
|
||||
|
||||
delay( 1000 );
|
||||
delay( 1000 );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include <adk.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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;
|
||||
|
@ -18,9 +19,11 @@ ADK adk(&Usb,"Circuits@Home, ltd.",
|
|||
void setup()
|
||||
{
|
||||
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");
|
||||
|
||||
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.println("OSCOKIRQ failed to assert");
|
||||
while(1); //halt
|
||||
|
@ -32,16 +35,16 @@ void loop()
|
|||
uint8_t buf[ 12 ] = { 0 }; //buffer to convert unsigned long to ASCII
|
||||
const char* sec_ela = " seconds elapsed\r";
|
||||
uint8_t rcode;
|
||||
|
||||
|
||||
Usb.Task();
|
||||
if( adk.isReady() == false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ultoa( millis()/1000, (char *)buf, 10 );
|
||||
|
||||
|
||||
rcode = adk.SndData( strlen((char *)buf), buf );
|
||||
rcode = adk.SndData( strlen( sec_ela), (uint8_t *)sec_ela );
|
||||
|
||||
delay( 1000 );
|
||||
|
||||
delay( 1000 );
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
/**/
|
||||
#include <usbhub.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library
|
||||
#include <SPI.h> // Hack to use the SPI library
|
||||
#endif
|
||||
|
||||
/* variables */
|
||||
|
@ -24,7 +26,9 @@ USB Usb;
|
|||
void setup() {
|
||||
laststate = 0;
|
||||
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
|
||||
E_Notify(PSTR("\r\nCircuits At Home 2011"), 0x80);
|
||||
E_Notify(PSTR("\r\nUSB Host Shield Quality Control Routine"), 0x80);
|
||||
/* SPI quick test - check revision register */
|
||||
|
@ -32,7 +36,7 @@ void setup() {
|
|||
Usb.Init(); // Initializes SPI, we don't care about the return value here
|
||||
{
|
||||
uint8_t tmpbyte = Usb.regRd(rREVISION);
|
||||
switch (tmpbyte) {
|
||||
switch(tmpbyte) {
|
||||
case( 0x01): //rev.01
|
||||
E_Notify(PSTR("01"), 0x80);
|
||||
break;
|
||||
|
@ -55,11 +59,11 @@ void setup() {
|
|||
uint8_t sample_wr = 0;
|
||||
uint8_t sample_rd = 0;
|
||||
uint8_t gpinpol_copy = Usb.regRd(rGPINPOL);
|
||||
for (uint8_t i = 0; i < 16; i++) {
|
||||
for (uint16_t j = 0; j < 65535; j++) {
|
||||
for(uint8_t i = 0; i < 16; i++) {
|
||||
for(uint16_t j = 0; j < 65535; j++) {
|
||||
Usb.regWr(rGPINPOL, sample_wr);
|
||||
sample_rd = Usb.regRd(rGPINPOL);
|
||||
if (sample_rd != sample_wr) {
|
||||
if(sample_rd != sample_wr) {
|
||||
E_Notify(PSTR("\r\nTest failed. "), 0x80);
|
||||
E_Notify(PSTR("Value written: "), 0x80);
|
||||
print_hex(sample_wr, 8);
|
||||
|
@ -80,12 +84,12 @@ void setup() {
|
|||
{
|
||||
uint8_t tmpbyte;
|
||||
E_Notify(PSTR("\r\nGPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on"), 0x80);
|
||||
for (uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++) {
|
||||
for(uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++) {
|
||||
Usb.gpioWr(sample_gpio);
|
||||
tmpbyte = Usb.gpioRd();
|
||||
/* bit reversing code copied vetbatim from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */
|
||||
tmpbyte = ((tmpbyte * 0x0802LU & 0x22110LU) | (tmpbyte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
|
||||
if (sample_gpio != tmpbyte) {
|
||||
if(sample_gpio != tmpbyte) {
|
||||
E_Notify(PSTR("\r\nTest failed. Value written: "), 0x80);
|
||||
print_hex(sample_gpio, 8);
|
||||
E_Notify(PSTR(" Value read: "), 0x80);
|
||||
|
@ -101,31 +105,31 @@ void setup() {
|
|||
{
|
||||
E_Notify(PSTR("\r\nPLL test. 100 chip resets will be performed"), 0x80);
|
||||
/* check current state of the oscillator */
|
||||
if (!(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ)) { //wrong state - should be on
|
||||
if(!(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ)) { //wrong state - should be on
|
||||
E_Notify(PSTR("\r\nCurrent oscillator state unexpected."), 0x80);
|
||||
press_any_key();
|
||||
}
|
||||
/* Restart oscillator */
|
||||
E_Notify(PSTR("\r\nResetting oscillator\r\n"), 0x80);
|
||||
for (uint16_t i = 0; i < 100; i++) {
|
||||
for(uint16_t i = 0; i < 100; i++) {
|
||||
E_Notify(PSTR("\rReset number "), 0x80);
|
||||
Serial.print(i, DEC);
|
||||
Usb.regWr(rUSBCTL, bmCHIPRES); //reset
|
||||
if (Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { //wrong state - should be off
|
||||
if(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) { //wrong state - should be off
|
||||
E_Notify(PSTR("\r\nCurrent oscillator state unexpected."), 0x80);
|
||||
halt55();
|
||||
}
|
||||
Usb.regWr(rUSBCTL, 0x00); //release from reset
|
||||
uint16_t j = 0;
|
||||
for (j = 0; j < 65535; j++) { //tracking off to on time
|
||||
if (Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) {
|
||||
for(j = 0; j < 65535; j++) { //tracking off to on time
|
||||
if(Usb.regRd(rUSBIRQ) & bmOSCOKIRQ) {
|
||||
E_Notify(PSTR(" Time to stabilize - "), 0x80);
|
||||
Serial.print(j, DEC);
|
||||
E_Notify(PSTR(" cycles\r\n"), 0x80);
|
||||
break;
|
||||
}
|
||||
}//for( uint16_t j = 0; j < 65535; j++
|
||||
if (j == 0) {
|
||||
if(j == 0) {
|
||||
E_Notify(PSTR("PLL failed to stabilize"), 0x80);
|
||||
press_any_key();
|
||||
}
|
||||
|
@ -133,7 +137,7 @@ void setup() {
|
|||
|
||||
}//PLL test
|
||||
/* initializing USB stack */
|
||||
if (Usb.Init() == -1) {
|
||||
if(Usb.Init() == -1) {
|
||||
E_Notify(PSTR("\r\nOSCOKIRQ failed to assert"), 0x80);
|
||||
halt55();
|
||||
}
|
||||
|
@ -144,10 +148,10 @@ void loop() {
|
|||
delay(200);
|
||||
Usb.Task();
|
||||
usbstate = Usb.getUsbTaskState();
|
||||
if (usbstate != laststate) {
|
||||
if(usbstate != laststate) {
|
||||
laststate = usbstate;
|
||||
/**/
|
||||
switch (usbstate) {
|
||||
switch(usbstate) {
|
||||
case( USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE):
|
||||
E_Notify(PSTR("\r\nWaiting for device..."), 0x80);
|
||||
break;
|
||||
|
@ -167,7 +171,7 @@ void loop() {
|
|||
E_Notify(PSTR("\r\nGetting device descriptor"), 0x80);
|
||||
rcode = Usb.getDevDescr(1, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*) & buf);
|
||||
|
||||
if (rcode) {
|
||||
if(rcode) {
|
||||
E_Notify(PSTR("\r\nError reading device descriptor. Error code "), 0x80);
|
||||
print_hex(rcode, 8);
|
||||
} else {
|
||||
|
@ -202,7 +206,7 @@ void loop() {
|
|||
print_hex(buf.bNumConfigurations, 8);
|
||||
/**/
|
||||
E_Notify(PSTR("\r\n\nAll tests passed. Press RESET to restart test"), 0x80);
|
||||
while (1);
|
||||
while(1);
|
||||
}
|
||||
break;
|
||||
case( USB_STATE_ERROR):
|
||||
|
@ -222,7 +226,7 @@ void halt55() {
|
|||
E_Notify(PSTR("\r\n0x55 pattern is transmitted via SPI"), 0x80);
|
||||
E_Notify(PSTR("\r\nPress RESET to restart test"), 0x80);
|
||||
|
||||
while (1) {
|
||||
while(1) {
|
||||
Usb.regWr(0x55, 0x55);
|
||||
}
|
||||
}
|
||||
|
@ -231,25 +235,25 @@ void halt55() {
|
|||
void print_hex(int v, int num_places) {
|
||||
int mask = 0, n, num_nibbles, digit;
|
||||
|
||||
for (n = 1; n <= num_places; n++) {
|
||||
for(n = 1; n <= num_places; n++) {
|
||||
mask = (mask << 1) | 0x0001;
|
||||
}
|
||||
v = v & mask; // truncate v to specified number of places
|
||||
|
||||
num_nibbles = num_places / 4;
|
||||
if ((num_places % 4) != 0) {
|
||||
if((num_places % 4) != 0) {
|
||||
++num_nibbles;
|
||||
}
|
||||
do {
|
||||
digit = ((v >> (num_nibbles - 1) * 4)) & 0x0f;
|
||||
Serial.print(digit, HEX);
|
||||
} while (--num_nibbles);
|
||||
} while(--num_nibbles);
|
||||
}
|
||||
|
||||
/* prints "Press any key" and returns when key is pressed */
|
||||
void press_any_key() {
|
||||
E_Notify(PSTR("\r\nPress any key to continue..."), 0x80);
|
||||
while (Serial.available() <= 0); //wait for input
|
||||
while(Serial.available() <= 0); //wait for input
|
||||
Serial.read(); //empty input buffer
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
|
||||
#include "pgmstrings.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
class FTDIAsync : public FTDIAsyncOper
|
||||
{
|
||||
public:
|
||||
virtual uint8_t OnInit(FTDI *pftdi);
|
||||
uint8_t OnInit(FTDI *pftdi);
|
||||
};
|
||||
|
||||
uint8_t FTDIAsync::OnInit(FTDI *pftdi)
|
||||
|
@ -43,7 +44,9 @@ uint32_t next_time;
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#include <usbhub.h>
|
||||
#include "pgmstrings.h"
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
|
@ -46,7 +47,9 @@ void PrintAddress(uint8_t addr)
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
@ -333,7 +336,7 @@ void printunkdescr( uint8_t* descr_ptr )
|
|||
|
||||
|
||||
/* Print a string from Program Memory directly to save RAM */
|
||||
void printProgStr(const prog_char str[])
|
||||
void printProgStr(prog_char str[])
|
||||
{
|
||||
char c;
|
||||
if(!str) return;
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
|
||||
#include <max_LCD.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.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;
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
#include <cdcacm.h>
|
||||
#include <cdcprolific.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
class PLAsyncOper : public CDCAsyncOper
|
||||
{
|
||||
public:
|
||||
virtual uint8_t OnInit(ACM *pacm);
|
||||
uint8_t OnInit(ACM *pacm);
|
||||
};
|
||||
|
||||
uint8_t PLAsyncOper::OnInit(ACM *pacm)
|
||||
|
@ -51,7 +52,9 @@ PL2303 Pl(&Usb, &AsyncOper);
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
#include <cdcacm.h>
|
||||
#include <cdcprolific.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
class PLAsyncOper : public CDCAsyncOper {
|
||||
public:
|
||||
virtual uint8_t OnInit(ACM *pacm);
|
||||
uint8_t OnInit(ACM *pacm);
|
||||
};
|
||||
|
||||
uint8_t PLAsyncOper::OnInit(ACM *pacm) {
|
||||
|
@ -50,7 +51,9 @@ uint32_t read_delay;
|
|||
|
||||
void setup() {
|
||||
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");
|
||||
|
||||
if(Usb.Init() == -1)
|
||||
|
|
|
@ -12,9 +12,10 @@
|
|||
|
||||
#include <TinyGPS.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
/* This sample code demonstrates the normal use of a TinyGPS object.
|
||||
|
@ -25,7 +26,7 @@
|
|||
class PLAsyncOper : public CDCAsyncOper
|
||||
{
|
||||
public:
|
||||
virtual uint8_t OnInit(ACM *pacm);
|
||||
uint8_t OnInit(ACM *pacm);
|
||||
};
|
||||
|
||||
uint8_t PLAsyncOper::OnInit(ACM *pacm)
|
||||
|
@ -69,7 +70,9 @@ void setup()
|
|||
{
|
||||
|
||||
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
|
||||
#endif
|
||||
|
||||
Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
|
||||
Serial.println("by Mikal Hart");
|
||||
|
|
|
@ -6,15 +6,16 @@
|
|||
#include <cdcacm.h>
|
||||
#include <cdcprolific.h>
|
||||
|
||||
#ifdef dobogusinclude // Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#include <SPI.h>
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
class PLAsyncOper : public CDCAsyncOper
|
||||
{
|
||||
public:
|
||||
virtual uint8_t OnInit(ACM *pacm);
|
||||
uint8_t OnInit(ACM *pacm);
|
||||
};
|
||||
|
||||
uint8_t PLAsyncOper::OnInit(ACM *pacm)
|
||||
|
@ -51,7 +52,9 @@ PL2303 Pl(&Usb, &AsyncOper);
|
|||
void setup()
|
||||
{
|
||||
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
|
||||
#endif
|
||||
Serial.println("Start");
|
||||
|
||||
if (Usb.Init() == -1)
|
||||
|
|
28
examples/testusbhostFAT/testusbhostFAT.ino
Normal file → Executable file
28
examples/testusbhostFAT/testusbhostFAT.ino
Normal file → Executable file
|
@ -81,14 +81,14 @@ USB Usb;
|
|||
|
||||
volatile uint8_t current_state = 1;
|
||||
volatile uint8_t last_state = 0;
|
||||
volatile boolean fatready = false;
|
||||
volatile boolean partsready = false;
|
||||
volatile boolean notified = false;
|
||||
volatile boolean runtest = false;
|
||||
volatile boolean usbon = false;
|
||||
volatile bool fatready = false;
|
||||
volatile bool partsready = false;
|
||||
volatile bool notified = false;
|
||||
volatile bool runtest = false;
|
||||
volatile bool usbon = false;
|
||||
volatile uint32_t usbon_time;
|
||||
volatile boolean change = false;
|
||||
volatile boolean reportlvl = false;
|
||||
volatile bool change = false;
|
||||
volatile bool reportlvl = false;
|
||||
int cpart = 0;
|
||||
PCPartition *PT;
|
||||
|
||||
|
@ -179,7 +179,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
void setup() {
|
||||
boolean serr = false;
|
||||
bool serr = false;
|
||||
for(int i = 0; i < _VOLUMES; i++) {
|
||||
Fats[i] = NULL;
|
||||
sto[i].private_data = new pvt_t;
|
||||
|
@ -455,14 +455,14 @@ void loop() {
|
|||
}
|
||||
// This is horrible, and needs to be moved elsewhere!
|
||||
for(int B = 0; B < MAX_USB_MS_DRIVERS; B++) {
|
||||
if(!partsready && (UHS_USB_BulkOnly[B]->GetAddress() != NULL)) {
|
||||
if(!partsready && (UHS_USB_Storage[B]->GetAddress() != NULL)) {
|
||||
|
||||
// Build a list.
|
||||
int ML = UHS_USB_BulkOnly[B]->GetbMaxLUN();
|
||||
int ML = UHS_USB_Storage[B]->GetbMaxLUN();
|
||||
//printf("MAXLUN = %i\r\n", ML);
|
||||
ML++;
|
||||
for(int i = 0; i < ML; i++) {
|
||||
if(UHS_USB_BulkOnly[B]->LUNIsGood(i)) {
|
||||
if(UHS_USB_Storage[B]->LUNIsGood(i)) {
|
||||
partsready = true;
|
||||
((pvt_t *)(sto[i].private_data))->lun = i;
|
||||
((pvt_t *)(sto[i].private_data))->B = B;
|
||||
|
@ -471,8 +471,8 @@ void loop() {
|
|||
sto[i].Status = *UHS_USB_BulkOnly_Status;
|
||||
sto[i].Initialize = *UHS_USB_BulkOnly_Initialize;
|
||||
sto[i].Commit = *UHS_USB_BulkOnly_Commit;
|
||||
sto[i].TotalSectors = UHS_USB_BulkOnly[B]->GetCapacity(i);
|
||||
sto[i].SectorSize = UHS_USB_BulkOnly[B]->GetSectorSize(i);
|
||||
sto[i].TotalSectors = UHS_USB_Storage[B]->GetCapacity(i);
|
||||
sto[i].SectorSize = UHS_USB_Storage[B]->GetSectorSize(i);
|
||||
printf_P(PSTR("LUN:\t\t%u\r\n"), i);
|
||||
printf_P(PSTR("Total Sectors:\t%08lx\t%lu\r\n"), sto[i].TotalSectors, sto[i].TotalSectors);
|
||||
printf_P(PSTR("Sector Size:\t%04x\t\t%u\r\n"), sto[i].SectorSize, sto[i].SectorSize);
|
||||
|
@ -525,7 +525,7 @@ void loop() {
|
|||
if(Fats[0] != NULL) {
|
||||
struct Pvt * p;
|
||||
p = ((struct Pvt *)(Fats[0]->storage->private_data));
|
||||
if(!UHS_USB_BulkOnly[p->B]->LUNIsGood(p->lun)) {
|
||||
if(!UHS_USB_Storage[p->B]->LUNIsGood(p->lun)) {
|
||||
// media change
|
||||
#if !defined(CORE_TEENSY) && defined(__AVR__)
|
||||
fadeAmount = 80;
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
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>
|
||||
|
|
5
hid.h
5
hid.h
|
@ -156,7 +156,7 @@ protected:
|
|||
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
|
||||
void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc);
|
||||
|
||||
virtual HIDReportParser* GetReportParser(uint8_t id);
|
||||
virtual HIDReportParser* GetReportParser(uint8_t id) {};
|
||||
|
||||
public:
|
||||
|
||||
|
@ -166,7 +166,8 @@ public:
|
|||
const USB* GetUsb() {
|
||||
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 GetProtocol(uint8_t iface, uint8_t* dataptr);
|
||||
|
|
25
hidboot.cpp
25
hidboot.cpp
|
@ -157,27 +157,6 @@ void KeyboardReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
|
|||
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::symKeysUp[12] PROGMEM = {'_', '+', '{', '}', '|', '~', ':', '"', '~', '<', '>', '?'};
|
||||
const uint8_t KeyboardReportParser::symKeysLo[12] PROGMEM = {'-', '=', '[', ']', '\\', ' ', ';', '\'', '`', ',', '.', '/'};
|
||||
|
@ -189,8 +168,8 @@ uint8_t KeyboardReportParser::OemToAscii(uint8_t mod, uint8_t key) {
|
|||
// [a-z]
|
||||
if (VALUE_WITHIN(key, 0x04, 0x1d)) {
|
||||
// Upper case letters
|
||||
if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && (mod & 2)) ||
|
||||
(kbdLockingKeys.kbdLeds.bmCapsLock == 1 && (mod & 2) == 0))
|
||||
if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && shift) ||
|
||||
(kbdLockingKeys.kbdLeds.bmCapsLock == 1 && shift == 0))
|
||||
return (key - 4 + 'A');
|
||||
|
||||
// Lower case letters
|
||||
|
|
45
hidboot.h
45
hidboot.h
|
@ -56,7 +56,7 @@ class MouseReportParser : public HIDReportParser {
|
|||
} prevState;
|
||||
|
||||
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:
|
||||
|
||||
|
@ -144,10 +144,30 @@ public:
|
|||
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:
|
||||
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) {
|
||||
};
|
||||
|
@ -204,16 +224,29 @@ public:
|
|||
};
|
||||
|
||||
// USBDeviceConfig implementation
|
||||
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
virtual uint8_t Release();
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Release();
|
||||
uint8_t Poll();
|
||||
|
||||
virtual uint8_t GetAddress() {
|
||||
return bAddress;
|
||||
};
|
||||
|
||||
virtual bool isReady() {
|
||||
return bPollEnable;
|
||||
};
|
||||
|
||||
// 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 bool DEVCLASSOK(uint8_t klass) {
|
||||
return (klass == USB_CLASS_HID);
|
||||
}
|
||||
|
||||
virtual bool DEVSUBCLASSOK(uint8_t subklass) {
|
||||
return (subklass == BOOT_PROTOCOL);
|
||||
}
|
||||
};
|
||||
|
||||
template <const uint8_t BOOT_PROTOCOL>
|
||||
|
|
|
@ -111,6 +111,7 @@ protected:
|
|||
|
||||
uint16_t totalSize; // Report size in bits
|
||||
|
||||
// Method should be defined here if virtual.
|
||||
virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn);
|
||||
|
||||
UsagePageFunc pfUsage;
|
||||
|
@ -132,7 +133,7 @@ public:
|
|||
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 {
|
||||
enErrorSuccess = 0
|
||||
|
@ -156,6 +157,7 @@ class ReportDescParser2 : public ReportDescParserBase {
|
|||
uint8_t bLen; // Report length
|
||||
|
||||
protected:
|
||||
// Method should be defined here if virtual.
|
||||
virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn);
|
||||
|
||||
public:
|
||||
|
@ -167,6 +169,7 @@ public:
|
|||
|
||||
class UniversalReportParser : public HIDReportParser {
|
||||
public:
|
||||
// Method should be defined here if virtual.
|
||||
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
|
||||
};
|
||||
|
||||
|
|
|
@ -418,3 +418,9 @@ uint8_t HIDUniversal::Poll() {
|
|||
}
|
||||
return rcode;
|
||||
}
|
||||
|
||||
|
||||
//Send a report to interrupt out endpoint. This is NOT SetReport() request!
|
||||
uint8_t HIDUniversal::SndRpt(uint16_t nbytes, uint8_t *dataptr) {
|
||||
return pUsb->outTransfer(bAddress, epInfo[epInterruptOutIndex].epAddr, nbytes, dataptr);
|
||||
}
|
|
@ -69,7 +69,7 @@ protected:
|
|||
uint16_t PID, VID; // PID and VID of connected device
|
||||
|
||||
// HID implementation
|
||||
virtual HIDReportParser* GetReportParser(uint8_t id);
|
||||
HIDReportParser* GetReportParser(uint8_t id);
|
||||
|
||||
virtual uint8_t OnInitSuccessful() {
|
||||
return 0;
|
||||
|
@ -83,12 +83,12 @@ public:
|
|||
HIDUniversal(USB *p);
|
||||
|
||||
// HID implementation
|
||||
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs);
|
||||
bool SetReportParser(uint8_t id, HIDReportParser *prs);
|
||||
|
||||
// USBDeviceConfig implementation
|
||||
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
virtual uint8_t Release();
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Release();
|
||||
uint8_t Poll();
|
||||
|
||||
virtual uint8_t GetAddress() {
|
||||
return bAddress;
|
||||
|
@ -99,7 +99,10 @@ public:
|
|||
};
|
||||
|
||||
// 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);
|
||||
|
||||
// Send report - do not mix with SetReport()!
|
||||
uint8_t SndRpt(uint16_t nbytes, uint8_t *dataptr);
|
||||
};
|
||||
|
||||
#endif // __HIDUNIVERSAL_H__
|
||||
|
|
46
library.json
Normal file
46
library.json
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "USB-Host-Shield-20",
|
||||
"keywords": "usb, host, ftdi, adk, acm, pl2303, hid, bluetooth, spp, ps3, ps4, buzz, xbox, wii, mass storage",
|
||||
"description": "Revision 2.0 of MAX3421E-based USB Host Shield Library",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
"name": "Oleg Mazurov",
|
||||
"email": "mazurov@circuitsathome.com",
|
||||
"url": "http://www.circuitsathome.com",
|
||||
"maintainer": true
|
||||
},
|
||||
{
|
||||
"name": "Alexei Glushchenko",
|
||||
"email": "alex-gl@mail.ru"
|
||||
},
|
||||
{
|
||||
"name": "Kristian Lauszus",
|
||||
"email": "kristianl@tkjelectronics.com",
|
||||
"url": "http://tkjelectronics.com",
|
||||
"maintainer": true
|
||||
},
|
||||
{
|
||||
"name": "Andrew Kroll",
|
||||
"email": "xxxajk@gmail.com",
|
||||
"maintainer": true
|
||||
}
|
||||
],
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/felis/USB_Host_Shield_2.0.git"
|
||||
},
|
||||
"examples":
|
||||
[
|
||||
"examples/*/*.ino",
|
||||
"examples/*/*/*.ino"
|
||||
],
|
||||
"frameworks": "arduino",
|
||||
"platforms":
|
||||
[
|
||||
"atmelavr",
|
||||
"teensy",
|
||||
"atmelsam"
|
||||
]
|
||||
}
|
|
@ -67,7 +67,7 @@ bool BulkOnly::LUNIsGood(uint8_t lun) {
|
|||
* @param lun Logical Unit Number
|
||||
* @return cached status of write protect switch
|
||||
*/
|
||||
boolean BulkOnly::WriteProtected(uint8_t lun) {
|
||||
bool BulkOnly::WriteProtected(uint8_t lun) {
|
||||
return WriteOk[lun];
|
||||
}
|
||||
|
||||
|
@ -599,7 +599,7 @@ uint8_t BulkOnly::Release() {
|
|||
* @param lun Logical Unit Number
|
||||
* @return true if LUN is ready for use.
|
||||
*/
|
||||
boolean BulkOnly::CheckLUN(uint8_t lun) {
|
||||
bool BulkOnly::CheckLUN(uint8_t lun) {
|
||||
uint8_t rcode;
|
||||
Capacity capacity;
|
||||
for(uint8_t i = 0; i < 8; i++) capacity.data[i] = 0;
|
||||
|
@ -1020,11 +1020,11 @@ uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void
|
|||
printf("Transfersize %i\r\n", bytes);
|
||||
delay(1000);
|
||||
|
||||
boolean callback = (flags & MASS_TRANS_FLG_CALLBACK) == MASS_TRANS_FLG_CALLBACK;
|
||||
bool callback = (flags & MASS_TRANS_FLG_CALLBACK) == MASS_TRANS_FLG_CALLBACK;
|
||||
#else
|
||||
uint16_t bytes = buf_size;
|
||||
#endif
|
||||
boolean write = (pcbw->bmCBWFlags & MASS_CMD_DIR_IN) != MASS_CMD_DIR_IN;
|
||||
bool write = (pcbw->bmCBWFlags & MASS_CMD_DIR_IN) != MASS_CMD_DIR_IN;
|
||||
uint8_t ret = 0;
|
||||
uint8_t usberr;
|
||||
CommandStatusWrapper csw; // up here, we allocate ahead to save cpu cycles.
|
||||
|
|
16
masstorage.h
16
masstorage.h
|
@ -507,7 +507,7 @@ public:
|
|||
return bTheLUN; // Active LUN
|
||||
}
|
||||
|
||||
boolean WriteProtected(uint8_t lun);
|
||||
bool WriteProtected(uint8_t lun);
|
||||
uint8_t MediaCTL(uint8_t lun, uint8_t ctl);
|
||||
uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf);
|
||||
uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, USBReadParser *prs);
|
||||
|
@ -519,20 +519,20 @@ public:
|
|||
uint16_t GetSectorSize(uint8_t lun);
|
||||
|
||||
// USBDeviceConfig implementation
|
||||
virtual 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 Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
|
||||
virtual uint8_t Release();
|
||||
virtual uint8_t Poll();
|
||||
uint8_t Release();
|
||||
uint8_t Poll();
|
||||
|
||||
virtual uint8_t GetAddress() {
|
||||
return bAddress;
|
||||
};
|
||||
|
||||
// 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 bool DEVCLASSOK(uint8_t klass) {
|
||||
return (klass == USB_CLASS_MASS_STORAGE);
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,7 @@ private:
|
|||
uint8_t ReadCapacity10(uint8_t lun, uint8_t *buf);
|
||||
void ClearAllEP();
|
||||
void CheckMedia();
|
||||
boolean CheckLUN(uint8_t lun);
|
||||
bool CheckLUN(uint8_t lun);
|
||||
uint8_t Page3F(uint8_t lun);
|
||||
bool IsValidCBW(uint8_t size, uint8_t *pcbw);
|
||||
bool IsMeaningfulCBW(uint8_t size, uint8_t *pcbw);
|
||||
|
|
|
@ -22,7 +22,7 @@ e-mail : support@circuitsathome.com
|
|||
#define _Max_LCD_h_
|
||||
|
||||
#include "Usb.h"
|
||||
#include "Print.h"
|
||||
#include <Print.h>
|
||||
|
||||
// commands
|
||||
#define LCD_CLEARDISPLAY 0x01
|
||||
|
@ -88,10 +88,10 @@ public:
|
|||
void command(uint8_t);
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >=100
|
||||
virtual size_t write(uint8_t);
|
||||
size_t write(uint8_t);
|
||||
using Print::write;
|
||||
#else
|
||||
virtual void write(uint8_t);
|
||||
void write(uint8_t);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
19
settings.h
19
settings.h
|
@ -78,15 +78,7 @@ e-mail : support@circuitsathome.com
|
|||
// No user serviceable parts below this line.
|
||||
// DO NOT change anything below here unless you are a developer!
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >=100
|
||||
#include <Arduino.h>
|
||||
#else
|
||||
#include <WProgram.h>
|
||||
#include <pins_arduino.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/io.h>
|
||||
#define F(str) (str)
|
||||
#endif
|
||||
#include "version_helper.h"
|
||||
|
||||
#if defined(__GNUC__) && defined(__AVR__)
|
||||
#ifndef GCC_VERSION
|
||||
|
@ -137,8 +129,11 @@ e-mail : support@circuitsathome.com
|
|||
#define USING_SPI4TEENSY3 0
|
||||
#endif
|
||||
|
||||
#if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__) || ARDUINO >= 158) && !USING_SPI4TEENSY3
|
||||
#include <SPI.h> // Use the Arduino SPI library for the Arduino Due, Intel Galileo or if the SPI library with transaction is available
|
||||
#if ((defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(RBL_NRF51822) || defined(__ARDUINO_X86__) || ARDUINO >= 10600) && !USING_SPI4TEENSY3
|
||||
#include <SPI.h> // Use the Arduino SPI library for the Arduino Due, RedBearLab nRF51822 or if the SPI library with transaction is available
|
||||
#endif
|
||||
#if defined(__PIC32MX__) || defined(__PIC32MZ__)
|
||||
#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library
|
||||
#endif
|
||||
|
||||
#endif /* SETTINGS_H */
|
||||
#endif /* SETTINGS_H */
|
||||
|
|
41
usbhost.h
41
usbhost.h
|
@ -43,17 +43,26 @@ public:
|
|||
SPI_SS::SetDirWrite();
|
||||
SPI_SS::Set();
|
||||
}
|
||||
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__)
|
||||
#elif !defined(SPDR)
|
||||
static void init() {
|
||||
SPI_SS::SetDirWrite();
|
||||
SPI_SS::Set();
|
||||
SPI.begin();
|
||||
#ifdef __ARDUINO_X86__
|
||||
#if defined(__MIPSEL__)
|
||||
SPI.setClockDivider(1);
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
SPI.setClockDivider(SPI_CLOCK_DIV2); // This will set the SPI frequency to 8MHz - it could be higher, but it is not supported in the API
|
||||
#else
|
||||
SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz
|
||||
#endif
|
||||
}
|
||||
#elif defined(RBL_NRF51822)
|
||||
static void init() {
|
||||
SPI_SS::SetDirWrite();
|
||||
SPI_SS::Set();
|
||||
SPI.begin();
|
||||
// SPI.setFrequency(SPI_FREQUENCY_8M);
|
||||
}
|
||||
#else
|
||||
static void init() {
|
||||
//uint8_t tmp;
|
||||
|
@ -82,6 +91,10 @@ typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi;
|
|||
typedef SPi< P13, P11, P12, P10 > spi;
|
||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||
typedef SPi< P76, P75, P74, P10 > spi;
|
||||
#elif defined(RBL_NRF51822)
|
||||
typedef SPi< P16, P18, P17, P10 > spi;
|
||||
#elif defined(__MIPSEL__)
|
||||
typedef SPi< P13, P11, P12, P10 > spi;
|
||||
#else
|
||||
#error "No SPI entry in usbhost.h"
|
||||
#endif
|
||||
|
@ -152,7 +165,7 @@ void MAX3421e< SPI_SS, INTR >::regWr(uint8_t reg, uint8_t data) {
|
|||
c[0] = reg | 0x02;
|
||||
c[1] = data;
|
||||
spi4teensy3::send(c, 2);
|
||||
#elif (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || defined(__ARDUINO_X86__)
|
||||
#elif !defined(SPDR)
|
||||
SPI.transfer(reg | 0x02);
|
||||
SPI.transfer(data);
|
||||
#else
|
||||
|
@ -188,17 +201,17 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t*
|
|||
spi4teensy3::send(reg | 0x02);
|
||||
spi4teensy3::send(data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
SPI.transfer(reg | 0x02);
|
||||
SPI.transferBuffer(data_p, NULL, nbytes);
|
||||
data_p += nbytes;
|
||||
#elif !defined(SPDR)
|
||||
SPI.transfer(reg | 0x02);
|
||||
while(nbytes) {
|
||||
SPI.transfer(*data_p);
|
||||
nbytes--;
|
||||
data_p++; // advance data pointer
|
||||
}
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
SPI.transfer(reg | 0x02);
|
||||
SPI.transferBuffer(data_p, NULL, nbytes);
|
||||
data_p += nbytes;
|
||||
#else
|
||||
SPDR = (reg | 0x02); //set WR bit and send register number
|
||||
while(nbytes) {
|
||||
|
@ -238,7 +251,7 @@ uint8_t MAX3421e< SPI_SS, INTR >::regRd(uint8_t reg) {
|
|||
#endif
|
||||
SPI_SS::Clear();
|
||||
|
||||
#if (defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)) || SPI_HAS_TRANSACTION || defined(__ARDUINO_X86__)
|
||||
#if !defined(SPDR) || SPI_HAS_TRANSACTION
|
||||
SPI.transfer(reg);
|
||||
uint8_t rv = SPI.transfer(0); // Send empty byte
|
||||
SPI_SS::Set();
|
||||
|
@ -281,16 +294,16 @@ uint8_t* MAX3421e< SPI_SS, INTR >::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t*
|
|||
spi4teensy3::send(reg);
|
||||
spi4teensy3::receive(data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
SPI.transfer(reg);
|
||||
SPI.transferBuffer(NULL, data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
#elif !defined(SPDR)
|
||||
SPI.transfer(reg);
|
||||
while(nbytes) {
|
||||
*data_p++ = SPI.transfer(0);
|
||||
nbytes--;
|
||||
}
|
||||
#elif defined(__ARDUINO_X86__)
|
||||
SPI.transfer(reg);
|
||||
SPI.transferBuffer(NULL, data_p, nbytes);
|
||||
data_p += nbytes;
|
||||
#else
|
||||
SPDR = reg;
|
||||
while(!(SPSR & (1 << SPIF))); //wait
|
||||
|
|
10
usbhub.h
10
usbhub.h
|
@ -191,16 +191,16 @@ public:
|
|||
|
||||
void PrintHubStatus();
|
||||
|
||||
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
virtual uint8_t Release();
|
||||
virtual uint8_t Poll();
|
||||
virtual void ResetHubPort(uint8_t port);
|
||||
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||
uint8_t Release();
|
||||
uint8_t Poll();
|
||||
void ResetHubPort(uint8_t port);
|
||||
|
||||
virtual uint8_t GetAddress() {
|
||||
return bAddress;
|
||||
};
|
||||
|
||||
virtual boolean DEVCLASSOK(uint8_t klass) {
|
||||
virtual bool DEVCLASSOK(uint8_t klass) {
|
||||
return (klass == 0x09);
|
||||
}
|
||||
|
||||
|
|
222
version_helper.h
Normal file
222
version_helper.h
Normal file
|
@ -0,0 +1,222 @@
|
|||
/* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
|
||||
|
||||
This software may be distributed and modified under the terms of the GNU
|
||||
General Public License version 2 (GPL2) as published by the Free Software
|
||||
Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||
this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||
on this software must also be made publicly available under the terms of
|
||||
the GPL2 ("Copyleft").
|
||||
|
||||
Contact information
|
||||
-------------------
|
||||
|
||||
Circuits At Home, LTD
|
||||
Web : http://www.circuitsathome.com
|
||||
e-mail : support@circuitsathome.com
|
||||
*/
|
||||
|
||||
/*
|
||||
* Universal Arduino(tm) "IDE" fixups.
|
||||
* Includes fixes for versions as low as 0023, used by Digilent.
|
||||
*/
|
||||
|
||||
#if defined(ARDUINO) && ARDUINO >=100
|
||||
#include <Arduino.h>
|
||||
#else
|
||||
#include <WProgram.h>
|
||||
#include <pins_arduino.h>
|
||||
#ifdef __AVR__
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/io.h>
|
||||
#else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PGMSPACE_H_
|
||||
#define __PGMSPACE_H_ 1
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef PROGMEM
|
||||
#define PROGMEM
|
||||
#endif
|
||||
#ifndef PGM_P
|
||||
#define PGM_P const char *
|
||||
#endif
|
||||
#ifndef PSTR
|
||||
#define PSTR(str) (str)
|
||||
#endif
|
||||
#ifndef F
|
||||
#define F(str) (str)
|
||||
#endif
|
||||
#ifndef _SFR_BYTE
|
||||
#define _SFR_BYTE(n) (n)
|
||||
#endif
|
||||
|
||||
#ifndef prog_void
|
||||
typedef void prog_void;
|
||||
#endif
|
||||
#ifndef prog_char
|
||||
typedef char prog_char;
|
||||
#endif
|
||||
#ifndef prog_uchar
|
||||
typedef unsigned char prog_uchar;
|
||||
#endif
|
||||
#ifndef prog_int8_t
|
||||
typedef int8_t prog_int8_t;
|
||||
#endif
|
||||
#ifndef prog_uint8_t
|
||||
typedef uint8_t prog_uint8_t;
|
||||
#endif
|
||||
#ifndef prog_int16_t
|
||||
typedef int16_t prog_int16_t;
|
||||
#endif
|
||||
#ifndef prog_uint16_t
|
||||
typedef uint16_t prog_uint16_t;
|
||||
#endif
|
||||
#ifndef prog_int32_t
|
||||
typedef int32_t prog_int32_t;
|
||||
#endif
|
||||
#ifndef prog_uint32_t
|
||||
typedef uint32_t prog_uint32_t;
|
||||
#endif
|
||||
|
||||
#ifndef memchr_P
|
||||
#define memchr_P(str, c, len) memchr((str), (c), (len))
|
||||
#endif
|
||||
#ifndef memcmp_P
|
||||
#define memcmp_P(a, b, n) memcmp((a), (b), (n))
|
||||
#endif
|
||||
#ifndef memcpy_P
|
||||
#define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
|
||||
#endif
|
||||
#ifndef memmem_P
|
||||
#define memmem_P(a, alen, b, blen) memmem((a), (alen), (b), (blen))
|
||||
#endif
|
||||
#ifndef memrchr_P
|
||||
#define memrchr_P(str, val, len) memrchr((str), (val), (len))
|
||||
#endif
|
||||
#ifndef strcat_P
|
||||
#define strcat_P(dest, src) strcat((dest), (src))
|
||||
#endif
|
||||
#ifndef strchr_P
|
||||
#define strchr_P(str, c) strchr((str), (c))
|
||||
#endif
|
||||
#ifndef strchrnul_P
|
||||
#define strchrnul_P(str, c) strchrnul((str), (c))
|
||||
#endif
|
||||
#ifndef strcmp_P
|
||||
#define strcmp_P(a, b) strcmp((a), (b))
|
||||
#endif
|
||||
#ifndef strcpy_P
|
||||
#define strcpy_P(dest, src) strcpy((dest), (src))
|
||||
#endif
|
||||
#ifndef strcasecmp_P
|
||||
#define strcasecmp_P(a, b) strcasecmp((a), (b))
|
||||
#endif
|
||||
#ifndef strcasestr_P
|
||||
#define strcasestr_P(a, b) strcasestr((a), (b))
|
||||
#endif
|
||||
#ifndef strlcat_P
|
||||
#define strlcat_P(dest, src, len) strlcat((dest), (src), (len))
|
||||
#endif
|
||||
#ifndef strlcpy_P
|
||||
#define strlcpy_P(dest, src, len) strlcpy((dest), (src), (len))
|
||||
#endif
|
||||
#ifndef strlen_P
|
||||
#define strlen_P(s) strlen((const char *)(s))
|
||||
#endif
|
||||
#ifndef strnlen_P
|
||||
#define strnlen_P(str, len) strnlen((str), (len))
|
||||
#endif
|
||||
#ifndef strncmp_P
|
||||
#define strncmp_P(a, b, n) strncmp((a), (b), (n))
|
||||
#endif
|
||||
#ifndef strncasecmp_P
|
||||
#define strncasecmp_P(a, b, n) strncasecmp((a), (b), (n))
|
||||
#endif
|
||||
#ifndef strncat_P
|
||||
#define strncat_P(a, b, n) strncat((a), (b), (n))
|
||||
#endif
|
||||
#ifndef strncpy_P
|
||||
#define strncpy_P(a, b, n) strncmp((a), (b), (n))
|
||||
#endif
|
||||
#ifndef strpbrk_P
|
||||
#define strpbrk_P(str, chrs) strpbrk((str), (chrs))
|
||||
#endif
|
||||
#ifndef strrchr_P
|
||||
#define strrchr_P(str, c) strrchr((str), (c))
|
||||
#endif
|
||||
#ifndef strsep_P
|
||||
#define strsep_P(strp, delim) strsep((strp), (delim))
|
||||
#endif
|
||||
#ifndef strspn_P
|
||||
#define strspn_P(str, chrs) strspn((str), (chrs))
|
||||
#endif
|
||||
#ifndef strstr_P
|
||||
#define strstr_P(a, b) strstr((a), (b))
|
||||
#endif
|
||||
#ifndef sprintf_P
|
||||
#define sprintf_P(s, ...) sprintf((s), __VA_ARGS__)
|
||||
#endif
|
||||
#ifndef vfprintf_P
|
||||
#define vfprintf_P(s, ...) vfprintf((s), __VA_ARGS__)
|
||||
#endif
|
||||
#ifndef printf_P
|
||||
#define printf_P(...) printf(__VA_ARGS__)
|
||||
#endif
|
||||
#ifndef snprintf_P
|
||||
#define snprintf_P(s, n, ...) ((s), (n), __VA_ARGS__)
|
||||
#endif
|
||||
#ifndef vsprintf_P
|
||||
#define vsprintf_P(s, ...) ((s),__VA_ARGS__)
|
||||
#endif
|
||||
#ifndef vsnprintf_P
|
||||
#define vsnprintf_P(s, n, ...) ((s), (n),__VA_ARGS__)
|
||||
#endif
|
||||
#ifndef fprintf_P
|
||||
#define fprintf_P(s, ...) ((s), __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifndef pgm_read_byte
|
||||
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
|
||||
#endif
|
||||
#ifndef pgm_read_word
|
||||
#define pgm_read_word(addr) (*(const unsigned short *)(addr))
|
||||
#endif
|
||||
#ifndef pgm_read_dword
|
||||
#define pgm_read_dword(addr) (*(const unsigned long *)(addr))
|
||||
#endif
|
||||
#ifndef pgm_read_float
|
||||
#define pgm_read_float(addr) (*(const float *)(addr))
|
||||
#endif
|
||||
|
||||
#ifndef pgm_read_byte_near
|
||||
#define pgm_read_byte_near(addr) pgm_read_byte(addr)
|
||||
#endif
|
||||
#ifndef pgm_read_word_near
|
||||
#define pgm_read_word_near(addr) pgm_read_word(addr)
|
||||
#endif
|
||||
#ifndef pgm_read_dword_near
|
||||
#define pgm_read_dword_near(addr) pgm_read_dword(addr)
|
||||
#endif
|
||||
#ifndef pgm_read_float_near
|
||||
#define pgm_read_float_near(addr) pgm_read_float(addr)
|
||||
#endif
|
||||
#ifndef pgm_read_byte_far
|
||||
#define pgm_read_byte_far(addr) pgm_read_byte(addr)
|
||||
#endif
|
||||
#ifndef pgm_read_word_far
|
||||
#define pgm_read_word_far(addr) pgm_read_word(addr)
|
||||
#endif
|
||||
#ifndef pgm_read_dword_far
|
||||
#define pgm_read_dword_far(addr) pgm_read_dword(addr)
|
||||
#endif
|
||||
#ifndef pgm_read_float_far
|
||||
#define pgm_read_float_far(addr) pgm_read_float(addr)
|
||||
#endif
|
||||
|
||||
#ifndef pgm_read_pointer
|
||||
#define pgm_read_pointer
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in a new issue