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: Usb.h avrpins.h usbhost.h
This commit is contained in:
commit
73ce976198
61 changed files with 15019 additions and 14416 deletions
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
|
* text eol=lf
|
||||||
|
|
||||||
|
# Custom for Visual Studio
|
||||||
|
*.cs diff=csharp
|
||||||
|
*.sln merge=union
|
||||||
|
*.csproj merge=union
|
||||||
|
*.vbproj merge=union
|
||||||
|
*.fsproj merge=union
|
||||||
|
*.dbproj merge=union
|
||||||
|
|
||||||
|
# Standard to msysgit
|
||||||
|
*.doc diff=astextplain
|
||||||
|
*.DOC diff=astextplain
|
||||||
|
*.docx diff=astextplain
|
||||||
|
*.DOCX diff=astextplain
|
||||||
|
*.dot diff=astextplain
|
||||||
|
*.DOT diff=astextplain
|
||||||
|
*.pdf diff=astextplain
|
||||||
|
*.PDF diff=astextplain
|
||||||
|
*.rtf diff=astextplain
|
||||||
|
*.RTF diff=astextplain
|
4
BTD.cpp
4
BTD.cpp
|
@ -1343,7 +1343,7 @@ void BTD::setBdaddr(uint8_t* bdaddr) {
|
||||||
buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed, so it is MSB first
|
buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed, so it is MSB first
|
||||||
|
|
||||||
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
||||||
pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTD::setMoveBdaddr(uint8_t* bdaddr) {
|
void BTD::setMoveBdaddr(uint8_t* bdaddr) {
|
||||||
|
@ -1359,5 +1359,5 @@ void BTD::setMoveBdaddr(uint8_t* bdaddr) {
|
||||||
buf[i + 1] = bdaddr[i];
|
buf[i + 1] = bdaddr[i];
|
||||||
|
|
||||||
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
||||||
pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
2
BTD.h
2
BTD.h
|
@ -19,7 +19,7 @@
|
||||||
#define _btd_h_
|
#define _btd_h_
|
||||||
|
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
#include "Hid.h"
|
#include "hid.h"
|
||||||
|
|
||||||
//PID and VID of the Sony PS3 devices
|
//PID and VID of the Sony PS3 devices
|
||||||
#define PS3_VID 0x054C // Sony Corporation
|
#define PS3_VID 0x054C // Sony Corporation
|
||||||
|
|
14
PS3USB.cpp
14
PS3USB.cpp
|
@ -398,7 +398,7 @@ void PS3USB::printStatusString() {
|
||||||
/* Playstation Sixaxis Dualshock and Navigation Controller commands */
|
/* Playstation Sixaxis Dualshock and Navigation Controller commands */
|
||||||
void PS3USB::PS3_Command(uint8_t *data, uint16_t nbytes) {
|
void PS3USB::PS3_Command(uint8_t *data, uint16_t nbytes) {
|
||||||
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x01), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
|
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x01), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
|
||||||
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x01, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0x01, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3USB::setAllOff() {
|
void PS3USB::setAllOff() {
|
||||||
|
@ -470,14 +470,14 @@ void PS3USB::setBdaddr(uint8_t *bdaddr) {
|
||||||
buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed, so it is MSB first
|
buf[i + 2] = bdaddr[5 - i]; // Copy into buffer, has to be written reversed, so it is MSB first
|
||||||
|
|
||||||
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
||||||
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3USB::getBdaddr(uint8_t *bdaddr) {
|
void PS3USB::getBdaddr(uint8_t *bdaddr) {
|
||||||
uint8_t buf[8];
|
uint8_t buf[8];
|
||||||
|
|
||||||
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
||||||
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HIDIN, HID_REQUEST_GET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
||||||
|
|
||||||
for(uint8_t i = 0; i < 6; i++)
|
for(uint8_t i = 0; i < 6; i++)
|
||||||
bdaddr[5 - i] = buf[i + 2]; // Copy into buffer reversed, so it is LSB first
|
bdaddr[5 - i] = buf[i + 2]; // Copy into buffer reversed, so it is LSB first
|
||||||
|
@ -491,7 +491,7 @@ void PS3USB::enable_sixaxis() { // Command used to enable the Dualshock 3 and Na
|
||||||
cmd_buf[3] = 0x00;
|
cmd_buf[3] = 0x00;
|
||||||
|
|
||||||
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF4), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
|
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF4), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
|
||||||
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF4, 0x03, 0x00, 4, 4, cmd_buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0xF4, 0x03, 0x00, 4, 4, cmd_buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Playstation Move Controller commands */
|
/* Playstation Move Controller commands */
|
||||||
|
@ -535,14 +535,14 @@ void PS3USB::setMoveBdaddr(uint8_t *bdaddr) {
|
||||||
buf[i + 1] = bdaddr[i];
|
buf[i + 1] = bdaddr[i];
|
||||||
|
|
||||||
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
||||||
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS3USB::getMoveBdaddr(uint8_t *bdaddr) {
|
void PS3USB::getMoveBdaddr(uint8_t *bdaddr) {
|
||||||
uint8_t buf[16];
|
uint8_t buf[16];
|
||||||
|
|
||||||
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0x04), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0x04), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
||||||
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0x04, 0x03, 0x00, 16, 16, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HIDIN, HID_REQUEST_GET_REPORT, 0x04, 0x03, 0x00, 16, 16, buf, NULL);
|
||||||
|
|
||||||
for(uint8_t i = 0; i < 6; i++)
|
for(uint8_t i = 0; i < 6; i++)
|
||||||
bdaddr[i] = buf[10 + i];
|
bdaddr[i] = buf[10 + i];
|
||||||
|
@ -553,7 +553,7 @@ void PS3USB::getMoveCalibration(uint8_t *data) {
|
||||||
|
|
||||||
for(uint8_t i = 0; i < 3; i++) {
|
for(uint8_t i = 0; i < 3; i++) {
|
||||||
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0x10), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
// bmRequest = Device to host (0x80) | Class (0x20) | Interface (0x01) = 0xA1, bRequest = Get Report (0x01), Report ID (0x10), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data
|
||||||
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, 0x10, 0x03, 0x00, 49, 49, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HIDIN, HID_REQUEST_GET_REPORT, 0x10, 0x03, 0x00, 49, 49, buf, NULL);
|
||||||
|
|
||||||
for(byte j = 0; j < 49; j++)
|
for(byte j = 0; j < 49; j++)
|
||||||
data[49 * i + j] = buf[j];
|
data[49 * i + j] = buf[j];
|
||||||
|
|
2
PS3USB.h
2
PS3USB.h
|
@ -19,7 +19,7 @@
|
||||||
#define _ps3usb_h_
|
#define _ps3usb_h_
|
||||||
|
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
#include "Hid.h"
|
#include "hid.h"
|
||||||
#include "PS3Enums.h"
|
#include "PS3Enums.h"
|
||||||
|
|
||||||
/* PS3 data taken from descriptors */
|
/* PS3 data taken from descriptors */
|
||||||
|
|
|
@ -78,5 +78,5 @@ void PSBuzz::setLedRaw(bool value, uint8_t controller) {
|
||||||
|
|
||||||
void PSBuzz::PSBuzz_Command(uint8_t *data, uint16_t nbytes) {
|
void PSBuzz::PSBuzz_Command(uint8_t *data, uint16_t nbytes) {
|
||||||
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
|
// bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
|
||||||
pUsb->ctrlReq(bAddress, epInfo[0].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[0].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
||||||
};
|
};
|
16
README.md
16
README.md
|
@ -285,7 +285,7 @@ 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.
|
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!
|
Note this means that it uses pin 13, 12, 11 on an Arduino Uno, so these pins can not be used for anything else than SPI communication!
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
@ -309,3 +309,17 @@ See the "Interface modifications" section in the [hardware manual](https://www.c
|
||||||
|
|
||||||
* Try to connect a external power supply to the Arduino - this solves the problem in most cases.
|
* Try to connect a external power supply to the Arduino - this solves the problem in most cases.
|
||||||
* You can also use a powered hub between the device and the USB Host Shield. You should then include the USB hub library: ```#include <usbhub.h>``` and create the instance like so: ```USBHub Hub1(&Usb);```.
|
* You can also use a powered hub between the device and the USB Host Shield. You should then include the USB hub library: ```#include <usbhub.h>``` and create the instance like so: ```USBHub Hub1(&Usb);```.
|
||||||
|
|
||||||
|
> When I connecting my PS3 controller I get a output like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
Dualshock 3 Controller Enabled
|
||||||
|
|
||||||
|
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
|
||||||
|
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
|
||||||
|
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
|
||||||
|
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
|
||||||
|
LeftHatX: 0 LeftHatY: 0 RightHatX: 0 RightHatY: 0
|
||||||
|
```
|
||||||
|
|
||||||
|
* This means that your dongle does not support 2.0+EDR, so you will need another dongle. Please see the following [list](https://github.com/felis/USB_Host_Shield_2.0/wiki/Bluetooth-dongles) for tested working dongles.
|
||||||
|
|
18
Usb.cpp
18
Usb.cpp
|
@ -77,7 +77,7 @@ uint8_t USB::setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t &nak_limit) {
|
uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) {
|
||||||
UsbDevice *p = addrPool.GetUsbDevicePtr(addr);
|
UsbDevice *p = addrPool.GetUsbDevicePtr(addr);
|
||||||
|
|
||||||
if(!p)
|
if(!p)
|
||||||
|
@ -91,8 +91,8 @@ uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t &nak_l
|
||||||
if(!*ppep)
|
if(!*ppep)
|
||||||
return USB_ERROR_EP_NOT_FOUND_IN_TBL;
|
return USB_ERROR_EP_NOT_FOUND_IN_TBL;
|
||||||
|
|
||||||
nak_limit = (0x0001UL << (((*ppep)->bmNakPower > USB_NAK_MAX_POWER) ? USB_NAK_MAX_POWER : (*ppep)->bmNakPower));
|
*nak_limit = (0x0001UL << (((*ppep)->bmNakPower > USB_NAK_MAX_POWER) ? USB_NAK_MAX_POWER : (*ppep)->bmNakPower));
|
||||||
nak_limit--;
|
*nak_limit--;
|
||||||
/*
|
/*
|
||||||
USBTRACE2("\r\nAddress: ", addr);
|
USBTRACE2("\r\nAddress: ", addr);
|
||||||
USBTRACE2(" EP: ", ep);
|
USBTRACE2(" EP: ", ep);
|
||||||
|
@ -132,7 +132,7 @@ uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bReque
|
||||||
EpInfo *pep = NULL;
|
EpInfo *pep = NULL;
|
||||||
uint16_t nak_limit = 0;
|
uint16_t nak_limit = 0;
|
||||||
|
|
||||||
rcode = SetAddress(addr, ep, &pep, nak_limit);
|
rcode = SetAddress(addr, ep, &pep, &nak_limit);
|
||||||
|
|
||||||
if(rcode)
|
if(rcode)
|
||||||
return rcode;
|
return rcode;
|
||||||
|
@ -207,7 +207,7 @@ uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t*
|
||||||
EpInfo *pep = NULL;
|
EpInfo *pep = NULL;
|
||||||
uint16_t nak_limit = 0;
|
uint16_t nak_limit = 0;
|
||||||
|
|
||||||
uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit);
|
uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit);
|
||||||
|
|
||||||
if(rcode) {
|
if(rcode) {
|
||||||
USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81);
|
USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81);
|
||||||
|
@ -293,7 +293,7 @@ uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dat
|
||||||
EpInfo *pep = NULL;
|
EpInfo *pep = NULL;
|
||||||
uint16_t nak_limit = 0;
|
uint16_t nak_limit = 0;
|
||||||
|
|
||||||
uint8_t rcode = SetAddress(addr, ep, &pep, nak_limit);
|
uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit);
|
||||||
|
|
||||||
if(rcode)
|
if(rcode)
|
||||||
return rcode;
|
return rcode;
|
||||||
|
@ -528,7 +528,7 @@ void USB::Task(void) //USB state machine
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
//uint8_t buf[12];
|
//uint8_t buf[12];
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p0 = NULL, *p = NULL;
|
UsbDevice *p0 = NULL, *p = NULL;
|
||||||
|
|
||||||
|
@ -733,8 +733,8 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
//printf("ERROR ENUMERATING %2.2x\r\n", rcode);
|
//printf("ERROR ENUMERATING %2.2x\r\n", rcode);
|
||||||
if(!(rcode == USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED || rcode == USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE)) {
|
if(!(rcode == USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED || rcode == USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE)) {
|
||||||
// in case of an error dev_index should be reset to 0
|
// in case of an error dev_index should be reset to 0
|
||||||
// in order to start from the very beginning the
|
// in order to start from the very beginning the
|
||||||
// next time the program gets here
|
// next time the program gets here
|
||||||
//if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE)
|
//if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE)
|
||||||
// devConfigIndex = 0;
|
// devConfigIndex = 0;
|
||||||
return rcode;
|
return rcode;
|
||||||
|
|
88
UsbCore.h
88
UsbCore.h
|
@ -18,7 +18,7 @@ e-mail : support@circuitsathome.com
|
||||||
#if !defined(_usb_h_) || defined(USBCORE_H)
|
#if !defined(_usb_h_) || defined(USBCORE_H)
|
||||||
#error "Never include UsbCore.h directly; include Usb.h instead"
|
#error "Never include UsbCore.h directly; include Usb.h instead"
|
||||||
#else
|
#else
|
||||||
#define USBCORE_H
|
#define USBCORE_H
|
||||||
|
|
||||||
// Not used anymore? If anyone uses this, please let us know so that this may be
|
// Not used anymore? If anyone uses this, please let us know so that this may be
|
||||||
// moved to the proper place, settings.h.
|
// moved to the proper place, settings.h.
|
||||||
|
@ -46,57 +46,57 @@ typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega
|
||||||
#define bmREQ_SET USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE //set request type for all but 'set feature' and 'set interface'
|
#define bmREQ_SET USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_DEVICE //set request type for all but 'set feature' and 'set interface'
|
||||||
#define bmREQ_CL_GET_INTF USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE //get interface request type
|
#define bmREQ_CL_GET_INTF USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE //get interface request type
|
||||||
|
|
||||||
// D7 data transfer direction (0 - host-to-device, 1 - device-to-host)
|
// D7 data transfer direction (0 - host-to-device, 1 - device-to-host)
|
||||||
// D6-5 Type (0- standard, 1 - class, 2 - vendor, 3 - reserved)
|
// D6-5 Type (0- standard, 1 - class, 2 - vendor, 3 - reserved)
|
||||||
// D4-0 Recipient (0 - device, 1 - interface, 2 - endpoint, 3 - other, 4..31 - reserved)
|
// D4-0 Recipient (0 - device, 1 - interface, 2 - endpoint, 3 - other, 4..31 - reserved)
|
||||||
|
|
||||||
// USB Device Classes
|
// USB Device Classes
|
||||||
#define USB_CLASS_USE_CLASS_INFO 0x00 // Use Class Info in the Interface Descriptors
|
#define USB_CLASS_USE_CLASS_INFO 0x00 // Use Class Info in the Interface Descriptors
|
||||||
#define USB_CLASS_AUDIO 0x01 // Audio
|
#define USB_CLASS_AUDIO 0x01 // Audio
|
||||||
#define USB_CLASS_COM_AND_CDC_CTRL 0x02 // Communications and CDC Control
|
#define USB_CLASS_COM_AND_CDC_CTRL 0x02 // Communications and CDC Control
|
||||||
#define USB_CLASS_HID 0x03 // HID
|
#define USB_CLASS_HID 0x03 // HID
|
||||||
#define USB_CLASS_PHYSICAL 0x05 // Physical
|
#define USB_CLASS_PHYSICAL 0x05 // Physical
|
||||||
#define USB_CLASS_IMAGE 0x06 // Image
|
#define USB_CLASS_IMAGE 0x06 // Image
|
||||||
#define USB_CLASS_PRINTER 0x07 // Printer
|
#define USB_CLASS_PRINTER 0x07 // Printer
|
||||||
#define USB_CLASS_MASS_STORAGE 0x08 // Mass Storage
|
#define USB_CLASS_MASS_STORAGE 0x08 // Mass Storage
|
||||||
#define USB_CLASS_HUB 0x09 // Hub
|
#define USB_CLASS_HUB 0x09 // Hub
|
||||||
#define USB_CLASS_CDC_DATA 0x0a // CDC-Data
|
#define USB_CLASS_CDC_DATA 0x0a // CDC-Data
|
||||||
#define USB_CLASS_SMART_CARD 0x0b // Smart-Card
|
#define USB_CLASS_SMART_CARD 0x0b // Smart-Card
|
||||||
#define USB_CLASS_CONTENT_SECURITY 0x0d // Content Security
|
#define USB_CLASS_CONTENT_SECURITY 0x0d // Content Security
|
||||||
#define USB_CLASS_VIDEO 0x0e // Video
|
#define USB_CLASS_VIDEO 0x0e // Video
|
||||||
#define USB_CLASS_PERSONAL_HEALTH 0x0f // Personal Healthcare
|
#define USB_CLASS_PERSONAL_HEALTH 0x0f // Personal Healthcare
|
||||||
#define USB_CLASS_DIAGNOSTIC_DEVICE 0xdc // Diagnostic Device
|
#define USB_CLASS_DIAGNOSTIC_DEVICE 0xdc // Diagnostic Device
|
||||||
#define USB_CLASS_WIRELESS_CTRL 0xe0 // Wireless Controller
|
#define USB_CLASS_WIRELESS_CTRL 0xe0 // Wireless Controller
|
||||||
#define USB_CLASS_MISC 0xef // Miscellaneous
|
#define USB_CLASS_MISC 0xef // Miscellaneous
|
||||||
#define USB_CLASS_APP_SPECIFIC 0xfe // Application Specific
|
#define USB_CLASS_APP_SPECIFIC 0xfe // Application Specific
|
||||||
#define USB_CLASS_VENDOR_SPECIFIC 0xff // Vendor Specific
|
#define USB_CLASS_VENDOR_SPECIFIC 0xff // Vendor Specific
|
||||||
|
|
||||||
// Additional Error Codes
|
// Additional Error Codes
|
||||||
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED 0xD1
|
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED 0xD1
|
||||||
#define USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE 0xD2
|
#define USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE 0xD2
|
||||||
#define USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS 0xD3
|
#define USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS 0xD3
|
||||||
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL 0xD4
|
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL 0xD4
|
||||||
#define USB_ERROR_HUB_ADDRESS_OVERFLOW 0xD5
|
#define USB_ERROR_HUB_ADDRESS_OVERFLOW 0xD5
|
||||||
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL 0xD6
|
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL 0xD6
|
||||||
#define USB_ERROR_EPINFO_IS_NULL 0xD7
|
#define USB_ERROR_EPINFO_IS_NULL 0xD7
|
||||||
#define USB_ERROR_INVALID_ARGUMENT 0xD8
|
#define USB_ERROR_INVALID_ARGUMENT 0xD8
|
||||||
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE 0xD9
|
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE 0xD9
|
||||||
#define USB_ERROR_INVALID_MAX_PKT_SIZE 0xDA
|
#define USB_ERROR_INVALID_MAX_PKT_SIZE 0xDA
|
||||||
#define USB_ERROR_EP_NOT_FOUND_IN_TBL 0xDB
|
#define USB_ERROR_EP_NOT_FOUND_IN_TBL 0xDB
|
||||||
#define USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET 0xE0
|
#define USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET 0xE0
|
||||||
#define USB_ERROR_FailGetDevDescr 0xE1
|
#define USB_ERROR_FailGetDevDescr 0xE1
|
||||||
#define USB_ERROR_FailSetDevTblEntry 0xE2
|
#define USB_ERROR_FailSetDevTblEntry 0xE2
|
||||||
#define USB_ERROR_FailGetConfDescr 0xE3
|
#define USB_ERROR_FailGetConfDescr 0xE3
|
||||||
#define USB_ERROR_TRANSFER_TIMEOUT 0xFF
|
#define USB_ERROR_TRANSFER_TIMEOUT 0xFF
|
||||||
|
|
||||||
#define USB_XFER_TIMEOUT 10000 //30000 // (5000) USB transfer timeout in milliseconds, per section 9.2.6.1 of USB 2.0 spec
|
#define USB_XFER_TIMEOUT 5000 // (5000) USB transfer timeout in milliseconds, per section 9.2.6.1 of USB 2.0 spec
|
||||||
//#define USB_NAK_LIMIT 32000 //NAK limit for a transfer. 0 means NAKs are not counted
|
//#define USB_NAK_LIMIT 32000 // NAK limit for a transfer. 0 means NAKs are not counted
|
||||||
#define USB_RETRY_LIMIT 3 // 3 retry limit for a transfer
|
#define USB_RETRY_LIMIT 3 // 3 retry limit for a transfer
|
||||||
#define USB_SETTLE_DELAY 200 //settle delay in milliseconds
|
#define USB_SETTLE_DELAY 200 // settle delay in milliseconds
|
||||||
|
|
||||||
#define USB_NUMDEVICES 16 //number of USB devices
|
#define USB_NUMDEVICES 16 //number of USB devices
|
||||||
//#define HUB_MAX_HUBS 7 // maximum number of hubs that can be attached to the host controller
|
//#define HUB_MAX_HUBS 7 // maximum number of hubs that can be attached to the host controller
|
||||||
#define HUB_PORT_RESET_DELAY 20 // hub port reset delay 10 ms recomended, can be up to 20 ms
|
#define HUB_PORT_RESET_DELAY 20 // hub port reset delay 10 ms recomended, can be up to 20 ms
|
||||||
|
|
||||||
/* USB state machine states */
|
/* USB state machine states */
|
||||||
#define USB_STATE_MASK 0xf0
|
#define USB_STATE_MASK 0xf0
|
||||||
|
@ -258,7 +258,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
uint8_t SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t &nak_limit);
|
uint8_t SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit);
|
||||||
uint8_t OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data);
|
uint8_t OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data);
|
||||||
uint8_t InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data);
|
uint8_t InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data);
|
||||||
uint8_t AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed);
|
uint8_t AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed);
|
||||||
|
@ -293,4 +293,4 @@ inline uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) {
|
||||||
|
|
||||||
#endif // defined(USB_METHODS_INLINE)
|
#endif // defined(USB_METHODS_INLINE)
|
||||||
|
|
||||||
#endif /* USBCORE_H */
|
#endif /* USBCORE_H */
|
||||||
|
|
|
@ -320,7 +320,7 @@ int16_t XBOXOLD::getAnalogHat(AnalogHatEnum a) {
|
||||||
/* Xbox Controller commands */
|
/* Xbox Controller commands */
|
||||||
void XBOXOLD::XboxCommand(uint8_t* data, uint16_t nbytes) {
|
void XBOXOLD::XboxCommand(uint8_t* data, uint16_t nbytes) {
|
||||||
//bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
|
//bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
|
||||||
pUsb->ctrlReq(bAddress, epInfo[XBOX_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[XBOX_CONTROL_PIPE].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XBOXOLD::setRumbleOn(uint8_t lValue, uint8_t rValue) {
|
void XBOXOLD::setRumbleOn(uint8_t lValue, uint8_t rValue) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#define _xboxold_h_
|
#define _xboxold_h_
|
||||||
|
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
#include "Hid.h"
|
#include "hid.h"
|
||||||
#include "controllerEnums.h"
|
#include "controllerEnums.h"
|
||||||
|
|
||||||
/* Data Xbox taken from descriptors */
|
/* Data Xbox taken from descriptors */
|
||||||
|
|
|
@ -314,7 +314,7 @@ int16_t XBOXUSB::getAnalogHat(AnalogHatEnum a) {
|
||||||
/* Xbox Controller commands */
|
/* Xbox Controller commands */
|
||||||
void XBOXUSB::XboxCommand(uint8_t* data, uint16_t nbytes) {
|
void XBOXUSB::XboxCommand(uint8_t* data, uint16_t nbytes) {
|
||||||
//bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
|
//bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x00), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
|
||||||
pUsb->ctrlReq(bAddress, epInfo[XBOX_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[XBOX_CONTROL_PIPE].epAddr, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XBOXUSB::setLedRaw(uint8_t value) {
|
void XBOXUSB::setLedRaw(uint8_t value) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#define _xboxusb_h_
|
#define _xboxusb_h_
|
||||||
|
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
#include "Hid.h"
|
#include "hid.h"
|
||||||
#include "xboxEnums.h"
|
#include "xboxEnums.h"
|
||||||
|
|
||||||
/* Data Xbox 360 taken from descriptors */
|
/* Data Xbox 360 taken from descriptors */
|
||||||
|
|
34
address.h
34
address.h
|
@ -24,10 +24,10 @@ e-mail : support@circuitsathome.com
|
||||||
|
|
||||||
/* NAK powers. To save space in endpoint data structure, amount of retries before giving up and returning 0x4 is stored in */
|
/* NAK powers. To save space in endpoint data structure, amount of retries before giving up and returning 0x4 is stored in */
|
||||||
/* bmNakPower as a power of 2. The actual nak_limit is then calculated as nak_limit = ( 2^bmNakPower - 1) */
|
/* bmNakPower as a power of 2. The actual nak_limit is then calculated as nak_limit = ( 2^bmNakPower - 1) */
|
||||||
#define USB_NAK_MAX_POWER 15 //NAK binary order maximum value
|
#define USB_NAK_MAX_POWER 15 //NAK binary order maximum value
|
||||||
#define USB_NAK_DEFAULT 14 //default 32K-1 NAKs before giving up
|
#define USB_NAK_DEFAULT 14 //default 32K-1 NAKs before giving up
|
||||||
#define USB_NAK_NOWAIT 1 //Single NAK stops transfer
|
#define USB_NAK_NOWAIT 1 //Single NAK stops transfer
|
||||||
#define USB_NAK_NONAK 0 //Do not count NAKs, stop retrying after USB Timeout
|
#define USB_NAK_NONAK 0 //Do not count NAKs, stop retrying after USB Timeout
|
||||||
|
|
||||||
struct EpInfo {
|
struct EpInfo {
|
||||||
uint8_t epAddr; // Endpoint address
|
uint8_t epAddr; // Endpoint address
|
||||||
|
@ -44,7 +44,7 @@ struct EpInfo {
|
||||||
};
|
};
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
// 7 6 5 4 3 2 1 0
|
// 7 6 5 4 3 2 1 0
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
// | | H | P | P | P | A | A | A |
|
// | | H | P | P | P | A | A | A |
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
|
@ -68,16 +68,16 @@ struct UsbDeviceAddress {
|
||||||
};
|
};
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
#define bmUSB_DEV_ADDR_ADDRESS 0x07
|
#define bmUSB_DEV_ADDR_ADDRESS 0x07
|
||||||
#define bmUSB_DEV_ADDR_PARENT 0x38
|
#define bmUSB_DEV_ADDR_PARENT 0x38
|
||||||
#define bmUSB_DEV_ADDR_HUB 0x40
|
#define bmUSB_DEV_ADDR_HUB 0x40
|
||||||
|
|
||||||
struct UsbDevice {
|
struct UsbDevice {
|
||||||
EpInfo *epinfo; // endpoint info pointer
|
EpInfo *epinfo; // endpoint info pointer
|
||||||
UsbDeviceAddress address;
|
UsbDeviceAddress address;
|
||||||
uint8_t epcount; // number of endpoints
|
uint8_t epcount; // number of endpoints
|
||||||
bool lowspeed; // indicates if a device is the low speed one
|
bool lowspeed; // indicates if a device is the low speed one
|
||||||
// uint8_t devclass; // device class
|
// uint8_t devclass; // device class
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
class AddressPool {
|
class AddressPool {
|
||||||
|
@ -89,8 +89,8 @@ public:
|
||||||
|
|
||||||
typedef void (*UsbDeviceHandleFunc)(UsbDevice *pdev);
|
typedef void (*UsbDeviceHandleFunc)(UsbDevice *pdev);
|
||||||
|
|
||||||
#define ADDR_ERROR_INVALID_INDEX 0xFF
|
#define ADDR_ERROR_INVALID_INDEX 0xFF
|
||||||
#define ADDR_ERROR_INVALID_ADDRESS 0xFF
|
#define ADDR_ERROR_INVALID_ADDRESS 0xFF
|
||||||
|
|
||||||
template <const uint8_t MAX_DEVICES_ALLOWED>
|
template <const uint8_t MAX_DEVICES_ALLOWED>
|
||||||
class AddressPoolImpl : public AddressPool {
|
class AddressPoolImpl : public AddressPool {
|
||||||
|
@ -265,17 +265,17 @@ public:
|
||||||
// It can be rather helpfull to find out if there are hubs attached than getting the exact number of hubs.
|
// It can be rather helpfull to find out if there are hubs attached than getting the exact number of hubs.
|
||||||
//uint8_t GetNumHubs()
|
//uint8_t GetNumHubs()
|
||||||
//{
|
//{
|
||||||
// return hubCounter;
|
// return hubCounter;
|
||||||
//};
|
//};
|
||||||
//uint8_t GetNumDevices()
|
//uint8_t GetNumDevices()
|
||||||
//{
|
//{
|
||||||
// uint8_t counter = 0;
|
// uint8_t counter = 0;
|
||||||
|
|
||||||
// for (uint8_t i=1; i<MAX_DEVICES_ALLOWED; i++)
|
// for (uint8_t i=1; i<MAX_DEVICES_ALLOWED; i++)
|
||||||
// if (thePool[i].address != 0);
|
// if (thePool[i].address != 0);
|
||||||
// counter ++;
|
// counter ++;
|
||||||
|
|
||||||
// return counter;
|
// return counter;
|
||||||
//};
|
//};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
16
adk.cpp
16
adk.cpp
|
@ -293,8 +293,8 @@ FailSwAcc:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//FailOnInit:
|
//FailOnInit:
|
||||||
// USBTRACE("OnInit:");
|
// USBTRACE("OnInit:");
|
||||||
// goto Fail;
|
// goto Fail;
|
||||||
//
|
//
|
||||||
SwAttempt:
|
SwAttempt:
|
||||||
#ifdef DEBUG_USB_HOST
|
#ifdef DEBUG_USB_HOST
|
||||||
|
@ -356,16 +356,16 @@ uint8_t ADK::SndData(uint16_t nbytes, uint8_t *dataptr) {
|
||||||
void ADK::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
void ADK::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
211
cdc_XR21B1411.cpp
Normal file
211
cdc_XR21B1411.cpp
Normal file
|
@ -0,0 +1,211 @@
|
||||||
|
/* 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
|
||||||
|
*/
|
||||||
|
#include "cdc_XR21B1411.h"
|
||||||
|
|
||||||
|
XR21B1411::XR21B1411(USB *p, CDCAsyncOper *pasync) :
|
||||||
|
ACM(p, pasync) {
|
||||||
|
// Is this needed??
|
||||||
|
_enhanced_status = enhanced_features(); // Set up features
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t XR21B1411::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||||
|
|
||||||
|
uint8_t buf[constBufSize];
|
||||||
|
USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
|
||||||
|
|
||||||
|
uint8_t rcode;
|
||||||
|
UsbDevice *p = NULL;
|
||||||
|
EpInfo *oldep_ptr = NULL;
|
||||||
|
uint8_t num_of_conf; // number of configurations
|
||||||
|
|
||||||
|
AddressPool &addrPool = pUsb->GetAddressPool();
|
||||||
|
|
||||||
|
USBTRACE("XR Init\r\n");
|
||||||
|
|
||||||
|
if(bAddress)
|
||||||
|
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
|
||||||
|
|
||||||
|
// Get pointer to pseudo device with address 0 assigned
|
||||||
|
p = addrPool.GetUsbDevicePtr(0);
|
||||||
|
|
||||||
|
if(!p)
|
||||||
|
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
||||||
|
|
||||||
|
if(!p->epinfo) {
|
||||||
|
USBTRACE("epinfo\r\n");
|
||||||
|
return USB_ERROR_EPINFO_IS_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save old pointer to EP_RECORD of address 0
|
||||||
|
oldep_ptr = p->epinfo;
|
||||||
|
|
||||||
|
// Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence
|
||||||
|
p->epinfo = epInfo;
|
||||||
|
|
||||||
|
p->lowspeed = lowspeed;
|
||||||
|
|
||||||
|
// Get device descriptor
|
||||||
|
rcode = pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf);
|
||||||
|
|
||||||
|
// Restore p->epinfo
|
||||||
|
p->epinfo = oldep_ptr;
|
||||||
|
|
||||||
|
if(rcode)
|
||||||
|
goto FailGetDevDescr;
|
||||||
|
|
||||||
|
// Allocate new address according to device class
|
||||||
|
bAddress = addrPool.AllocAddress(parent, false, port);
|
||||||
|
|
||||||
|
if(!bAddress)
|
||||||
|
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
|
||||||
|
|
||||||
|
// Extract Max Packet Size from the device descriptor
|
||||||
|
epInfo[0].maxPktSize = udd->bMaxPacketSize0;
|
||||||
|
|
||||||
|
// Assign new address to the device
|
||||||
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
|
|
||||||
|
if(rcode) {
|
||||||
|
p->lowspeed = false;
|
||||||
|
addrPool.FreeAddress(bAddress);
|
||||||
|
bAddress = 0;
|
||||||
|
USBTRACE2("setAddr:", rcode);
|
||||||
|
return rcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
USBTRACE2("Addr:", bAddress);
|
||||||
|
|
||||||
|
p->lowspeed = false;
|
||||||
|
|
||||||
|
p = addrPool.GetUsbDevicePtr(bAddress);
|
||||||
|
|
||||||
|
if(!p)
|
||||||
|
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
|
||||||
|
|
||||||
|
p->lowspeed = lowspeed;
|
||||||
|
|
||||||
|
num_of_conf = udd->bNumConfigurations;
|
||||||
|
|
||||||
|
if((((udd->idVendor != 0x2890U) || (udd->idProduct != 0x0201U)) && ((udd->idVendor != 0x04e2U) || (udd->idProduct != 0x1411U))))
|
||||||
|
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
|
// Assign epInfo to epinfo pointer
|
||||||
|
rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
|
||||||
|
|
||||||
|
if(rcode)
|
||||||
|
goto FailSetDevTblEntry;
|
||||||
|
|
||||||
|
USBTRACE2("NC:", num_of_conf);
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i < num_of_conf; i++) {
|
||||||
|
ConfigDescParser< USB_CLASS_COM_AND_CDC_CTRL,
|
||||||
|
CDC_SUBCLASS_ACM,
|
||||||
|
CDC_PROTOCOL_ITU_T_V_250,
|
||||||
|
CP_MASK_COMPARE_CLASS |
|
||||||
|
CP_MASK_COMPARE_SUBCLASS |
|
||||||
|
CP_MASK_COMPARE_PROTOCOL > CdcControlParser(this);
|
||||||
|
|
||||||
|
ConfigDescParser<USB_CLASS_CDC_DATA, 0, 0,
|
||||||
|
CP_MASK_COMPARE_CLASS> CdcDataParser(this);
|
||||||
|
|
||||||
|
rcode = pUsb->getConfDescr(bAddress, 0, i, &CdcControlParser);
|
||||||
|
|
||||||
|
if(rcode)
|
||||||
|
goto FailGetConfDescr;
|
||||||
|
|
||||||
|
rcode = pUsb->getConfDescr(bAddress, 0, i, &CdcDataParser);
|
||||||
|
|
||||||
|
if(rcode)
|
||||||
|
goto FailGetConfDescr;
|
||||||
|
|
||||||
|
if(bNumEP > 1)
|
||||||
|
break;
|
||||||
|
} // for
|
||||||
|
|
||||||
|
if(bNumEP < 4)
|
||||||
|
return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
|
||||||
|
|
||||||
|
// Assign epInfo to epinfo pointer
|
||||||
|
rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo);
|
||||||
|
|
||||||
|
USBTRACE2("Conf:", bConfNum);
|
||||||
|
|
||||||
|
// Set Configuration Value
|
||||||
|
rcode = pUsb->setConf(bAddress, 0, bConfNum);
|
||||||
|
|
||||||
|
if(rcode)
|
||||||
|
goto FailSetConfDescr;
|
||||||
|
|
||||||
|
// Set up features status
|
||||||
|
_enhanced_status = enhanced_features();
|
||||||
|
half_duplex(false);
|
||||||
|
autoflowRTS(false);
|
||||||
|
autoflowDSR(false);
|
||||||
|
autoflowXON(false);
|
||||||
|
wide(false); // Always false, because this is only available in custom mode.
|
||||||
|
|
||||||
|
rcode = pAsync->OnInit(this);
|
||||||
|
|
||||||
|
if(rcode)
|
||||||
|
goto FailOnInit;
|
||||||
|
|
||||||
|
USBTRACE("XR configured\r\n");
|
||||||
|
|
||||||
|
ready = true;
|
||||||
|
|
||||||
|
//bPollEnable = true;
|
||||||
|
|
||||||
|
//USBTRACE("Poll enabled\r\n");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
FailGetDevDescr:
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
NotifyFailGetDevDescr();
|
||||||
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FailSetDevTblEntry:
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
NotifyFailSetDevTblEntry();
|
||||||
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FailGetConfDescr:
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
NotifyFailGetConfDescr();
|
||||||
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FailSetConfDescr:
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
NotifyFailSetConfDescr();
|
||||||
|
goto Fail;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FailOnInit:
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
USBTRACE("OnInit:");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_USB_HOST
|
||||||
|
Fail:
|
||||||
|
NotifyFail(rcode);
|
||||||
|
#endif
|
||||||
|
Release();
|
||||||
|
return rcode;
|
||||||
|
}
|
272
cdc_XR21B1411.h
Normal file
272
cdc_XR21B1411.h
Normal file
|
@ -0,0 +1,272 @@
|
||||||
|
/* Copyright (C) 2015 Andrew J. Kroll
|
||||||
|
and
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
#if !defined(__CDC_XR21B1411_H__)
|
||||||
|
#define __CDC_XR21B1411_H__
|
||||||
|
|
||||||
|
#include "cdcacm.h"
|
||||||
|
|
||||||
|
#define XR_REG_CUSTOM_DRIVER (0x020DU) // DRIVER SELECT
|
||||||
|
#define XR_REG_CUSTOM_DRIVER_ACTIVE (0x0001U) // 0: CDC 1: CUSTOM
|
||||||
|
|
||||||
|
#define XR_REG_ACM_FLOW_CTL (0x0216U) // FLOW CONTROL REGISTER CDCACM MODE
|
||||||
|
#define XR_REG_FLOW_CTL (0x0C06U) // FLOW CONTROL REGISTER CUSTOM MODE
|
||||||
|
#define XR_REG_FLOW_CTL_HALF_DPLX (0x0008U) // 0:FULL DUPLEX 1:HALF DUPLEX
|
||||||
|
#define XR_REG_FLOW_CTL_MODE_MASK (0x0007U) // MODE BITMASK
|
||||||
|
#define XR_REG_FLOW_CTL_NONE (0x0000U) // NO FLOW CONTROL
|
||||||
|
#define XR_REG_FLOW_CTL_HW (0x0001U) // HARDWARE FLOW CONTROL
|
||||||
|
#define XR_REG_FLOW_CTL_SW (0x0002U) // SOFTWARE FLOW CONTROL
|
||||||
|
#define XR_REG_FLOW_CTL_MMMRX (0x0003U) // MULTIDROP RX UPON ADDRESS MATCH
|
||||||
|
#define XR_REG_FLOW_CTL_MMMRXTX (0x0004U) // MULTIDROP RX/TX UPON ADDRESS MATCH
|
||||||
|
|
||||||
|
#define XR_REG_ACM_GPIO_MODE (0x0217U) // GPIO MODE REGISTER IN CDCACM MODE
|
||||||
|
#define XR_REG_GPIO_MODE (0x0C0CU) // GPIO MODE REGISTER IN CUSTOM MODE
|
||||||
|
#define XR_REG_GPIO_MODE_GPIO (0x0000U) // ALL GPIO PINS ACM PROGRAMMABLE
|
||||||
|
#define XR_REG_GPIO_MODE_FC_RTSCTS (0x0001U) // AUTO RTSCTS HW FC (GPIO 4/5)
|
||||||
|
#define XR_REG_GPIO_MODE_FC_DTRDSR (0x0002U) // AUTO DTRDSR HW FC (GPIO 2/3)
|
||||||
|
#define XR_REG_GPIO_MODE_ATE (0x0003U) // AUTO TRANSCEIVER ENABLE DURING TX (GPIO 5)
|
||||||
|
#define XR_REG_GPIO_MODE_ATE_ADDRESS (0x0004U) // AUTO TRANSCEIVER ENABLE ON ADDRESS MATCH (GPIO 5)
|
||||||
|
|
||||||
|
#define XR_REG_ACM_GPIO_DIR (0x0218U) // GPIO DIRECTION REGISTER CDCACM MODE, 0:IN 1:OUT
|
||||||
|
#define XR_REG_GPIO_DIR (0x0C0DU) // GPIO DIRECTION REGISTER CUSTOM MODE, 0:IN 1:OUT
|
||||||
|
|
||||||
|
#define XR_REG_ACM_GPIO_INT (0x0219U) // GPIO PIN CHANGE INTERRUPT ENABLE CDCACM MODE, 0: ENABLED 1: DISABLED
|
||||||
|
#define XR_REG_GPIO_INT (0x0C11U) // GPIO PIN CHANGE INTERRUPT ENABLE CUSTOM MODE, 0: ENABLED 1: DISABLED
|
||||||
|
#define XR_REG_GPIO_MASK (0x001FU) // GPIO REGISTERS BITMASK
|
||||||
|
|
||||||
|
#define XR_REG_UART_ENABLE (0x0C00U) // UART I/O ENABLE REGISTER
|
||||||
|
#define XR_REG_UART_ENABLE_RX (0x0002U) // 0:DISABLED 1:ENABLED
|
||||||
|
#define XR_REG_UART_ENABLE_TX (0x0001U) // 0:DISABLED 1:ENABLED
|
||||||
|
|
||||||
|
#define XR_REG_ERROR_STATUS (0x0C09U) // ERROR STATUS REGISTER
|
||||||
|
#define XR_REG_ERROR_STATUS_MASK (0x00F8U) // ERROR STATUS BITMASK
|
||||||
|
#define XR_REG_ERROR_STATUS_ERROR (0x0070U) // ERROR STATUS ERROR BITMASK
|
||||||
|
#define XR_REG_ERROR_STATUS_BREAK (0x0008U) // BREAK HAS BEEN DETECTED
|
||||||
|
#define XR_REG_ERROR_STATUS_OVERRUN (0x0010U) // RX OVERRUN ERROR
|
||||||
|
#define XR_REG_ERROR_STATUS_PARITY (0x0020U) // PARITY ERROR
|
||||||
|
#define XR_REG_ERROR_STATUS_FRAME (0x0040U) // FRAMING ERROR
|
||||||
|
#define XR_REG_ERROR_STATUS_BREAK (0x0080U) // BREAK IS BEING DETECTED
|
||||||
|
|
||||||
|
#define XR_REG_TX_BREAK (0x0C0AU) // TRANSMIT BREAK. 0X0001-0XFFE TIME IN MS, 0X0000 STOP, 0X0FFF BREAK ON
|
||||||
|
|
||||||
|
#define XR_REG_XCVR_EN_DELAY (0x0C0BU) // TURN-ARROUND DELAY IN BIT-TIMES 0X0000-0X000F
|
||||||
|
|
||||||
|
#define XR_REG_GPIO_SET (0x0C0EU) // 1:SET GPIO PIN
|
||||||
|
|
||||||
|
#define XR_REG_GPIO_CLR (0x0C0FU) // 1:CLEAR GPIO PIN
|
||||||
|
|
||||||
|
#define XR_REG_GPIO_STATUS (0x0C10U) // READ GPIO PINS
|
||||||
|
|
||||||
|
#define XR_REG_CUSTOMISED_INT (0x0C12U) // 0:STANDARD 1:CUSTOM SEE DATA SHEET
|
||||||
|
|
||||||
|
#define XR_REG_PIN_PULLUP_ENABLE (0x0C14U) // 0:DISABLE 1:ENABLE, BITS 0-5:GPIO, 6:RX 7:TX
|
||||||
|
|
||||||
|
#define XR_REG_PIN_PULLDOWN_ENABLE (0x0C15U) // 0:DISABLE 1:ENABLE, BITS 0-5:GPIO, 6:RX 7:TX
|
||||||
|
|
||||||
|
#define XR_REG_LOOPBACK (0x0C16U) // 0:DISABLE 1:ENABLE, SEE DATA SHEET
|
||||||
|
|
||||||
|
#define XR_REG_RX_FIFO_LATENCY (0x0CC2U) // FIFO LATENCY REGISTER
|
||||||
|
#define XR_REG_RX_FIFO_LATENCY_ENABLE (0x0001U) //
|
||||||
|
|
||||||
|
#define XR_REG_WIDE_MODE (0x0D02U)
|
||||||
|
#define XR_REG_WIDE_MODE_ENABLE (0x0001U)
|
||||||
|
|
||||||
|
#define XR_REG_XON_CHAR (0x0C07U)
|
||||||
|
#define XR_REG_XOFF_CHAR (0x0C08U)
|
||||||
|
|
||||||
|
#define XR_REG_TX_FIFO_RESET (0x0C80U) // 1: RESET, SELF-CLEARING
|
||||||
|
#define XR_REG_TX_FIFO_COUNT (0x0C81U) // READ-ONLY
|
||||||
|
#define XR_REG_RX_FIFO_RESET (0x0CC0U) // 1: RESET, SELF-CLEARING
|
||||||
|
#define XR_REG_RX_FIFO_COUNT (0x0CC1U) // READ-ONLY
|
||||||
|
|
||||||
|
#define XR_WRITE_REQUEST_TYPE (0x40U)
|
||||||
|
|
||||||
|
#define XR_READ_REQUEST_TYPE (0xC0U)
|
||||||
|
|
||||||
|
#define XR_MAX_ENDPOINTS 4
|
||||||
|
|
||||||
|
class XR21B1411 : public ACM {
|
||||||
|
protected:
|
||||||
|
|
||||||
|
public:
|
||||||
|
XR21B1411(USB *pusb, CDCAsyncOper *pasync);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by the USB core to check what this driver support.
|
||||||
|
* @param vid The device's VID.
|
||||||
|
* @param pid The device's PID.
|
||||||
|
* @return Returns true if the device's VID and PID matches this driver.
|
||||||
|
*/
|
||||||
|
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||||
|
return (((vid == 0x2890U) && (pid == 0x0201U)) || ((vid == 0x04e2U) && (pid == 0x1411U)));
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||||
|
|
||||||
|
virtual tty_features enhanced_features(void) {
|
||||||
|
tty_features rv;
|
||||||
|
rv.enhanced = true;
|
||||||
|
rv.autoflow_RTS = true;
|
||||||
|
rv.autoflow_DSR = true;
|
||||||
|
rv.autoflow_XON = true;
|
||||||
|
rv.half_duplex = true;
|
||||||
|
rv.wide = true;
|
||||||
|
return rv;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t read_register(uint16_t reg, uint16_t *val) {
|
||||||
|
return (pUsb->ctrlReq(bAddress, 0, XR_READ_REQUEST_TYPE, 1, 0, 0, reg, 2, 2, (uint8_t *)val, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t write_register(uint16_t reg, uint16_t val) {
|
||||||
|
return (pUsb->ctrlReq(bAddress, 0, XR_WRITE_REQUEST_TYPE, 0, BGRAB0(val), BGRAB1(val), reg, 0, 0, NULL, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// The following methods set the CDC-ACM defaults.
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
virtual void autoflowRTS(bool s) {
|
||||||
|
uint16_t val;
|
||||||
|
uint8_t rval;
|
||||||
|
rval = read_register(XR_REG_ACM_FLOW_CTL, &val);
|
||||||
|
if(!rval) {
|
||||||
|
if(s) {
|
||||||
|
val &= XR_REG_FLOW_CTL_HALF_DPLX;
|
||||||
|
val |= XR_REG_FLOW_CTL_HW;
|
||||||
|
} else {
|
||||||
|
val &= XR_REG_FLOW_CTL_HALF_DPLX;
|
||||||
|
}
|
||||||
|
rval = write_register(XR_REG_ACM_FLOW_CTL, val);
|
||||||
|
if(!rval) {
|
||||||
|
rval = write_register(XR_REG_ACM_GPIO_MODE, XR_REG_GPIO_MODE_GPIO);
|
||||||
|
if(!rval) {
|
||||||
|
// ACM commands apply the new settings.
|
||||||
|
LINE_CODING LCT;
|
||||||
|
rval = GetLineCoding(&LCT);
|
||||||
|
if(!rval) {
|
||||||
|
rval = SetLineCoding(&LCT);
|
||||||
|
if(!rval) {
|
||||||
|
_enhanced_status.autoflow_XON = false;
|
||||||
|
_enhanced_status.autoflow_DSR = false;
|
||||||
|
_enhanced_status.autoflow_RTS = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void autoflowDSR(bool s) {
|
||||||
|
uint16_t val;
|
||||||
|
uint8_t rval;
|
||||||
|
rval = read_register(XR_REG_ACM_FLOW_CTL, &val);
|
||||||
|
if(!rval) {
|
||||||
|
if(s) {
|
||||||
|
val &= XR_REG_FLOW_CTL_HALF_DPLX;
|
||||||
|
val |= XR_REG_FLOW_CTL_HW;
|
||||||
|
} else {
|
||||||
|
val &= XR_REG_FLOW_CTL_HALF_DPLX;
|
||||||
|
}
|
||||||
|
rval = write_register(XR_REG_ACM_FLOW_CTL, val);
|
||||||
|
if(!rval) {
|
||||||
|
if(s) {
|
||||||
|
rval = write_register(XR_REG_ACM_GPIO_MODE, XR_REG_GPIO_MODE_FC_DTRDSR);
|
||||||
|
} else {
|
||||||
|
rval = write_register(XR_REG_ACM_GPIO_MODE, XR_REG_GPIO_MODE_GPIO);
|
||||||
|
}
|
||||||
|
if(!rval) {
|
||||||
|
// ACM commands apply the new settings.
|
||||||
|
LINE_CODING LCT;
|
||||||
|
rval = GetLineCoding(&LCT);
|
||||||
|
if(!rval) {
|
||||||
|
rval = SetLineCoding(&LCT);
|
||||||
|
if(!rval) {
|
||||||
|
_enhanced_status.autoflow_XON = false;
|
||||||
|
_enhanced_status.autoflow_RTS = false;
|
||||||
|
_enhanced_status.autoflow_DSR = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void autoflowXON(bool s) {
|
||||||
|
// NOTE: hardware defaults to the normal XON/XOFF
|
||||||
|
uint16_t val;
|
||||||
|
uint8_t rval;
|
||||||
|
rval = read_register(XR_REG_ACM_FLOW_CTL, &val);
|
||||||
|
if(!rval) {
|
||||||
|
if(s) {
|
||||||
|
val &= XR_REG_FLOW_CTL_HALF_DPLX;
|
||||||
|
val |= XR_REG_FLOW_CTL_SW;
|
||||||
|
} else {
|
||||||
|
val &= XR_REG_FLOW_CTL_HALF_DPLX;
|
||||||
|
}
|
||||||
|
rval = write_register(XR_REG_ACM_FLOW_CTL, val);
|
||||||
|
if(!rval) {
|
||||||
|
rval = write_register(XR_REG_ACM_GPIO_MODE, XR_REG_GPIO_MODE_GPIO);
|
||||||
|
if(!rval) {
|
||||||
|
// ACM commands apply the new settings.
|
||||||
|
LINE_CODING LCT;
|
||||||
|
rval = GetLineCoding(&LCT);
|
||||||
|
if(!rval) {
|
||||||
|
rval = SetLineCoding(&LCT);
|
||||||
|
if(!rval) {
|
||||||
|
_enhanced_status.autoflow_RTS = false;
|
||||||
|
_enhanced_status.autoflow_DSR = false;
|
||||||
|
_enhanced_status.autoflow_XON = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void half_duplex(bool s) {
|
||||||
|
uint16_t val;
|
||||||
|
uint8_t rval;
|
||||||
|
rval = read_register(XR_REG_ACM_FLOW_CTL, &val);
|
||||||
|
if(!rval) {
|
||||||
|
if(s) {
|
||||||
|
val |= XR_REG_FLOW_CTL_HALF_DPLX;
|
||||||
|
} else {
|
||||||
|
val &= XR_REG_FLOW_CTL_MODE_MASK;
|
||||||
|
}
|
||||||
|
rval = write_register(XR_REG_ACM_FLOW_CTL, val);
|
||||||
|
if(!rval) {
|
||||||
|
// ACM commands apply the new settings.
|
||||||
|
LINE_CODING LCT;
|
||||||
|
rval = GetLineCoding(&LCT);
|
||||||
|
if(!rval) {
|
||||||
|
rval = SetLineCoding(&LCT);
|
||||||
|
if(!rval) {
|
||||||
|
_enhanced_status.half_duplex = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __CDCPROLIFIC_H__
|
60
cdcacm.cpp
60
cdcacm.cpp
|
@ -30,21 +30,20 @@ bNumEP(1),
|
||||||
qNextPollTime(0),
|
qNextPollTime(0),
|
||||||
bPollEnable(false),
|
bPollEnable(false),
|
||||||
ready(false) {
|
ready(false) {
|
||||||
|
_enhanced_status = enhanced_features(); // Set up features
|
||||||
for(uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) {
|
for(uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) {
|
||||||
epInfo[i].epAddr = 0;
|
epInfo[i].epAddr = 0;
|
||||||
epInfo[i].maxPktSize = (i) ? 0 : 8;
|
epInfo[i].maxPktSize = (i) ? 0 : 8;
|
||||||
epInfo[i].epAttribs = 0;
|
epInfo[i].epAttribs = 0;
|
||||||
//epInfo[i].bmNakPower = USB_NAK_NOWAIT;
|
epInfo[i].bmNakPower = (i == epDataInIndex) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER;
|
||||||
epInfo[i].bmNakPower = USB_NAK_MAX_POWER;
|
|
||||||
|
|
||||||
//if (!i)
|
|
||||||
epInfo[i].bmNakPower = USB_NAK_MAX_POWER;
|
|
||||||
}
|
}
|
||||||
if(pUsb)
|
if(pUsb)
|
||||||
pUsb->RegisterDeviceClass(this);
|
pUsb->RegisterDeviceClass(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
|
||||||
|
|
||||||
uint8_t buf[constBufSize];
|
uint8_t buf[constBufSize];
|
||||||
|
@ -170,6 +169,13 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if(rcode)
|
if(rcode)
|
||||||
goto FailSetConfDescr;
|
goto FailSetConfDescr;
|
||||||
|
|
||||||
|
// Set up features status
|
||||||
|
_enhanced_status = enhanced_features();
|
||||||
|
half_duplex(false);
|
||||||
|
autoflowRTS(false);
|
||||||
|
autoflowDSR(false);
|
||||||
|
autoflowXON(false);
|
||||||
|
wide(false); // Always false, because this is only available in custom mode.
|
||||||
rcode = pAsync->OnInit(this);
|
rcode = pAsync->OnInit(this);
|
||||||
|
|
||||||
if(rcode)
|
if(rcode)
|
||||||
|
@ -222,9 +228,9 @@ Fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACM::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) {
|
void ACM::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) {
|
||||||
ErrorMessage<uint8_t > (PSTR("Conf.Val"), conf);
|
//ErrorMessage<uint8_t > (PSTR("Conf.Val"), conf);
|
||||||
ErrorMessage<uint8_t > (PSTR("Iface Num"), iface);
|
//ErrorMessage<uint8_t > (PSTR("Iface Num"), iface);
|
||||||
ErrorMessage<uint8_t > (PSTR("Alt.Set"), alt);
|
//ErrorMessage<uint8_t > (PSTR("Alt.Set"), alt);
|
||||||
|
|
||||||
bConfNum = conf;
|
bConfNum = conf;
|
||||||
|
|
||||||
|
@ -249,6 +255,7 @@ void ACM::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ACM::Release() {
|
uint8_t ACM::Release() {
|
||||||
|
ready = false;
|
||||||
pUsb->GetAddressPool().FreeAddress(bAddress);
|
pUsb->GetAddressPool().FreeAddress(bAddress);
|
||||||
|
|
||||||
bControlIface = 0;
|
bControlIface = 0;
|
||||||
|
@ -267,33 +274,6 @@ uint8_t ACM::Poll() {
|
||||||
if(!bPollEnable)
|
if(!bPollEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//uint32_t time_now = millis();
|
|
||||||
|
|
||||||
//if (qNextPollTime <= time_now)
|
|
||||||
//{
|
|
||||||
// qNextPollTime = time_now + 100;
|
|
||||||
|
|
||||||
// uint8_t rcode;
|
|
||||||
// const uint8_t constBufSize = 16;
|
|
||||||
// uint8_t buf[constBufSize];
|
|
||||||
|
|
||||||
// for (uint8_t i=0; i<constBufSize; i++)
|
|
||||||
// buf[i] = 0;
|
|
||||||
|
|
||||||
// uint16_t read = (constBufSize > epInfo[epInterruptInIndex].maxPktSize)
|
|
||||||
// ? epInfo[epInterruptInIndex].maxPktSize : constBufSize;
|
|
||||||
// rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex].epAddr, &read, buf);
|
|
||||||
|
|
||||||
// if (rcode)
|
|
||||||
// return rcode;
|
|
||||||
|
|
||||||
// for (uint8_t i=0; i<read; i++)
|
|
||||||
// {
|
|
||||||
// PrintHex<uint8_t>(buf[i]);
|
|
||||||
// USB_HOST_SERIAL.print(" ");
|
|
||||||
// }
|
|
||||||
// USBTRACE("\r\n");
|
|
||||||
//}
|
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,16 +316,16 @@ uint8_t ACM::SendBreak(uint16_t duration) {
|
||||||
void ACM::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
void ACM::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
148
cdcacm.h
148
cdcacm.h
|
@ -23,53 +23,53 @@ e-mail : support@circuitsathome.com
|
||||||
#define bmREQ_CDCIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
#define bmREQ_CDCIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||||
|
|
||||||
// CDC Subclass Constants
|
// CDC Subclass Constants
|
||||||
#define CDC_SUBCLASS_DLCM 0x01 // Direct Line Control Model
|
#define CDC_SUBCLASS_DLCM 0x01 // Direct Line Control Model
|
||||||
#define CDC_SUBCLASS_ACM 0x02 // Abstract Control Model
|
#define CDC_SUBCLASS_ACM 0x02 // Abstract Control Model
|
||||||
#define CDC_SUBCLASS_TCM 0x03 // Telephone Control Model
|
#define CDC_SUBCLASS_TCM 0x03 // Telephone Control Model
|
||||||
#define CDC_SUBCLASS_MCCM 0x04 // Multi Channel Control Model
|
#define CDC_SUBCLASS_MCCM 0x04 // Multi Channel Control Model
|
||||||
#define CDC_SUBCLASS_CAPI 0x05 // CAPI Control Model
|
#define CDC_SUBCLASS_CAPI 0x05 // CAPI Control Model
|
||||||
#define CDC_SUBCLASS_ETHERNET 0x06 // Ethernet Network Control Model
|
#define CDC_SUBCLASS_ETHERNET 0x06 // Ethernet Network Control Model
|
||||||
#define CDC_SUBCLASS_ATM 0x07 // ATM Network Control Model
|
#define CDC_SUBCLASS_ATM 0x07 // ATM Network Control Model
|
||||||
#define CDC_SUBCLASS_WIRELESS_HANDSET 0x08 // Wireless Handset Control Model
|
#define CDC_SUBCLASS_WIRELESS_HANDSET 0x08 // Wireless Handset Control Model
|
||||||
#define CDC_SUBCLASS_DEVICE_MANAGEMENT 0x09 // Device Management
|
#define CDC_SUBCLASS_DEVICE_MANAGEMENT 0x09 // Device Management
|
||||||
#define CDC_SUBCLASS_MOBILE_DIRECT_LINE 0x0A // Mobile Direct Line Model
|
#define CDC_SUBCLASS_MOBILE_DIRECT_LINE 0x0A // Mobile Direct Line Model
|
||||||
#define CDC_SUBCLASS_OBEX 0x0B // OBEX
|
#define CDC_SUBCLASS_OBEX 0x0B // OBEX
|
||||||
#define CDC_SUBCLASS_ETHERNET_EMU 0x0C // Ethernet Emulation Model
|
#define CDC_SUBCLASS_ETHERNET_EMU 0x0C // Ethernet Emulation Model
|
||||||
|
|
||||||
// Communication Interface Class Control Protocol Codes
|
// Communication Interface Class Control Protocol Codes
|
||||||
#define CDC_PROTOCOL_ITU_T_V_250 0x01 // AT Commands defined by ITU-T V.250
|
#define CDC_PROTOCOL_ITU_T_V_250 0x01 // AT Commands defined by ITU-T V.250
|
||||||
#define CDC_PROTOCOL_PCCA_101 0x02 // AT Commands defined by PCCA-101
|
#define CDC_PROTOCOL_PCCA_101 0x02 // AT Commands defined by PCCA-101
|
||||||
#define CDC_PROTOCOL_PCCA_101_O 0x03 // AT Commands defined by PCCA-101 & Annex O
|
#define CDC_PROTOCOL_PCCA_101_O 0x03 // AT Commands defined by PCCA-101 & Annex O
|
||||||
#define CDC_PROTOCOL_GSM_7_07 0x04 // AT Commands defined by GSM 7.07
|
#define CDC_PROTOCOL_GSM_7_07 0x04 // AT Commands defined by GSM 7.07
|
||||||
#define CDC_PROTOCOL_3GPP_27_07 0x05 // AT Commands defined by 3GPP 27.007
|
#define CDC_PROTOCOL_3GPP_27_07 0x05 // AT Commands defined by 3GPP 27.007
|
||||||
#define CDC_PROTOCOL_C_S0017_0 0x06 // AT Commands defined by TIA for CDMA
|
#define CDC_PROTOCOL_C_S0017_0 0x06 // AT Commands defined by TIA for CDMA
|
||||||
#define CDC_PROTOCOL_USB_EEM 0x07 // Ethernet Emulation Model
|
#define CDC_PROTOCOL_USB_EEM 0x07 // Ethernet Emulation Model
|
||||||
|
|
||||||
// CDC Commands defined by CDC 1.2
|
// CDC Commands defined by CDC 1.2
|
||||||
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
||||||
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
||||||
|
|
||||||
// CDC Commands defined by PSTN 1.2
|
// CDC Commands defined by PSTN 1.2
|
||||||
#define CDC_SET_COMM_FEATURE 0x02
|
#define CDC_SET_COMM_FEATURE 0x02
|
||||||
#define CDC_GET_COMM_FEATURE 0x03
|
#define CDC_GET_COMM_FEATURE 0x03
|
||||||
#define CDC_CLEAR_COMM_FEATURE 0x04
|
#define CDC_CLEAR_COMM_FEATURE 0x04
|
||||||
#define CDC_SET_AUX_LINE_STATE 0x10
|
#define CDC_SET_AUX_LINE_STATE 0x10
|
||||||
#define CDC_SET_HOOK_STATE 0x11
|
#define CDC_SET_HOOK_STATE 0x11
|
||||||
#define CDC_PULSE_SETUP 0x12
|
#define CDC_PULSE_SETUP 0x12
|
||||||
#define CDC_SEND_PULSE 0x13
|
#define CDC_SEND_PULSE 0x13
|
||||||
#define CDC_SET_PULSE_TIME 0x14
|
#define CDC_SET_PULSE_TIME 0x14
|
||||||
#define CDC_RING_AUX_JACK 0x15
|
#define CDC_RING_AUX_JACK 0x15
|
||||||
#define CDC_SET_LINE_CODING 0x20
|
#define CDC_SET_LINE_CODING 0x20
|
||||||
#define CDC_GET_LINE_CODING 0x21
|
#define CDC_GET_LINE_CODING 0x21
|
||||||
#define CDC_SET_CONTROL_LINE_STATE 0x22
|
#define CDC_SET_CONTROL_LINE_STATE 0x22
|
||||||
#define CDC_SEND_BREAK 0x23
|
#define CDC_SEND_BREAK 0x23
|
||||||
#define CDC_SET_RINGER_PARMS 0x30
|
#define CDC_SET_RINGER_PARMS 0x30
|
||||||
#define CDC_GET_RINGER_PARMS 0x31
|
#define CDC_GET_RINGER_PARMS 0x31
|
||||||
#define CDC_SET_OPERATION_PARMS 0x32
|
#define CDC_SET_OPERATION_PARMS 0x32
|
||||||
#define CDC_GET_OPERATION_PARMS 0x33
|
#define CDC_GET_OPERATION_PARMS 0x33
|
||||||
#define CDC_SET_LINE_PARMS 0x34
|
#define CDC_SET_LINE_PARMS 0x34
|
||||||
#define CDC_GET_LINE_PARMS 0x35
|
#define CDC_GET_LINE_PARMS 0x35
|
||||||
#define CDC_DIAL_DIGITS 0x36
|
#define CDC_DIAL_DIGITS 0x36
|
||||||
|
|
||||||
//Class-Specific Notification Codes
|
//Class-Specific Notification Codes
|
||||||
#define NETWORK_CONNECTION 0x00
|
#define NETWORK_CONNECTION 0x00
|
||||||
|
@ -129,13 +129,36 @@ class CDCAsyncOper {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual uint8_t OnInit(ACM *pacm) {
|
virtual uint8_t OnInit(ACM *pacm) {
|
||||||
|
return 0;
|
||||||
};
|
};
|
||||||
//virtual void OnDataRcvd(ACM *pacm, uint8_t nbytes, uint8_t *dataptr) = 0;
|
//virtual void OnDataRcvd(ACM *pacm, uint8_t nbytes, uint8_t *dataptr) = 0;
|
||||||
//virtual void OnDisconnected(ACM *pacm) = 0;
|
//virtual void OnDisconnected(ACM *pacm) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This structure is used to report the extended capabilities of the connected device.
|
||||||
|
* It is also used to report the current status.
|
||||||
|
* Regular CDC-ACM reports all as false.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
#define ACM_MAX_ENDPOINTS 4
|
union {
|
||||||
|
uint8_t tty;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
bool enhanced : 1; // Do we have the ability to set/clear any features?
|
||||||
|
// Status and 8th bit in data stream.
|
||||||
|
// Presence only indicates feature is available, but this isn't used for CDC-ACM.
|
||||||
|
bool wide : 1;
|
||||||
|
bool autoflow_RTS : 1; // Has autoflow on RTS/CTS
|
||||||
|
bool autoflow_DSR : 1; // Has autoflow on DTR/DSR
|
||||||
|
bool autoflow_XON : 1; // Has autoflow XON/XOFF
|
||||||
|
bool half_duplex : 1; // Has half-duplex capability.
|
||||||
|
} __attribute__((packed));
|
||||||
|
};
|
||||||
|
} tty_features;
|
||||||
|
|
||||||
|
#define ACM_MAX_ENDPOINTS 4
|
||||||
|
|
||||||
class ACM : public USBDeviceConfig, public UsbConfigXtracter {
|
class ACM : public USBDeviceConfig, public UsbConfigXtracter {
|
||||||
protected:
|
protected:
|
||||||
|
@ -151,8 +174,9 @@ protected:
|
||||||
uint8_t bDataIface; // Data interface value
|
uint8_t bDataIface; // Data interface value
|
||||||
uint8_t bNumEP; // total number of EP in the configuration
|
uint8_t bNumEP; // total number of EP in the configuration
|
||||||
uint32_t qNextPollTime; // next poll time
|
uint32_t qNextPollTime; // next poll time
|
||||||
bool bPollEnable; // poll enable flag
|
volatile bool bPollEnable; // poll enable flag
|
||||||
bool ready; //device ready indicator
|
volatile bool ready; //device ready indicator
|
||||||
|
tty_features _enhanced_status; // current status
|
||||||
|
|
||||||
EpInfo epInfo[ACM_MAX_ENDPOINTS];
|
EpInfo epInfo[ACM_MAX_ENDPOINTS];
|
||||||
|
|
||||||
|
@ -170,7 +194,7 @@ public:
|
||||||
uint8_t SendBreak(uint16_t duration);
|
uint8_t SendBreak(uint16_t duration);
|
||||||
uint8_t GetNotif(uint16_t *bytes_rcvd, uint8_t *dataptr);
|
uint8_t GetNotif(uint16_t *bytes_rcvd, uint8_t *dataptr);
|
||||||
|
|
||||||
// Methods for recieving and sending data
|
// Methods for receiving and sending data
|
||||||
uint8_t RcvData(uint16_t *nbytesptr, uint8_t *dataptr);
|
uint8_t RcvData(uint16_t *nbytesptr, uint8_t *dataptr);
|
||||||
uint8_t SndData(uint16_t nbytes, uint8_t *dataptr);
|
uint8_t SndData(uint16_t nbytes, uint8_t *dataptr);
|
||||||
|
|
||||||
|
@ -179,6 +203,10 @@ public:
|
||||||
uint8_t Release();
|
uint8_t Release();
|
||||||
uint8_t Poll();
|
uint8_t Poll();
|
||||||
|
|
||||||
|
bool available(void) {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
virtual uint8_t GetAddress() {
|
virtual uint8_t GetAddress() {
|
||||||
return bAddress;
|
return bAddress;
|
||||||
};
|
};
|
||||||
|
@ -187,6 +215,36 @@ public:
|
||||||
return ready;
|
return ready;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual tty_features enhanced_status(void) {
|
||||||
|
return _enhanced_status;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual tty_features enhanced_features(void) {
|
||||||
|
tty_features rv;
|
||||||
|
rv.enhanced = false;
|
||||||
|
rv.autoflow_RTS = false;
|
||||||
|
rv.autoflow_DSR = false;
|
||||||
|
rv.autoflow_XON = false;
|
||||||
|
rv.half_duplex = false;
|
||||||
|
rv.wide = false;
|
||||||
|
return rv;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void autoflowRTS(bool s) {
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void autoflowDSR(bool s) {
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void autoflowXON(bool s) {
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void half_duplex(bool s) {
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void wide(bool s) {
|
||||||
|
};
|
||||||
|
|
||||||
// UsbConfigXtracter implementation
|
// UsbConfigXtracter implementation
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
|
25
cdcftdi.cpp
25
cdcftdi.cpp
|
@ -30,9 +30,7 @@ wFTDIType(0) {
|
||||||
epInfo[i].epAddr = 0;
|
epInfo[i].epAddr = 0;
|
||||||
epInfo[i].maxPktSize = (i) ? 0 : 8;
|
epInfo[i].maxPktSize = (i) ? 0 : 8;
|
||||||
epInfo[i].epAttribs = 0;
|
epInfo[i].epAttribs = 0;
|
||||||
|
epInfo[i].bmNakPower = (i==epDataInIndex) ? USB_NAK_NOWAIT: USB_NAK_MAX_POWER;
|
||||||
//if (!i)
|
|
||||||
epInfo[i].bmNakPower = USB_NAK_MAX_POWER;
|
|
||||||
}
|
}
|
||||||
if(pUsb)
|
if(pUsb)
|
||||||
pUsb->RegisterDeviceClass(this);
|
pUsb->RegisterDeviceClass(this);
|
||||||
|
@ -46,11 +44,8 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
//uint8_t len = 0;
|
|
||||||
//uint16_t cd_len = 0;
|
|
||||||
|
|
||||||
uint8_t num_of_conf; // number of configurations
|
uint8_t num_of_conf; // number of configurations
|
||||||
//uint8_t num_of_intf; // number of interfaces
|
|
||||||
|
|
||||||
AddressPool &addrPool = pUsb->GetAddressPool();
|
AddressPool &addrPool = pUsb->GetAddressPool();
|
||||||
|
|
||||||
|
@ -253,13 +248,13 @@ uint8_t FTDI::Poll() {
|
||||||
uint8_t rcode = 0;
|
uint8_t rcode = 0;
|
||||||
|
|
||||||
//if (!bPollEnable)
|
//if (!bPollEnable)
|
||||||
// return 0;
|
// return 0;
|
||||||
|
|
||||||
//if (qNextPollTime <= millis())
|
//if (qNextPollTime <= millis())
|
||||||
//{
|
//{
|
||||||
// USB_HOST_SERIAL.println(bAddress, HEX);
|
// USB_HOST_SERIAL.println(bAddress, HEX);
|
||||||
|
|
||||||
// qNextPollTime = millis() + 100;
|
// qNextPollTime = millis() + 100;
|
||||||
//}
|
//}
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
@ -324,16 +319,16 @@ uint8_t FTDI::SndData(uint16_t nbytes, uint8_t *dataptr) {
|
||||||
void FTDI::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
void FTDI::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
Notify(PSTR("Endpoint descriptor:"), 0x80);
|
||||||
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
Notify(PSTR("\r\nLength:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
|
||||||
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
Notify(PSTR("\r\nType:\t\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
|
||||||
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
Notify(PSTR("\r\nAddress:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
|
||||||
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
Notify(PSTR("\r\nAttributes:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
|
||||||
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
|
||||||
PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
|
||||||
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
|
||||||
Notify(PSTR("\r\n"), 0x80);
|
Notify(PSTR("\r\n"), 0x80);
|
||||||
}
|
}
|
||||||
|
|
88
cdcftdi.h
88
cdcftdi.h
|
@ -22,57 +22,57 @@ e-mail : support@circuitsathome.com
|
||||||
#define bmREQ_FTDI_OUT 0x40
|
#define bmREQ_FTDI_OUT 0x40
|
||||||
#define bmREQ_FTDI_IN 0xc0
|
#define bmREQ_FTDI_IN 0xc0
|
||||||
|
|
||||||
//#define bmREQ_FTDI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
//#define bmREQ_FTDI_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||||
//#define bmREQ_FTDI_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
//#define bmREQ_FTDI_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||||
|
|
||||||
#define FTDI_VID 0x0403 // FTDI VID
|
#define FTDI_VID 0x0403 // FTDI VID
|
||||||
#define FTDI_PID 0x6001 // FTDI PID
|
#define FTDI_PID 0x6001 // FTDI PID
|
||||||
|
|
||||||
#define FT232AM 0x0200
|
#define FT232AM 0x0200
|
||||||
#define FT232BM 0x0400
|
#define FT232BM 0x0400
|
||||||
#define FT2232 0x0500
|
#define FT2232 0x0500
|
||||||
#define FT232R 0x0600
|
#define FT232R 0x0600
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
#define FTDI_SIO_RESET 0 /* Reset the port */
|
#define FTDI_SIO_RESET 0 /* Reset the port */
|
||||||
#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
|
#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
|
||||||
#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
|
#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
|
||||||
#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
|
#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
|
||||||
#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */
|
#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */
|
||||||
#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem status register */
|
#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem status register */
|
||||||
#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
|
#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
|
||||||
#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
|
#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
|
||||||
|
|
||||||
#define FTDI_SIO_RESET_SIO 0
|
#define FTDI_SIO_RESET_SIO 0
|
||||||
#define FTDI_SIO_RESET_PURGE_RX 1
|
#define FTDI_SIO_RESET_PURGE_RX 1
|
||||||
#define FTDI_SIO_RESET_PURGE_TX 2
|
#define FTDI_SIO_RESET_PURGE_TX 2
|
||||||
|
|
||||||
#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8 )
|
#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8 )
|
||||||
#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8 )
|
#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8 )
|
||||||
#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8 )
|
#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8 )
|
||||||
#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8 )
|
#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8 )
|
||||||
#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8 )
|
#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8 )
|
||||||
#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
|
#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
|
||||||
#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
|
#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
|
||||||
#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
|
#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
|
||||||
#define FTDI_SIO_SET_BREAK (0x1 << 14)
|
#define FTDI_SIO_SET_BREAK (0x1 << 14)
|
||||||
|
|
||||||
#define FTDI_SIO_SET_DTR_MASK 0x1
|
#define FTDI_SIO_SET_DTR_MASK 0x1
|
||||||
#define FTDI_SIO_SET_DTR_HIGH ( 1 | ( FTDI_SIO_SET_DTR_MASK << 8))
|
#define FTDI_SIO_SET_DTR_HIGH ( 1 | ( FTDI_SIO_SET_DTR_MASK << 8))
|
||||||
#define FTDI_SIO_SET_DTR_LOW ( 0 | ( FTDI_SIO_SET_DTR_MASK << 8))
|
#define FTDI_SIO_SET_DTR_LOW ( 0 | ( FTDI_SIO_SET_DTR_MASK << 8))
|
||||||
#define FTDI_SIO_SET_RTS_MASK 0x2
|
#define FTDI_SIO_SET_RTS_MASK 0x2
|
||||||
#define FTDI_SIO_SET_RTS_HIGH ( 2 | ( FTDI_SIO_SET_RTS_MASK << 8 ))
|
#define FTDI_SIO_SET_RTS_HIGH ( 2 | ( FTDI_SIO_SET_RTS_MASK << 8 ))
|
||||||
#define FTDI_SIO_SET_RTS_LOW ( 0 | ( FTDI_SIO_SET_RTS_MASK << 8 ))
|
#define FTDI_SIO_SET_RTS_LOW ( 0 | ( FTDI_SIO_SET_RTS_MASK << 8 ))
|
||||||
|
|
||||||
#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
|
#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
|
||||||
#define FTDI_SIO_RTS_CTS_HS (0x1 << 8)
|
#define FTDI_SIO_RTS_CTS_HS (0x1 << 8)
|
||||||
#define FTDI_SIO_DTR_DSR_HS (0x2 << 8)
|
#define FTDI_SIO_DTR_DSR_HS (0x2 << 8)
|
||||||
#define FTDI_SIO_XON_XOFF_HS (0x4 << 8)
|
#define FTDI_SIO_XON_XOFF_HS (0x4 << 8)
|
||||||
|
|
||||||
#define FTDI_SIO_CTS_MASK 0x10
|
#define FTDI_SIO_CTS_MASK 0x10
|
||||||
#define FTDI_SIO_DSR_MASK 0x20
|
#define FTDI_SIO_DSR_MASK 0x20
|
||||||
#define FTDI_SIO_RI_MASK 0x40
|
#define FTDI_SIO_RI_MASK 0x40
|
||||||
#define FTDI_SIO_RLSD_MASK 0x80
|
#define FTDI_SIO_RLSD_MASK 0x80
|
||||||
|
|
||||||
class FTDI;
|
class FTDI;
|
||||||
|
|
||||||
|
@ -88,8 +88,8 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// Only single port chips are currently supported by the library,
|
// Only single port chips are currently supported by the library,
|
||||||
// so only three endpoints are allocated.
|
// so only three endpoints are allocated.
|
||||||
#define FTDI_MAX_ENDPOINTS 3
|
#define FTDI_MAX_ENDPOINTS 3
|
||||||
|
|
||||||
class FTDI : public USBDeviceConfig, public UsbConfigXtracter {
|
class FTDI : public USBDeviceConfig, public UsbConfigXtracter {
|
||||||
static const uint8_t epDataInIndex; // DataIn endpoint index
|
static const uint8_t epDataInIndex; // DataIn endpoint index
|
||||||
|
|
|
@ -195,16 +195,16 @@ Fail:
|
||||||
|
|
||||||
//uint8_t PL::Poll()
|
//uint8_t PL::Poll()
|
||||||
//{
|
//{
|
||||||
// uint8_t rcode = 0;
|
// uint8_t rcode = 0;
|
||||||
//
|
//
|
||||||
// //if (!bPollEnable)
|
// //if (!bPollEnable)
|
||||||
// // return 0;
|
// // return 0;
|
||||||
//
|
//
|
||||||
// //if (qNextPollTime <= millis())
|
// //if (qNextPollTime <= millis())
|
||||||
// //{
|
// //{
|
||||||
// // USB_HOST_SERIAL.println(bAddress, HEX);
|
// // USB_HOST_SERIAL.println(bAddress, HEX);
|
||||||
//
|
//
|
||||||
// // qNextPollTime = millis() + 100;
|
// // qNextPollTime = millis() + 100;
|
||||||
// //}
|
// //}
|
||||||
// return rcode;
|
// return rcode;
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -45,8 +45,8 @@ e-mail : support@circuitsathome.com
|
||||||
#define DEFAULT_NOTIFY 0x00
|
#define DEFAULT_NOTIFY 0x00
|
||||||
#define DEFAULT_STATE ( PD_S_TX_ENABLE | PD_S_RX_ENABLE | PD_RS232_A_TXO | PD_RS232_A_RXO )
|
#define DEFAULT_STATE ( PD_S_TX_ENABLE | PD_S_RX_ENABLE | PD_RS232_A_TXO | PD_RS232_A_RXO )
|
||||||
|
|
||||||
#define CONTINUE_SEND 1
|
#define CONTINUE_SEND 1
|
||||||
#define PAUSE_SEND 2
|
#define PAUSE_SEND 2
|
||||||
|
|
||||||
#define kRxAutoFlow ((UInt32)( PD_RS232_A_RFR | PD_RS232_A_DTR | PD_RS232_A_RXO ))
|
#define kRxAutoFlow ((UInt32)( PD_RS232_A_RFR | PD_RS232_A_DTR | PD_RS232_A_RXO ))
|
||||||
#define kTxAutoFlow ((UInt32)( PD_RS232_A_CTS | PD_RS232_A_DSR | PD_RS232_A_TXO | PD_RS232_A_DCD ))
|
#define kTxAutoFlow ((UInt32)( PD_RS232_A_CTS | PD_RS232_A_DSR | PD_RS232_A_TXO | PD_RS232_A_DCD ))
|
||||||
|
|
|
@ -29,10 +29,10 @@ public:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CP_MASK_COMPARE_CLASS 1
|
#define CP_MASK_COMPARE_CLASS 1
|
||||||
#define CP_MASK_COMPARE_SUBCLASS 2
|
#define CP_MASK_COMPARE_SUBCLASS 2
|
||||||
#define CP_MASK_COMPARE_PROTOCOL 4
|
#define CP_MASK_COMPARE_PROTOCOL 4
|
||||||
#define CP_MASK_COMPARE_ALL 7
|
#define CP_MASK_COMPARE_ALL 7
|
||||||
|
|
||||||
// Configuration Descriptor Parser Class Template
|
// Configuration Descriptor Parser Class Template
|
||||||
|
|
||||||
|
@ -109,10 +109,10 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
||||||
stateParseDescr = 2;
|
stateParseDescr = 2;
|
||||||
case 2:
|
case 2:
|
||||||
// This is a sort of hack. Assuming that two bytes are all ready in the buffer
|
// This is a sort of hack. Assuming that two bytes are all ready in the buffer
|
||||||
// the pointer is positioned two bytes ahead in order for the rest of descriptor
|
// the pointer is positioned two bytes ahead in order for the rest of descriptor
|
||||||
// to be read right after the size and the type fields.
|
// to be read right after the size and the type fields.
|
||||||
// This should be used carefully. varBuffer should be used directly to handle data
|
// This should be used carefully. varBuffer should be used directly to handle data
|
||||||
// in the buffer.
|
// in the buffer.
|
||||||
theBuffer.pValue = varBuffer + 2;
|
theBuffer.pValue = varBuffer + 2;
|
||||||
stateParseDescr = 3;
|
stateParseDescr = 3;
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -165,10 +165,10 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
|
||||||
theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer);
|
theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer);
|
||||||
break;
|
break;
|
||||||
//case HID_DESCRIPTOR_HID:
|
//case HID_DESCRIPTOR_HID:
|
||||||
// if (!valParser.Parse(pp, pcntdn))
|
// if (!valParser.Parse(pp, pcntdn))
|
||||||
// return false;
|
// return false;
|
||||||
// PrintHidDescriptor((const USB_HID_DESCRIPTOR*)varBuffer);
|
// PrintHidDescriptor((const USB_HID_DESCRIPTOR*)varBuffer);
|
||||||
// break;
|
// break;
|
||||||
default:
|
default:
|
||||||
if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2))
|
if(!theSkipper.Skip(pp, pcntdn, dscrLen - 2))
|
||||||
return false;
|
return false;
|
||||||
|
@ -197,12 +197,6 @@ void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescrip
|
||||||
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
|
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
|
||||||
PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
|
PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
|
||||||
|
|
||||||
//Notify(PSTR("\r\nbDescrType:\t\t"));
|
|
||||||
//PrintHex<uint8_t>(pDesc->bDescrType);
|
|
||||||
//
|
|
||||||
//Notify(PSTR("\r\nwDescriptorLength:\t"));
|
|
||||||
//PrintHex<uint16_t>(pDesc->wDescriptorLength);
|
|
||||||
|
|
||||||
for(uint8_t i = 0; i < pDesc->bNumDescriptors; i++) {
|
for(uint8_t i = 0; i < pDesc->bNumDescriptors; i++) {
|
||||||
HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType);
|
HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType);
|
||||||
|
|
||||||
|
|
83
examples/cdc_XR21B1411/XR_terminal/__XR_terminal.ino
Normal file
83
examples/cdc_XR21B1411/XR_terminal/__XR_terminal.ino
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
#include <cdc_XR21B1411.h>
|
||||||
|
|
||||||
|
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||||
|
#ifdef dobogusinclude
|
||||||
|
#include <spi4teensy3.h>
|
||||||
|
#include <SPI.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class ACMAsyncOper : public CDCAsyncOper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint8_t OnInit(ACM *pacm);
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t ACMAsyncOper::OnInit(ACM *pacm)
|
||||||
|
{
|
||||||
|
uint8_t rcode;
|
||||||
|
// Set DTR = 1 RTS=1
|
||||||
|
rcode = pacm->SetControlLineState(3);
|
||||||
|
|
||||||
|
if (rcode)
|
||||||
|
{
|
||||||
|
ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
|
||||||
|
return rcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
LINE_CODING lc;
|
||||||
|
lc.dwDTERate = 115200;
|
||||||
|
lc.bCharFormat = 0;
|
||||||
|
lc.bParityType = 0;
|
||||||
|
lc.bDataBits = 8;
|
||||||
|
|
||||||
|
rcode = pacm->SetLineCoding(&lc);
|
||||||
|
|
||||||
|
if (rcode)
|
||||||
|
ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);
|
||||||
|
|
||||||
|
return rcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
USB Usb;
|
||||||
|
ACMAsyncOper AsyncOper;
|
||||||
|
XR21B1411 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("\r\n\r\nStart");
|
||||||
|
|
||||||
|
if (Usb.Init() == -1) Serial.println("OSCOKIRQ failed to assert");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Usb.Task();
|
||||||
|
if( Acm.isReady()) {
|
||||||
|
uint8_t rcode;
|
||||||
|
uint8_t buf[1];
|
||||||
|
uint16_t rcvd = 1;
|
||||||
|
|
||||||
|
/* read keyboard */
|
||||||
|
if(Serial.available()) {
|
||||||
|
uint8_t data = Serial.read();
|
||||||
|
/* send */
|
||||||
|
rcode = Acm.SndData(1, &data);
|
||||||
|
if (rcode)
|
||||||
|
ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read XR serial */
|
||||||
|
rcode = Acm.RcvData(&rcvd, buf);
|
||||||
|
if (rcode && rcode != hrNAK)
|
||||||
|
ErrorMessage<uint8_t>(PSTR("Ret"), rcode);
|
||||||
|
|
||||||
|
if( rcvd ) { //more than zero bytes received
|
||||||
|
for(uint16_t i=0; i < rcvd; i++ ) {
|
||||||
|
Serial.print((char)buf[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
16
hid.cpp
16
hid.cpp
|
@ -24,7 +24,7 @@ uint8_t HID::GetReportDescr(uint8_t ep, USBReadParser *parser) {
|
||||||
const uint8_t constBufLen = 64;
|
const uint8_t constBufLen = 64;
|
||||||
uint8_t buf[constBufLen];
|
uint8_t buf[constBufLen];
|
||||||
|
|
||||||
uint8_t rcode = pUsb->ctrlReq(bAddress, ep, bmREQ_HID_REPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00,
|
uint8_t rcode = pUsb->ctrlReq(bAddress, ep, bmREQ_HIDREPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00,
|
||||||
HID_DESCRIPTOR_REPORT, 0x0000, 128, constBufLen, buf, (USBReadParser*)parser);
|
HID_DESCRIPTOR_REPORT, 0x0000, 128, constBufLen, buf, (USBReadParser*)parser);
|
||||||
|
|
||||||
//return ((rcode != hrSTALL) ? rcode : 0);
|
//return ((rcode != hrSTALL) ? rcode : 0);
|
||||||
|
@ -35,7 +35,7 @@ uint8_t HID::GetReportDescr(uint16_t wIndex, USBReadParser *parser) {
|
||||||
const uint8_t constBufLen = 64;
|
const uint8_t constBufLen = 64;
|
||||||
uint8_t buf[constBufLen];
|
uint8_t buf[constBufLen];
|
||||||
|
|
||||||
uint8_t rcode = pUsb->ctrlReq(bAddress, 0x00, bmREQ_HID_REPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00,
|
uint8_t rcode = pUsb->ctrlReq(bAddress, 0x00, bmREQ_HIDREPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00,
|
||||||
HID_DESCRIPTOR_REPORT, wIndex, 128, constBufLen, buf, (USBReadParser*)parser);
|
HID_DESCRIPTOR_REPORT, wIndex, 128, constBufLen, buf, (USBReadParser*)parser);
|
||||||
|
|
||||||
//return ((rcode != hrSTALL) ? rcode : 0);
|
//return ((rcode != hrSTALL) ? rcode : 0);
|
||||||
|
@ -48,27 +48,27 @@ uint8_t HID::GetReportDescr(uint16_t wIndex, USBReadParser *parser) {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
uint8_t HID::SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr) {
|
uint8_t HID::SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr) {
|
||||||
return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL));
|
return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HIDOUT, HID_REQUEST_SET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t HID::GetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr) {
|
uint8_t HID::GetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr) {
|
||||||
return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HID_IN, HID_REQUEST_GET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL));
|
return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HIDIN, HID_REQUEST_GET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t HID::GetIdle(uint8_t iface, uint8_t reportID, uint8_t* dataptr) {
|
uint8_t HID::GetIdle(uint8_t iface, uint8_t reportID, uint8_t* dataptr) {
|
||||||
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_IN, HID_REQUEST_GET_IDLE, reportID, 0, iface, 0x0001, 0x0001, dataptr, NULL));
|
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HIDIN, HID_REQUEST_GET_IDLE, reportID, 0, iface, 0x0001, 0x0001, dataptr, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t HID::SetIdle(uint8_t iface, uint8_t reportID, uint8_t duration) {
|
uint8_t HID::SetIdle(uint8_t iface, uint8_t reportID, uint8_t duration) {
|
||||||
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_OUT, HID_REQUEST_SET_IDLE, reportID, duration, iface, 0x0000, 0x0000, NULL, NULL));
|
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HIDOUT, HID_REQUEST_SET_IDLE, reportID, duration, iface, 0x0000, 0x0000, NULL, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t HID::SetProtocol(uint8_t iface, uint8_t protocol) {
|
uint8_t HID::SetProtocol(uint8_t iface, uint8_t protocol) {
|
||||||
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_OUT, HID_REQUEST_SET_PROTOCOL, protocol, 0x00, iface, 0x0000, 0x0000, NULL, NULL));
|
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HIDOUT, HID_REQUEST_SET_PROTOCOL, protocol, 0x00, iface, 0x0000, 0x0000, NULL, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t HID::GetProtocol(uint8_t iface, uint8_t* dataptr) {
|
uint8_t HID::GetProtocol(uint8_t iface, uint8_t* dataptr) {
|
||||||
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_IN, HID_REQUEST_GET_PROTOCOL, 0x00, 0x00, iface, 0x0001, 0x0001, dataptr, NULL));
|
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HIDIN, HID_REQUEST_GET_PROTOCOL, 0x00, 0x00, iface, 0x0001, 0x0001, dataptr, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HID::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
void HID::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
|
||||||
|
|
38
hid.h
38
hid.h
|
@ -20,8 +20,8 @@ e-mail : support@circuitsathome.com
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
#include "hidusagestr.h"
|
#include "hidusagestr.h"
|
||||||
|
|
||||||
#define MAX_REPORT_PARSERS 2
|
#define MAX_REPORT_PARSERS 2
|
||||||
#define HID_MAX_HID_CLASS_DESCRIPTORS 5
|
#define HID_MAX_HID_CLASS_DESCRIPTORS 5
|
||||||
|
|
||||||
#define DATA_SIZE_MASK 0x03
|
#define DATA_SIZE_MASK 0x03
|
||||||
#define TYPE_MASK 0x0C
|
#define TYPE_MASK 0x0C
|
||||||
|
@ -60,9 +60,9 @@ e-mail : support@circuitsathome.com
|
||||||
#define TAG_LOCAL_USAGEMAX 0x20
|
#define TAG_LOCAL_USAGEMAX 0x20
|
||||||
|
|
||||||
/* HID requests */
|
/* HID requests */
|
||||||
#define bmREQ_HID_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
#define bmREQ_HIDOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||||
#define bmREQ_HID_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
#define bmREQ_HIDIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||||
#define bmREQ_HID_REPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE
|
#define bmREQ_HIDREPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE
|
||||||
|
|
||||||
/* HID constants. Not part of chapter 9 */
|
/* HID constants. Not part of chapter 9 */
|
||||||
/* Class-Specific Requests */
|
/* Class-Specific Requests */
|
||||||
|
@ -98,23 +98,23 @@ e-mail : support@circuitsathome.com
|
||||||
#define HID_ITEM_TYPE_LOCAL 2
|
#define HID_ITEM_TYPE_LOCAL 2
|
||||||
#define HID_ITEM_TYPE_RESERVED 3
|
#define HID_ITEM_TYPE_RESERVED 3
|
||||||
|
|
||||||
#define HID_LONG_ITEM_PREFIX 0xfe // Long item prefix value
|
#define HID_LONG_ITEM_PREFIX 0xfe // Long item prefix value
|
||||||
|
|
||||||
#define bmHID_MAIN_ITEM_TAG 0xfc // Main item tag mask
|
#define bmHID_MAIN_ITEM_TAG 0xfc // Main item tag mask
|
||||||
|
|
||||||
#define bmHID_MAIN_ITEM_INPUT 0x80 // Main item Input tag value
|
#define bmHID_MAIN_ITEM_INPUT 0x80 // Main item Input tag value
|
||||||
#define bmHID_MAIN_ITEM_OUTPUT 0x90 // Main item Output tag value
|
#define bmHID_MAIN_ITEM_OUTPUT 0x90 // Main item Output tag value
|
||||||
#define bmHID_MAIN_ITEM_FEATURE 0xb0 // Main item Feature tag value
|
#define bmHID_MAIN_ITEM_FEATURE 0xb0 // Main item Feature tag value
|
||||||
#define bmHID_MAIN_ITEM_COLLECTION 0xa0 // Main item Collection tag value
|
#define bmHID_MAIN_ITEM_COLLECTION 0xa0 // Main item Collection tag value
|
||||||
#define bmHID_MAIN_ITEM_END_COLLECTION 0xce // Main item End Collection tag value
|
#define bmHID_MAIN_ITEM_END_COLLECTION 0xce // Main item End Collection tag value
|
||||||
|
|
||||||
#define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0
|
#define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0
|
||||||
#define HID_MAIN_ITEM_COLLECTION_APPLICATION 1
|
#define HID_MAIN_ITEM_COLLECTION_APPLICATION 1
|
||||||
#define HID_MAIN_ITEM_COLLECTION_LOGICAL 2
|
#define HID_MAIN_ITEM_COLLECTION_LOGICAL 2
|
||||||
#define HID_MAIN_ITEM_COLLECTION_REPORT 3
|
#define HID_MAIN_ITEM_COLLECTION_REPORT 3
|
||||||
#define HID_MAIN_ITEM_COLLECTION_NAMED_ARRAY 4
|
#define HID_MAIN_ITEM_COLLECTION_NAMED_ARRAY 4
|
||||||
#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5
|
#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5
|
||||||
#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6
|
#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6
|
||||||
|
|
||||||
struct HidItemPrefix {
|
struct HidItemPrefix {
|
||||||
uint8_t bSize : 2;
|
uint8_t bSize : 2;
|
||||||
|
|
14
hidboot.cpp
14
hidboot.cpp
|
@ -129,12 +129,12 @@ void KeyboardReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
|
||||||
if (buf[2] == 1)
|
if (buf[2] == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//KBDINFO *pki = (KBDINFO*)buf;
|
//KBDINFO *pki = (KBDINFO*)buf;
|
||||||
|
|
||||||
// provide event for changed control key state
|
// provide event for changed control key state
|
||||||
if (prevState.bInfo[0x00] != buf[0x00]) {
|
if (prevState.bInfo[0x00] != buf[0x00]) {
|
||||||
OnControlKeysChanged(prevState.bInfo[0x00], buf[0x00]);
|
OnControlKeysChanged(prevState.bInfo[0x00], buf[0x00]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 2; i < 8; i++) {
|
for (uint8_t i = 2; i < 8; i++) {
|
||||||
bool down = false;
|
bool down = false;
|
||||||
|
@ -168,8 +168,8 @@ uint8_t KeyboardReportParser::OemToAscii(uint8_t mod, uint8_t key) {
|
||||||
// [a-z]
|
// [a-z]
|
||||||
if (VALUE_WITHIN(key, 0x04, 0x1d)) {
|
if (VALUE_WITHIN(key, 0x04, 0x1d)) {
|
||||||
// Upper case letters
|
// Upper case letters
|
||||||
if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && shift) ||
|
if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && (mod & 2)) ||
|
||||||
(kbdLockingKeys.kbdLeds.bmCapsLock == 1 && shift == 0))
|
(kbdLockingKeys.kbdLeds.bmCapsLock == 1 && (mod & 2) == 0))
|
||||||
return (key - 4 + 'A');
|
return (key - 4 + 'A');
|
||||||
|
|
||||||
// Lower case letters
|
// Lower case letters
|
||||||
|
|
|
@ -232,10 +232,6 @@ public:
|
||||||
return bAddress;
|
return bAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual bool isReady() {
|
|
||||||
return bPollEnable;
|
|
||||||
};
|
|
||||||
|
|
||||||
// UsbConfigXtracter implementation
|
// UsbConfigXtracter implementation
|
||||||
// Method should be defined here if virtual.
|
// Method should be defined here if virtual.
|
||||||
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
|
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ void ReportDescParserBase::Parse(const uint16_t len, const uint8_t *pbuf, const
|
||||||
ParseItem(&p, &cntdn);
|
ParseItem(&p, &cntdn);
|
||||||
|
|
||||||
//if (ParseItem(&p, &cntdn))
|
//if (ParseItem(&p, &cntdn))
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
//USBTRACE2("Total:", totalSize);
|
//USBTRACE2("Total:", totalSize);
|
||||||
}
|
}
|
||||||
|
@ -1089,7 +1089,7 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
||||||
//uint8_t ret = enErrorSuccess;
|
//uint8_t ret = enErrorSuccess;
|
||||||
//reinterpret_cast<>(varBuffer);
|
//reinterpret_cast<>(varBuffer);
|
||||||
switch(itemParseState) {
|
switch(itemParseState) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1233,22 +1233,10 @@ ReportDescParserBase::UsagePageFunc ReportDescParserBase::usagePageFunctions[] /
|
||||||
void ReportDescParserBase::SetUsagePage(uint16_t page) {
|
void ReportDescParserBase::SetUsagePage(uint16_t page) {
|
||||||
pfUsage = NULL;
|
pfUsage = NULL;
|
||||||
|
|
||||||
if(VALUE_BETWEEN(page, 0x00, 0x11))
|
if(VALUE_BETWEEN(page, 0x00, 0x11)) {
|
||||||
pfUsage = (usagePageFunctions[page - 1]);
|
pfUsage = (usagePageFunctions[page - 1]);
|
||||||
|
|
||||||
// Dead code...
|
} else {
|
||||||
//
|
|
||||||
// pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]);
|
|
||||||
//else if (page > 0x7f && page < 0x84)
|
|
||||||
// E_Notify(pstrUsagePageMonitor);
|
|
||||||
//else if (page > 0x83 && page < 0x8c)
|
|
||||||
// E_Notify(pstrUsagePagePower);
|
|
||||||
//else if (page > 0x8b && page < 0x92)
|
|
||||||
// E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c]));
|
|
||||||
//else if (page > 0xfeff && page <= 0xffff)
|
|
||||||
// E_Notify(pstrUsagePageVendorDefined);
|
|
||||||
//
|
|
||||||
else
|
|
||||||
switch(page) {
|
switch(page) {
|
||||||
case 0x14:
|
case 0x14:
|
||||||
pfUsage = &ReportDescParserBase::PrintAlphanumDisplayPageUsage;
|
pfUsage = &ReportDescParserBase::PrintAlphanumDisplayPageUsage;
|
||||||
|
@ -1257,6 +1245,7 @@ void ReportDescParserBase::SetUsagePage(uint16_t page) {
|
||||||
pfUsage = &ReportDescParserBase::PrintMedicalInstrumentPageUsage;
|
pfUsage = &ReportDescParserBase::PrintMedicalInstrumentPageUsage;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportDescParserBase::PrintUsagePage(uint16_t page) {
|
void ReportDescParserBase::PrintUsagePage(uint16_t page) {
|
||||||
|
@ -1438,7 +1427,7 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint16_t *pcntdn) {
|
||||||
//uint8_t ret = enErrorSuccess;
|
//uint8_t ret = enErrorSuccess;
|
||||||
|
|
||||||
switch(itemParseState) {
|
switch(itemParseState) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1553,9 +1542,9 @@ void ReportDescParser2::OnInputItem(uint8_t itm) {
|
||||||
if(print_usemin_usemax)
|
if(print_usemin_usemax)
|
||||||
pfUsage(usage);
|
pfUsage(usage);
|
||||||
|
|
||||||
// bits_left - number of bits in the field(array of fields, depending on Report Count) left to process
|
// bits_left - number of bits in the field(array of fields, depending on Report Count) left to process
|
||||||
// bits_of_byte - number of bits in current byte left to process
|
// bits_of_byte - number of bits in current byte left to process
|
||||||
// bits_to_copy - number of bits to copy to result buffer
|
// bits_to_copy - number of bits to copy to result buffer
|
||||||
|
|
||||||
// for each bit in a field
|
// for each bit in a field
|
||||||
for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left;
|
for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left;
|
||||||
|
|
|
@ -103,7 +103,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
uint8_t len = 0;
|
uint8_t len = 0;
|
||||||
|
|
||||||
uint8_t num_of_conf; // number of configurations
|
uint8_t num_of_conf; // number of configurations
|
||||||
//uint8_t num_of_intf; // number of interfaces
|
//uint8_t num_of_intf; // number of interfaces
|
||||||
|
|
||||||
AddressPool &addrPool = pUsb->GetAddressPool();
|
AddressPool &addrPool = pUsb->GetAddressPool();
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
USBTRACE2("NC:", num_of_conf);
|
USBTRACE2("NC:", num_of_conf);
|
||||||
|
|
||||||
for(uint8_t i = 0; i < num_of_conf; i++) {
|
for(uint8_t i = 0; i < num_of_conf; i++) {
|
||||||
//HexDumper<USBReadParser, uint16_t, uint16_t> HexDump;
|
//HexDumper<USBReadParser, uint16_t, uint16_t> HexDump;
|
||||||
ConfigDescParser<USB_CLASS_HID, 0, 0,
|
ConfigDescParser<USB_CLASS_HID, 0, 0,
|
||||||
CP_MASK_COMPARE_CLASS> confDescrParser(this);
|
CP_MASK_COMPARE_CLASS> confDescrParser(this);
|
||||||
|
|
||||||
|
@ -418,9 +418,3 @@ uint8_t HIDUniversal::Poll() {
|
||||||
}
|
}
|
||||||
return rcode;
|
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);
|
|
||||||
}
|
|
|
@ -100,9 +100,6 @@ public:
|
||||||
|
|
||||||
// UsbConfigXtracter implementation
|
// UsbConfigXtracter implementation
|
||||||
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__
|
#endif // __HIDUNIVERSAL_H__
|
||||||
|
|
|
@ -358,7 +358,7 @@ const char pstrUsageProgrammableButton [] PROGMEM = "Prog Button";
|
||||||
const char pstrUsageHookSwitch [] PROGMEM = "Hook Sw";
|
const char pstrUsageHookSwitch [] PROGMEM = "Hook Sw";
|
||||||
const char pstrUsageFlash [] PROGMEM = "Flash";
|
const char pstrUsageFlash [] PROGMEM = "Flash";
|
||||||
const char pstrUsageFeature [] PROGMEM = "Feature";
|
const char pstrUsageFeature [] PROGMEM = "Feature";
|
||||||
//const char pstrUsageHold [] PROGMEM = "Hold";
|
//const char pstrUsageHold [] PROGMEM = "Hold";
|
||||||
const char pstrUsageRedial [] PROGMEM = "Redial";
|
const char pstrUsageRedial [] PROGMEM = "Redial";
|
||||||
const char pstrUsageTransfer [] PROGMEM = "Transfer";
|
const char pstrUsageTransfer [] PROGMEM = "Transfer";
|
||||||
const char pstrUsageDrop [] PROGMEM = "Drop";
|
const char pstrUsageDrop [] PROGMEM = "Drop";
|
||||||
|
@ -367,7 +367,7 @@ const char pstrUsageForwardCalls [] PROGMEM = "Fwd Calls";
|
||||||
const char pstrUsageAlternateFunction [] PROGMEM = "Alt Func";
|
const char pstrUsageAlternateFunction [] PROGMEM = "Alt Func";
|
||||||
const char pstrUsageLine [] PROGMEM = "Line";
|
const char pstrUsageLine [] PROGMEM = "Line";
|
||||||
const char pstrUsageSpeakerPhone [] PROGMEM = "Spk Phone";
|
const char pstrUsageSpeakerPhone [] PROGMEM = "Spk Phone";
|
||||||
//const char pstrUsageConference [] PROGMEM = "Conference";
|
//const char pstrUsageConference [] PROGMEM = "Conference";
|
||||||
const char pstrUsageRingEnable [] PROGMEM = "Ring Enbl";
|
const char pstrUsageRingEnable [] PROGMEM = "Ring Enbl";
|
||||||
const char pstrUsageRingSelect [] PROGMEM = "Ring Sel";
|
const char pstrUsageRingSelect [] PROGMEM = "Ring Sel";
|
||||||
const char pstrUsagePhoneMute [] PROGMEM = "Phone Mute";
|
const char pstrUsagePhoneMute [] PROGMEM = "Phone Mute";
|
||||||
|
@ -379,7 +379,7 @@ const char pstrUsageRecallNumber [] PROGMEM = "Recall Num";
|
||||||
const char pstrUsagePhoneDirectory [] PROGMEM = "Phone Dir";
|
const char pstrUsagePhoneDirectory [] PROGMEM = "Phone Dir";
|
||||||
const char pstrUsageVoiceMail [] PROGMEM = "Voice Mail";
|
const char pstrUsageVoiceMail [] PROGMEM = "Voice Mail";
|
||||||
const char pstrUsageScreenCalls [] PROGMEM = "Screen Calls";
|
const char pstrUsageScreenCalls [] PROGMEM = "Screen Calls";
|
||||||
//const char pstrUsageDoNotDisturb [] PROGMEM = "Do Not Disturb";
|
//const char pstrUsageDoNotDisturb [] PROGMEM = "Do Not Disturb";
|
||||||
const char pstrUsageMessage [] PROGMEM = "Msg";
|
const char pstrUsageMessage [] PROGMEM = "Msg";
|
||||||
const char pstrUsageAnswerOnOff [] PROGMEM = "Answer On/Off";
|
const char pstrUsageAnswerOnOff [] PROGMEM = "Answer On/Off";
|
||||||
const char pstrUsageInsideDialTone [] PROGMEM = "Inside Dial Tone";
|
const char pstrUsageInsideDialTone [] PROGMEM = "Inside Dial Tone";
|
||||||
|
@ -417,14 +417,14 @@ const char pstrUsagePhoneKeyD [] PROGMEM = "D";
|
||||||
// Consumer Usage Page
|
// Consumer Usage Page
|
||||||
const char pstrUsageConsumerControl [] PROGMEM = "Consumer Ctrl";
|
const char pstrUsageConsumerControl [] PROGMEM = "Consumer Ctrl";
|
||||||
const char pstrUsageNumericKeyPad [] PROGMEM = "Num Key Pad";
|
const char pstrUsageNumericKeyPad [] PROGMEM = "Num Key Pad";
|
||||||
//const char pstrUsageProgrammableButton [] PROGMEM = "Prog Btn";
|
//const char pstrUsageProgrammableButton [] PROGMEM = "Prog Btn";
|
||||||
//const char pstrUsageMicrophone [] PROGMEM = "Mic";
|
//const char pstrUsageMicrophone [] PROGMEM = "Mic";
|
||||||
const char pstrUsageHeadphone [] PROGMEM = "Headphone";
|
const char pstrUsageHeadphone [] PROGMEM = "Headphone";
|
||||||
const char pstrUsageGraphicEqualizer [] PROGMEM = "Graph Eq";
|
const char pstrUsageGraphicEqualizer [] PROGMEM = "Graph Eq";
|
||||||
const char pstrUsagePlus10 [] PROGMEM = "+10";
|
const char pstrUsagePlus10 [] PROGMEM = "+10";
|
||||||
const char pstrUsagePlus100 [] PROGMEM = "+100";
|
const char pstrUsagePlus100 [] PROGMEM = "+100";
|
||||||
const char pstrUsageAMPM [] PROGMEM = "AM/PM";
|
const char pstrUsageAMPM [] PROGMEM = "AM/PM";
|
||||||
//const char pstrUsagePower [] PROGMEM = "Pwr";
|
//const char pstrUsagePower [] PROGMEM = "Pwr";
|
||||||
const char pstrUsageReset [] PROGMEM = "Reset";
|
const char pstrUsageReset [] PROGMEM = "Reset";
|
||||||
const char pstrUsageSleep [] PROGMEM = "Sleep";
|
const char pstrUsageSleep [] PROGMEM = "Sleep";
|
||||||
const char pstrUsageSleepAfter [] PROGMEM = "Sleep After";
|
const char pstrUsageSleepAfter [] PROGMEM = "Sleep After";
|
||||||
|
@ -483,19 +483,19 @@ const char pstrUsageOnce [] PROGMEM = "Once";
|
||||||
const char pstrUsageDaily [] PROGMEM = "Daily";
|
const char pstrUsageDaily [] PROGMEM = "Daily";
|
||||||
const char pstrUsageWeekly [] PROGMEM = "Weekly";
|
const char pstrUsageWeekly [] PROGMEM = "Weekly";
|
||||||
const char pstrUsageMonthly [] PROGMEM = "Monthly";
|
const char pstrUsageMonthly [] PROGMEM = "Monthly";
|
||||||
//const char pstrUsagePlay [] PROGMEM = "Play";
|
//const char pstrUsagePlay [] PROGMEM = "Play";
|
||||||
//const char pstrUsagePause [] PROGMEM = "Pause";
|
//const char pstrUsagePause [] PROGMEM = "Pause";
|
||||||
//const char pstrUsageRecord [] PROGMEM = "Rec";
|
//const char pstrUsageRecord [] PROGMEM = "Rec";
|
||||||
//const char pstrUsageFastForward [] PROGMEM = "FF";
|
//const char pstrUsageFastForward [] PROGMEM = "FF";
|
||||||
//const char pstrUsageRewind [] PROGMEM = "Rewind";
|
//const char pstrUsageRewind [] PROGMEM = "Rewind";
|
||||||
const char pstrUsageScanNextTrack [] PROGMEM = "Next Track";
|
const char pstrUsageScanNextTrack [] PROGMEM = "Next Track";
|
||||||
const char pstrUsageScanPreviousTrack [] PROGMEM = "Prev Track";
|
const char pstrUsageScanPreviousTrack [] PROGMEM = "Prev Track";
|
||||||
//const char pstrUsageStop [] PROGMEM = "Stop";
|
//const char pstrUsageStop [] PROGMEM = "Stop";
|
||||||
const char pstrUsageEject [] PROGMEM = "Eject";
|
const char pstrUsageEject [] PROGMEM = "Eject";
|
||||||
const char pstrUsageRandomPlay [] PROGMEM = "Random";
|
const char pstrUsageRandomPlay [] PROGMEM = "Random";
|
||||||
const char pstrUsageSelectDisk [] PROGMEM = "Sel Disk";
|
const char pstrUsageSelectDisk [] PROGMEM = "Sel Disk";
|
||||||
const char pstrUsageEnterDisk [] PROGMEM = "Ent Disk";
|
const char pstrUsageEnterDisk [] PROGMEM = "Ent Disk";
|
||||||
//const char pstrUsageRepeat [] PROGMEM = "Repeat";
|
//const char pstrUsageRepeat [] PROGMEM = "Repeat";
|
||||||
const char pstrUsageTracking [] PROGMEM = "Tracking";
|
const char pstrUsageTracking [] PROGMEM = "Tracking";
|
||||||
const char pstrUsageTrackNormal [] PROGMEM = "Trk Norm";
|
const char pstrUsageTrackNormal [] PROGMEM = "Trk Norm";
|
||||||
const char pstrUsageSlowTracking [] PROGMEM = "Slow Trk";
|
const char pstrUsageSlowTracking [] PROGMEM = "Slow Trk";
|
||||||
|
@ -516,7 +516,7 @@ const char pstrUsagePlayPause [] PROGMEM = "Play/Pause";
|
||||||
const char pstrUsagePlaySkip [] PROGMEM = "Play/Skip";
|
const char pstrUsagePlaySkip [] PROGMEM = "Play/Skip";
|
||||||
const char pstrUsageVolume [] PROGMEM = "Vol";
|
const char pstrUsageVolume [] PROGMEM = "Vol";
|
||||||
const char pstrUsageBalance [] PROGMEM = "Balance";
|
const char pstrUsageBalance [] PROGMEM = "Balance";
|
||||||
//const char pstrUsageMute [] PROGMEM = "Mute";
|
//const char pstrUsageMute [] PROGMEM = "Mute";
|
||||||
const char pstrUsageBass [] PROGMEM = "Bass";
|
const char pstrUsageBass [] PROGMEM = "Bass";
|
||||||
const char pstrUsageTreble [] PROGMEM = "Treble";
|
const char pstrUsageTreble [] PROGMEM = "Treble";
|
||||||
const char pstrUsageBassBoost [] PROGMEM = "Bass Boost";
|
const char pstrUsageBassBoost [] PROGMEM = "Bass Boost";
|
||||||
|
@ -808,7 +808,7 @@ const char pstrUsageDataValid [] PROGMEM = "Data Valid";
|
||||||
const char pstrUsageTransducerIndex [] PROGMEM = "Transducer Ind";
|
const char pstrUsageTransducerIndex [] PROGMEM = "Transducer Ind";
|
||||||
const char pstrUsageTabletFunctionKeys [] PROGMEM = "Tabl Func Keys";
|
const char pstrUsageTabletFunctionKeys [] PROGMEM = "Tabl Func Keys";
|
||||||
const char pstrUsageProgramChangeKeys [] PROGMEM = "Pgm Chng Keys";
|
const char pstrUsageProgramChangeKeys [] PROGMEM = "Pgm Chng Keys";
|
||||||
//const char pstrUsageBatteryStrength [] PROGMEM = "Bat Strength";
|
//const char pstrUsageBatteryStrength [] PROGMEM = "Bat Strength";
|
||||||
const char pstrUsageInvert [] PROGMEM = "Invert";
|
const char pstrUsageInvert [] PROGMEM = "Invert";
|
||||||
const char pstrUsageXTilt [] PROGMEM = "X Tilt";
|
const char pstrUsageXTilt [] PROGMEM = "X Tilt";
|
||||||
const char pstrUsageYTilt [] PROGMEM = "Y Tilt";
|
const char pstrUsageYTilt [] PROGMEM = "Y Tilt";
|
||||||
|
@ -830,7 +830,7 @@ const char pstrUsageDataReadBack [] PROGMEM = "Data Rd Back";
|
||||||
const char pstrUsageFontReadBack [] PROGMEM = "Fnt Rd Back";
|
const char pstrUsageFontReadBack [] PROGMEM = "Fnt Rd Back";
|
||||||
const char pstrUsageDisplayControlReport [] PROGMEM = "Disp Ctrl Rpt";
|
const char pstrUsageDisplayControlReport [] PROGMEM = "Disp Ctrl Rpt";
|
||||||
const char pstrUsageClearDisplay [] PROGMEM = "Clr Disp";
|
const char pstrUsageClearDisplay [] PROGMEM = "Clr Disp";
|
||||||
//const char pstrUsageDisplayEnable [] PROGMEM = "Disp Enbl";
|
//const char pstrUsageDisplayEnable [] PROGMEM = "Disp Enbl";
|
||||||
const char pstrUsageScreenSaverDelay [] PROGMEM = "Scr Sav Delay";
|
const char pstrUsageScreenSaverDelay [] PROGMEM = "Scr Sav Delay";
|
||||||
const char pstrUsageScreenSaverEnable [] PROGMEM = "Scr Sav Enbl";
|
const char pstrUsageScreenSaverEnable [] PROGMEM = "Scr Sav Enbl";
|
||||||
const char pstrUsageVerticalScroll [] PROGMEM = "V Scroll";
|
const char pstrUsageVerticalScroll [] PROGMEM = "V Scroll";
|
||||||
|
@ -903,7 +903,7 @@ const char pstrUsagePrint [] PROGMEM = "Print";
|
||||||
const char pstrUsageMicrophoneEnable [] PROGMEM = "Mic Enbl";
|
const char pstrUsageMicrophoneEnable [] PROGMEM = "Mic Enbl";
|
||||||
const char pstrUsageCine [] PROGMEM = "Cine";
|
const char pstrUsageCine [] PROGMEM = "Cine";
|
||||||
const char pstrUsageTransmitPower [] PROGMEM = "Trans Pwr";
|
const char pstrUsageTransmitPower [] PROGMEM = "Trans Pwr";
|
||||||
//const char pstrUsageVolume [] PROGMEM = "Vol";
|
//const char pstrUsageVolume [] PROGMEM = "Vol";
|
||||||
const char pstrUsageFocus [] PROGMEM = "Focus";
|
const char pstrUsageFocus [] PROGMEM = "Focus";
|
||||||
const char pstrUsageDepth [] PROGMEM = "Depth";
|
const char pstrUsageDepth [] PROGMEM = "Depth";
|
||||||
const char pstrUsageSoftStepPrimary [] PROGMEM = "Soft Stp-Pri";
|
const char pstrUsageSoftStepPrimary [] PROGMEM = "Soft Stp-Pri";
|
||||||
|
|
|
@ -19,6 +19,8 @@ e-mail : support@circuitsathome.com
|
||||||
|
|
||||||
#include "hidusagestr.h"
|
#include "hidusagestr.h"
|
||||||
|
|
||||||
|
// This is here why?
|
||||||
|
|
||||||
//const char *usagePageTitles0[] PROGMEM =
|
//const char *usagePageTitles0[] PROGMEM =
|
||||||
//{
|
//{
|
||||||
// pstrUsagePageGenericDesktopControls ,
|
// pstrUsagePageGenericDesktopControls ,
|
||||||
|
|
4
macros.h
4
macros.h
|
@ -18,7 +18,7 @@ e-mail : support@circuitsathome.com
|
||||||
#if !defined(_usb_h_) || defined(MACROS_H)
|
#if !defined(_usb_h_) || defined(MACROS_H)
|
||||||
#error "Never include macros.h directly; include Usb.h instead"
|
#error "Never include macros.h directly; include Usb.h instead"
|
||||||
#else
|
#else
|
||||||
#define MACROS_H
|
#define MACROS_H
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// HANDY MACROS
|
// HANDY MACROS
|
||||||
|
@ -78,5 +78,5 @@ e-mail : support@circuitsathome.com
|
||||||
#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l))
|
#define USBTRACE3(s,r,l) (Notify(PSTR(s), l), D_PrintHex((r), l), Notify(PSTR("\r\n"), l))
|
||||||
|
|
||||||
|
|
||||||
#endif /* MACROS_H */
|
#endif /* MACROS_H */
|
||||||
|
|
||||||
|
|
110
masstorage.h
110
masstorage.h
|
@ -29,35 +29,35 @@ e-mail : support@circuitsathome.com
|
||||||
#define bmREQ_MASSIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
#define bmREQ_MASSIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||||
|
|
||||||
// Mass Storage Subclass Constants
|
// Mass Storage Subclass Constants
|
||||||
#define MASS_SUBCLASS_SCSI_NOT_REPORTED 0x00 // De facto use
|
#define MASS_SUBCLASS_SCSI_NOT_REPORTED 0x00 // De facto use
|
||||||
#define MASS_SUBCLASS_RBC 0x01
|
#define MASS_SUBCLASS_RBC 0x01
|
||||||
#define MASS_SUBCLASS_ATAPI 0x02 // MMC-5 (ATAPI)
|
#define MASS_SUBCLASS_ATAPI 0x02 // MMC-5 (ATAPI)
|
||||||
#define MASS_SUBCLASS_OBSOLETE1 0x03 // Was QIC-157
|
#define MASS_SUBCLASS_OBSOLETE1 0x03 // Was QIC-157
|
||||||
#define MASS_SUBCLASS_UFI 0x04 // Specifies how to interface Floppy Disk Drives to USB
|
#define MASS_SUBCLASS_UFI 0x04 // Specifies how to interface Floppy Disk Drives to USB
|
||||||
#define MASS_SUBCLASS_OBSOLETE2 0x05 // Was SFF-8070i
|
#define MASS_SUBCLASS_OBSOLETE2 0x05 // Was SFF-8070i
|
||||||
#define MASS_SUBCLASS_SCSI 0x06 // SCSI Transparent Command Set
|
#define MASS_SUBCLASS_SCSI 0x06 // SCSI Transparent Command Set
|
||||||
#define MASS_SUBCLASS_LSDFS 0x07 // Specifies how host has to negotiate access before trying SCSI
|
#define MASS_SUBCLASS_LSDFS 0x07 // Specifies how host has to negotiate access before trying SCSI
|
||||||
#define MASS_SUBCLASS_IEEE1667 0x08
|
#define MASS_SUBCLASS_IEEE1667 0x08
|
||||||
|
|
||||||
// Mass Storage Class Protocols
|
// Mass Storage Class Protocols
|
||||||
#define MASS_PROTO_CBI 0x00 // CBI (with command completion interrupt)
|
#define MASS_PROTO_CBI 0x00 // CBI (with command completion interrupt)
|
||||||
#define MASS_PROTO_CBI_NO_INT 0x01 // CBI (without command completion interrupt)
|
#define MASS_PROTO_CBI_NO_INT 0x01 // CBI (without command completion interrupt)
|
||||||
#define MASS_PROTO_OBSOLETE 0x02
|
#define MASS_PROTO_OBSOLETE 0x02
|
||||||
#define MASS_PROTO_BBB 0x50 // Bulk Only Transport
|
#define MASS_PROTO_BBB 0x50 // Bulk Only Transport
|
||||||
#define MASS_PROTO_UAS 0x62
|
#define MASS_PROTO_UAS 0x62
|
||||||
|
|
||||||
// Request Codes
|
// Request Codes
|
||||||
#define MASS_REQ_ADSC 0x00
|
#define MASS_REQ_ADSC 0x00
|
||||||
#define MASS_REQ_GET 0xFC
|
#define MASS_REQ_GET 0xFC
|
||||||
#define MASS_REQ_PUT 0xFD
|
#define MASS_REQ_PUT 0xFD
|
||||||
#define MASS_REQ_GET_MAX_LUN 0xFE
|
#define MASS_REQ_GET_MAX_LUN 0xFE
|
||||||
#define MASS_REQ_BOMSR 0xFF // Bulk-Only Mass Storage Reset
|
#define MASS_REQ_BOMSR 0xFF // Bulk-Only Mass Storage Reset
|
||||||
|
|
||||||
#define MASS_CBW_SIGNATURE 0x43425355
|
#define MASS_CBW_SIGNATURE 0x43425355
|
||||||
#define MASS_CSW_SIGNATURE 0x53425355
|
#define MASS_CSW_SIGNATURE 0x53425355
|
||||||
|
|
||||||
#define MASS_CMD_DIR_OUT 0 // (0 << 7)
|
#define MASS_CMD_DIR_OUT 0 // (0 << 7)
|
||||||
#define MASS_CMD_DIR_IN 0x80 //(1 << 7)
|
#define MASS_CMD_DIR_IN 0x80 //(1 << 7)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reference documents from T10 (http://www.t10.org)
|
* Reference documents from T10 (http://www.t10.org)
|
||||||
|
@ -67,21 +67,21 @@ e-mail : support@circuitsathome.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Group 1 commands (CDB's here are should all be 6-bytes) */
|
/* Group 1 commands (CDB's here are should all be 6-bytes) */
|
||||||
#define SCSI_CMD_TEST_UNIT_READY 0x00
|
#define SCSI_CMD_TEST_UNIT_READY 0x00
|
||||||
#define SCSI_CMD_REQUEST_SENSE 0x03
|
#define SCSI_CMD_REQUEST_SENSE 0x03
|
||||||
#define SCSI_CMD_FORMAT_UNIT 0x04
|
#define SCSI_CMD_FORMAT_UNIT 0x04
|
||||||
#define SCSI_CMD_READ_6 0x08
|
#define SCSI_CMD_READ_6 0x08
|
||||||
#define SCSI_CMD_WRITE_6 0x0A
|
#define SCSI_CMD_WRITE_6 0x0A
|
||||||
#define SCSI_CMD_INQUIRY 0x12
|
#define SCSI_CMD_INQUIRY 0x12
|
||||||
#define SCSI_CMD_MODE_SELECT_6 0x15
|
#define SCSI_CMD_MODE_SELECT_6 0x15
|
||||||
#define SCSI_CMD_MODE_SENSE_6 0x1A
|
#define SCSI_CMD_MODE_SENSE_6 0x1A
|
||||||
#define SCSI_CMD_START_STOP_UNIT 0x1B
|
#define SCSI_CMD_START_STOP_UNIT 0x1B
|
||||||
#define SCSI_CMD_PREVENT_REMOVAL 0x1E
|
#define SCSI_CMD_PREVENT_REMOVAL 0x1E
|
||||||
/* Group 2 Commands (CDB's here are 10-bytes) */
|
/* Group 2 Commands (CDB's here are 10-bytes) */
|
||||||
#define SCSI_CMD_READ_FORMAT_CAPACITIES 0x23
|
#define SCSI_CMD_READ_FORMAT_CAPACITIES 0x23
|
||||||
#define SCSI_CMD_READ_CAPACITY_10 0x25
|
#define SCSI_CMD_READ_CAPACITY_10 0x25
|
||||||
#define SCSI_CMD_READ_10 0x28
|
#define SCSI_CMD_READ_10 0x28
|
||||||
#define SCSI_CMD_WRITE_10 0x2A
|
#define SCSI_CMD_WRITE_10 0x2A
|
||||||
#define SCSI_CMD_SEEK_10 0x2B
|
#define SCSI_CMD_SEEK_10 0x2B
|
||||||
#define SCSI_CMD_ERASE_10 0x2C
|
#define SCSI_CMD_ERASE_10 0x2C
|
||||||
#define SCSI_CMD_WRITE_AND_VERIFY_10 0x2E
|
#define SCSI_CMD_WRITE_AND_VERIFY_10 0x2E
|
||||||
|
@ -139,42 +139,42 @@ e-mail : support@circuitsathome.com
|
||||||
#define SCSI_CMD_READ_ALL_SUBCODES 0xDF /* Vendor unique */
|
#define SCSI_CMD_READ_ALL_SUBCODES 0xDF /* Vendor unique */
|
||||||
|
|
||||||
/* SCSI error codes */
|
/* SCSI error codes */
|
||||||
#define SCSI_S_NOT_READY 0x02
|
#define SCSI_S_NOT_READY 0x02
|
||||||
#define SCSI_S_MEDIUM_ERROR 0x03
|
#define SCSI_S_MEDIUM_ERROR 0x03
|
||||||
#define SCSI_S_ILLEGAL_REQUEST 0x05
|
#define SCSI_S_ILLEGAL_REQUEST 0x05
|
||||||
#define SCSI_S_UNIT_ATTENTION 0x06
|
#define SCSI_S_UNIT_ATTENTION 0x06
|
||||||
#define SCSI_ASC_LBA_OUT_OF_RANGE 0x21
|
#define SCSI_ASC_LBA_OUT_OF_RANGE 0x21
|
||||||
#define SCSI_ASC_MEDIA_CHANGED 0x28
|
#define SCSI_ASC_MEDIA_CHANGED 0x28
|
||||||
#define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3A
|
#define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3A
|
||||||
|
|
||||||
/* USB error codes */
|
/* USB error codes */
|
||||||
#define MASS_ERR_SUCCESS 0x00
|
#define MASS_ERR_SUCCESS 0x00
|
||||||
#define MASS_ERR_PHASE_ERROR 0x02
|
#define MASS_ERR_PHASE_ERROR 0x02
|
||||||
#define MASS_ERR_UNIT_NOT_READY 0x03
|
#define MASS_ERR_UNIT_NOT_READY 0x03
|
||||||
#define MASS_ERR_UNIT_BUSY 0x04
|
#define MASS_ERR_UNIT_BUSY 0x04
|
||||||
#define MASS_ERR_STALL 0x05
|
#define MASS_ERR_STALL 0x05
|
||||||
#define MASS_ERR_CMD_NOT_SUPPORTED 0x06
|
#define MASS_ERR_CMD_NOT_SUPPORTED 0x06
|
||||||
#define MASS_ERR_INVALID_CSW 0x07
|
#define MASS_ERR_INVALID_CSW 0x07
|
||||||
#define MASS_ERR_NO_MEDIA 0x08
|
#define MASS_ERR_NO_MEDIA 0x08
|
||||||
#define MASS_ERR_BAD_LBA 0x09
|
#define MASS_ERR_BAD_LBA 0x09
|
||||||
#define MASS_ERR_MEDIA_CHANGED 0x0A
|
#define MASS_ERR_MEDIA_CHANGED 0x0A
|
||||||
#define MASS_ERR_DEVICE_DISCONNECTED 0x11
|
#define MASS_ERR_DEVICE_DISCONNECTED 0x11
|
||||||
#define MASS_ERR_UNABLE_TO_RECOVER 0x12 // Reset recovery error
|
#define MASS_ERR_UNABLE_TO_RECOVER 0x12 // Reset recovery error
|
||||||
#define MASS_ERR_INVALID_LUN 0x13
|
#define MASS_ERR_INVALID_LUN 0x13
|
||||||
#define MASS_ERR_WRITE_STALL 0x14
|
#define MASS_ERR_WRITE_STALL 0x14
|
||||||
#define MASS_ERR_READ_NAKS 0x15
|
#define MASS_ERR_READ_NAKS 0x15
|
||||||
#define MASS_ERR_WRITE_NAKS 0x16
|
#define MASS_ERR_WRITE_NAKS 0x16
|
||||||
#define MASS_ERR_WRITE_PROTECTED 0x17
|
#define MASS_ERR_WRITE_PROTECTED 0x17
|
||||||
#define MASS_ERR_NOT_IMPLEMENTED 0xFD
|
#define MASS_ERR_NOT_IMPLEMENTED 0xFD
|
||||||
#define MASS_ERR_GENERAL_SCSI_ERROR 0xFE
|
#define MASS_ERR_GENERAL_SCSI_ERROR 0xFE
|
||||||
#define MASS_ERR_GENERAL_USB_ERROR 0xFF
|
#define MASS_ERR_GENERAL_USB_ERROR 0xFF
|
||||||
#define MASS_ERR_USER 0xA0 // For subclasses to define their own error codes
|
#define MASS_ERR_USER 0xA0 // For subclasses to define their own error codes
|
||||||
|
|
||||||
#define MASS_TRANS_FLG_CALLBACK 0x01 // Callback is involved
|
#define MASS_TRANS_FLG_CALLBACK 0x01 // Callback is involved
|
||||||
#define MASS_TRANS_FLG_NO_STALL_CHECK 0x02 // STALL condition is not checked
|
#define MASS_TRANS_FLG_NO_STALL_CHECK 0x02 // STALL condition is not checked
|
||||||
#define MASS_TRANS_FLG_NO_PHASE_CHECK 0x04 // PHASE_ERROR is not checked
|
#define MASS_TRANS_FLG_NO_PHASE_CHECK 0x04 // PHASE_ERROR is not checked
|
||||||
|
|
||||||
#define MASS_MAX_ENDPOINTS 3
|
#define MASS_MAX_ENDPOINTS 3
|
||||||
|
|
||||||
struct Capacity {
|
struct Capacity {
|
||||||
uint8_t data[8];
|
uint8_t data[8];
|
||||||
|
|
|
@ -25,11 +25,6 @@ e-mail : support@circuitsathome.com
|
||||||
/* Arduino pin definitions */
|
/* Arduino pin definitions */
|
||||||
/* pin numbers to port numbers */
|
/* pin numbers to port numbers */
|
||||||
|
|
||||||
|
|
||||||
//#define MAX_INT 9 // Duemielanove
|
|
||||||
|
|
||||||
//#define MAX_GPX 8
|
|
||||||
|
|
||||||
#define SE0 0
|
#define SE0 0
|
||||||
#define SE1 1
|
#define SE1 1
|
||||||
#define FSHOST 2
|
#define FSHOST 2
|
||||||
|
@ -150,7 +145,7 @@ e-mail : support@circuitsathome.com
|
||||||
#define bmFRAMEIRQ 0x40
|
#define bmFRAMEIRQ 0x40
|
||||||
#define bmHXFRDNIRQ 0x80
|
#define bmHXFRDNIRQ 0x80
|
||||||
|
|
||||||
#define rHIEN 0xd0 //26<<3
|
#define rHIEN 0xd0 //26<<3
|
||||||
|
|
||||||
/* HIEN Bits */
|
/* HIEN Bits */
|
||||||
#define bmBUSEVENTIE 0x01
|
#define bmBUSEVENTIE 0x01
|
||||||
|
@ -162,7 +157,7 @@ e-mail : support@circuitsathome.com
|
||||||
#define bmFRAMEIE 0x40
|
#define bmFRAMEIE 0x40
|
||||||
#define bmHXFRDNIE 0x80
|
#define bmHXFRDNIE 0x80
|
||||||
|
|
||||||
#define rMODE 0xd8 //27<<3
|
#define rMODE 0xd8 //27<<3
|
||||||
|
|
||||||
/* MODE Bits */
|
/* MODE Bits */
|
||||||
#define bmHOST 0x01
|
#define bmHOST 0x01
|
||||||
|
|
54
max_LCD.h
54
max_LCD.h
|
@ -22,45 +22,45 @@ e-mail : support@circuitsathome.com
|
||||||
#define _Max_LCD_h_
|
#define _Max_LCD_h_
|
||||||
|
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
#include <Print.h>
|
#include "Print.h"
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
#define LCD_CLEARDISPLAY 0x01
|
#define LCD_CLEARDISPLAY 0x01
|
||||||
#define LCD_RETURNHOME 0x02
|
#define LCD_RETURNHOME 0x02
|
||||||
#define LCD_ENTRYMODESET 0x04
|
#define LCD_ENTRYMODESET 0x04
|
||||||
#define LCD_DISPLAYCONTROL 0x08
|
#define LCD_DISPLAYCONTROL 0x08
|
||||||
#define LCD_CURSORSHIFT 0x10
|
#define LCD_CURSORSHIFT 0x10
|
||||||
#define LCD_FUNCTIONSET 0x20
|
#define LCD_FUNCTIONSET 0x20
|
||||||
#define LCD_SETCGRAMADDR 0x40
|
#define LCD_SETCGRAMADDR 0x40
|
||||||
#define LCD_SETDDRAMADDR 0x80
|
#define LCD_SETDDRAMADDR 0x80
|
||||||
|
|
||||||
// flags for display entry mode
|
// flags for display entry mode
|
||||||
#define LCD_ENTRYRIGHT 0x00
|
#define LCD_ENTRYRIGHT 0x00
|
||||||
#define LCD_ENTRYLEFT 0x02
|
#define LCD_ENTRYLEFT 0x02
|
||||||
#define LCD_ENTRYSHIFTINCREMENT 0x01
|
#define LCD_ENTRYSHIFTINCREMENT 0x01
|
||||||
#define LCD_ENTRYSHIFTDECREMENT 0x00
|
#define LCD_ENTRYSHIFTDECREMENT 0x00
|
||||||
|
|
||||||
// flags for display on/off control
|
// flags for display on/off control
|
||||||
#define LCD_DISPLAYON 0x04
|
#define LCD_DISPLAYON 0x04
|
||||||
#define LCD_DISPLAYOFF 0x00
|
#define LCD_DISPLAYOFF 0x00
|
||||||
#define LCD_CURSORON 0x02
|
#define LCD_CURSORON 0x02
|
||||||
#define LCD_CURSOROFF 0x00
|
#define LCD_CURSOROFF 0x00
|
||||||
#define LCD_BLINKON 0x01
|
#define LCD_BLINKON 0x01
|
||||||
#define LCD_BLINKOFF 0x00
|
#define LCD_BLINKOFF 0x00
|
||||||
|
|
||||||
// flags for display/cursor shift
|
// flags for display/cursor shift
|
||||||
#define LCD_DISPLAYMOVE 0x08
|
#define LCD_DISPLAYMOVE 0x08
|
||||||
#define LCD_CURSORMOVE 0x00
|
#define LCD_CURSORMOVE 0x00
|
||||||
#define LCD_MOVERIGHT 0x04
|
#define LCD_MOVERIGHT 0x04
|
||||||
#define LCD_MOVELEFT 0x00
|
#define LCD_MOVELEFT 0x00
|
||||||
|
|
||||||
// flags for function set
|
// flags for function set
|
||||||
#define LCD_8BITMODE 0x10
|
#define LCD_8BITMODE 0x10
|
||||||
#define LCD_4BITMODE 0x00
|
#define LCD_4BITMODE 0x00
|
||||||
#define LCD_2LINE 0x08
|
#define LCD_2LINE 0x08
|
||||||
#define LCD_1LINE 0x00
|
#define LCD_1LINE 0x00
|
||||||
#define LCD_5x10DOTS 0x04
|
#define LCD_5x10DOTS 0x04
|
||||||
#define LCD_5x8DOTS 0x00
|
#define LCD_5x8DOTS 0x00
|
||||||
|
|
||||||
class Max_LCD : public Print {
|
class Max_LCD : public Print {
|
||||||
USB *pUsb;
|
USB *pUsb;
|
||||||
|
|
|
@ -136,4 +136,4 @@ e-mail : support@circuitsathome.com
|
||||||
#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library
|
#include <../../../../hardware/pic32/libraries/SPI/SPI.h> // Hack to use the SPI library
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* SETTINGS_H */
|
#endif /* SETTINGS_H */
|
||||||
|
|
20
usb_ch9.h
20
usb_ch9.h
|
@ -60,17 +60,17 @@ e-mail : support@circuitsathome.com
|
||||||
|
|
||||||
/* USB descriptors */
|
/* USB descriptors */
|
||||||
|
|
||||||
#define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor.
|
#define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor.
|
||||||
#define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor.
|
#define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor.
|
||||||
#define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor.
|
#define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor.
|
||||||
#define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor.
|
#define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor.
|
||||||
#define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor.
|
#define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor.
|
||||||
#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier.
|
#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier.
|
||||||
#define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration.
|
#define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration.
|
||||||
#define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power.
|
#define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power.
|
||||||
#define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor.
|
#define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor.
|
||||||
|
|
||||||
#define HID_DESCRIPTOR_HID 0x21
|
#define HID_DESCRIPTOR_HID 0x21
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -253,9 +253,9 @@ uint8_t USBHub::CheckHubStatus() {
|
||||||
// rcode = GetHubStatus(1, 0, 1, 4, buf);
|
// rcode = GetHubStatus(1, 0, 1, 4, buf);
|
||||||
// if (rcode)
|
// if (rcode)
|
||||||
// {
|
// {
|
||||||
// USB_HOST_SERIAL.print("GetHubStatus Error");
|
// USB_HOST_SERIAL.print("GetHubStatus Error");
|
||||||
// USB_HOST_SERIAL.println(rcode, HEX);
|
// USB_HOST_SERIAL.println(rcode, HEX);
|
||||||
// return rcode;
|
// return rcode;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
for(uint8_t port = 1, mask = 0x02; port < 8; mask <<= 1, port++) {
|
for(uint8_t port = 1, mask = 0x02; port < 8; mask <<= 1, port++) {
|
||||||
|
|
74
usbhub.h
74
usbhub.h
|
@ -19,7 +19,7 @@ e-mail : support@circuitsathome.com
|
||||||
|
|
||||||
#include "Usb.h"
|
#include "Usb.h"
|
||||||
|
|
||||||
#define USB_DESCRIPTOR_HUB 0x09 // Hub descriptor type
|
#define USB_DESCRIPTOR_HUB 0x09 // Hub descriptor type
|
||||||
|
|
||||||
// Hub Requests
|
// Hub Requests
|
||||||
#define bmREQ_CLEAR_HUB_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE
|
#define bmREQ_CLEAR_HUB_FEATURE USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_DEVICE
|
||||||
|
@ -73,62 +73,62 @@ e-mail : support@circuitsathome.com
|
||||||
#define HUB_PORT_INDICATOR_OFF 3
|
#define HUB_PORT_INDICATOR_OFF 3
|
||||||
|
|
||||||
// Hub Port Status Bitmasks
|
// Hub Port Status Bitmasks
|
||||||
#define bmHUB_PORT_STATUS_PORT_CONNECTION 0x0001
|
#define bmHUB_PORT_STATUS_PORT_CONNECTION 0x0001
|
||||||
#define bmHUB_PORT_STATUS_PORT_ENABLE 0x0002
|
#define bmHUB_PORT_STATUS_PORT_ENABLE 0x0002
|
||||||
#define bmHUB_PORT_STATUS_PORT_SUSPEND 0x0004
|
#define bmHUB_PORT_STATUS_PORT_SUSPEND 0x0004
|
||||||
#define bmHUB_PORT_STATUS_PORT_OVER_CURRENT 0x0008
|
#define bmHUB_PORT_STATUS_PORT_OVER_CURRENT 0x0008
|
||||||
#define bmHUB_PORT_STATUS_PORT_RESET 0x0010
|
#define bmHUB_PORT_STATUS_PORT_RESET 0x0010
|
||||||
#define bmHUB_PORT_STATUS_PORT_POWER 0x0100
|
#define bmHUB_PORT_STATUS_PORT_POWER 0x0100
|
||||||
#define bmHUB_PORT_STATUS_PORT_LOW_SPEED 0x0200
|
#define bmHUB_PORT_STATUS_PORT_LOW_SPEED 0x0200
|
||||||
#define bmHUB_PORT_STATUS_PORT_HIGH_SPEED 0x0400
|
#define bmHUB_PORT_STATUS_PORT_HIGH_SPEED 0x0400
|
||||||
#define bmHUB_PORT_STATUS_PORT_TEST 0x0800
|
#define bmHUB_PORT_STATUS_PORT_TEST 0x0800
|
||||||
#define bmHUB_PORT_STATUS_PORT_INDICATOR 0x1000
|
#define bmHUB_PORT_STATUS_PORT_INDICATOR 0x1000
|
||||||
|
|
||||||
// Hub Port Status Change Bitmasks (used one byte instead of two)
|
// Hub Port Status Change Bitmasks (used one byte instead of two)
|
||||||
#define bmHUB_PORT_STATUS_C_PORT_CONNECTION 0x0001
|
#define bmHUB_PORT_STATUS_C_PORT_CONNECTION 0x0001
|
||||||
#define bmHUB_PORT_STATUS_C_PORT_ENABLE 0x0002
|
#define bmHUB_PORT_STATUS_C_PORT_ENABLE 0x0002
|
||||||
#define bmHUB_PORT_STATUS_C_PORT_SUSPEND 0x0004
|
#define bmHUB_PORT_STATUS_C_PORT_SUSPEND 0x0004
|
||||||
#define bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT 0x0008
|
#define bmHUB_PORT_STATUS_C_PORT_OVER_CURRENT 0x0008
|
||||||
#define bmHUB_PORT_STATUS_C_PORT_RESET 0x0010
|
#define bmHUB_PORT_STATUS_C_PORT_RESET 0x0010
|
||||||
|
|
||||||
// Hub Status Bitmasks (used one byte instead of two)
|
// Hub Status Bitmasks (used one byte instead of two)
|
||||||
#define bmHUB_STATUS_LOCAL_POWER_SOURCE 0x01
|
#define bmHUB_STATUS_LOCAL_POWER_SOURCE 0x01
|
||||||
#define bmHUB_STATUS_OVER_CURRENT 0x12
|
#define bmHUB_STATUS_OVER_CURRENT 0x12
|
||||||
|
|
||||||
// Hub Status Change Bitmasks (used one byte instead of two)
|
// Hub Status Change Bitmasks (used one byte instead of two)
|
||||||
#define bmHUB_STATUS_C_LOCAL_POWER_SOURCE 0x01
|
#define bmHUB_STATUS_C_LOCAL_POWER_SOURCE 0x01
|
||||||
#define bmHUB_STATUS_C_OVER_CURRENT 0x12
|
#define bmHUB_STATUS_C_OVER_CURRENT 0x12
|
||||||
|
|
||||||
|
|
||||||
// Hub Port Configuring Substates
|
// Hub Port Configuring Substates
|
||||||
#define USB_STATE_HUB_PORT_CONFIGURING 0xb0
|
#define USB_STATE_HUB_PORT_CONFIGURING 0xb0
|
||||||
#define USB_STATE_HUB_PORT_POWERED_OFF 0xb1
|
#define USB_STATE_HUB_PORT_POWERED_OFF 0xb1
|
||||||
#define USB_STATE_HUB_PORT_WAIT_FOR_POWER_GOOD 0xb2
|
#define USB_STATE_HUB_PORT_WAIT_FOR_POWER_GOOD 0xb2
|
||||||
#define USB_STATE_HUB_PORT_DISCONNECTED 0xb3
|
#define USB_STATE_HUB_PORT_DISCONNECTED 0xb3
|
||||||
#define USB_STATE_HUB_PORT_DISABLED 0xb4
|
#define USB_STATE_HUB_PORT_DISABLED 0xb4
|
||||||
#define USB_STATE_HUB_PORT_RESETTING 0xb5
|
#define USB_STATE_HUB_PORT_RESETTING 0xb5
|
||||||
#define USB_STATE_HUB_PORT_ENABLED 0xb6
|
#define USB_STATE_HUB_PORT_ENABLED 0xb6
|
||||||
|
|
||||||
// Additional Error Codes
|
// Additional Error Codes
|
||||||
#define HUB_ERROR_PORT_HAS_BEEN_RESET 0xb1
|
#define HUB_ERROR_PORT_HAS_BEEN_RESET 0xb1
|
||||||
|
|
||||||
// The bit mask to check for all necessary state bits
|
// The bit mask to check for all necessary state bits
|
||||||
#define bmHUB_PORT_STATUS_ALL_MAIN ((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION | bmHUB_PORT_STATUS_C_PORT_ENABLE | bmHUB_PORT_STATUS_C_PORT_SUSPEND | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_SUSPEND)
|
#define bmHUB_PORT_STATUS_ALL_MAIN ((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION | bmHUB_PORT_STATUS_C_PORT_ENABLE | bmHUB_PORT_STATUS_C_PORT_SUSPEND | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_SUSPEND)
|
||||||
|
|
||||||
// Bit mask to check for DISABLED state in HubEvent::bmStatus field
|
// Bit mask to check for DISABLED state in HubEvent::bmStatus field
|
||||||
#define bmHUB_PORT_STATE_CHECK_DISABLED (0x0000 | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_SUSPEND)
|
#define bmHUB_PORT_STATE_CHECK_DISABLED (0x0000 | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_SUSPEND)
|
||||||
|
|
||||||
// Hub Port States
|
// Hub Port States
|
||||||
#define bmHUB_PORT_STATE_DISABLED (0x0000 | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION)
|
#define bmHUB_PORT_STATE_DISABLED (0x0000 | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION)
|
||||||
|
|
||||||
// Hub Port Events
|
// Hub Port Events
|
||||||
#define bmHUB_PORT_EVENT_CONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION)
|
#define bmHUB_PORT_EVENT_CONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION)
|
||||||
#define bmHUB_PORT_EVENT_DISCONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER)
|
#define bmHUB_PORT_EVENT_DISCONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER)
|
||||||
#define bmHUB_PORT_EVENT_RESET_COMPLETE (((0UL | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION)
|
#define bmHUB_PORT_EVENT_RESET_COMPLETE (((0UL | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION)
|
||||||
|
|
||||||
#define bmHUB_PORT_EVENT_LS_CONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED)
|
#define bmHUB_PORT_EVENT_LS_CONNECT (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED)
|
||||||
#define bmHUB_PORT_EVENT_LS_RESET_COMPLETE (((0UL | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED)
|
#define bmHUB_PORT_EVENT_LS_RESET_COMPLETE (((0UL | bmHUB_PORT_STATUS_C_PORT_RESET) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED)
|
||||||
#define bmHUB_PORT_EVENT_LS_PORT_ENABLED (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION | bmHUB_PORT_STATUS_C_PORT_ENABLE) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED)
|
#define bmHUB_PORT_EVENT_LS_PORT_ENABLED (((0UL | bmHUB_PORT_STATUS_C_PORT_CONNECTION | bmHUB_PORT_STATUS_C_PORT_ENABLE) << 16) | bmHUB_PORT_STATUS_PORT_POWER | bmHUB_PORT_STATUS_PORT_ENABLE | bmHUB_PORT_STATUS_PORT_CONNECTION | bmHUB_PORT_STATUS_PORT_LOW_SPEED)
|
||||||
|
|
||||||
struct HubDescriptor {
|
struct HubDescriptor {
|
||||||
uint8_t bDescLength; // descriptor length
|
uint8_t bDescLength; // descriptor length
|
||||||
|
|
Loading…
Reference in a new issue