mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Merge branch 'master' of github.com:felis/USB_Host_Shield_2.0
This commit is contained in:
commit
e73a684b46
14 changed files with 120 additions and 32 deletions
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_HIDOUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, 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_HIDOUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
14
PS3USB.cpp
Normal file → Executable file
14
PS3USB.cpp
Normal file → Executable file
|
@ -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_HIDOUT, HID_REQUEST_SET_REPORT, 0x01, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, 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_HIDOUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, 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_HIDIN, HID_REQUEST_GET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, 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_HIDOUT, HID_REQUEST_SET_REPORT, 0xF4, 0x03, 0x00, 4, 4, cmd_buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, 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_HIDOUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, 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_HIDIN, HID_REQUEST_GET_REPORT, 0x04, 0x03, 0x00, 16, 16, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, 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_HIDIN, HID_REQUEST_GET_REPORT, 0x10, 0x03, 0x00, 49, 49, buf, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_IN, 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];
|
||||||
|
|
|
@ -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_HIDOUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[0].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
||||||
};
|
};
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
|
|
|
@ -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_HIDOUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[XBOX_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, 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) {
|
||||||
|
|
|
@ -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_HIDOUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
pUsb->ctrlReq(bAddress, epInfo[XBOX_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XBOXUSB::setLedRaw(uint8_t value) {
|
void XBOXUSB::setLedRaw(uint8_t value) {
|
||||||
|
|
79
avrpins.h
79
avrpins.h
|
@ -672,10 +672,19 @@ public:
|
||||||
// http://balanduino.net/
|
// http://balanduino.net/
|
||||||
#define P0 Pd0 /* 0 - PD0 */
|
#define P0 Pd0 /* 0 - PD0 */
|
||||||
#define P1 Pd1 /* 1 - PD1 */
|
#define P1 Pd1 /* 1 - PD1 */
|
||||||
#define P2 Pb2 /* 2 - PB2 */
|
|
||||||
#define P3 Pd6 /* 3 - PD6 */
|
#if BALANDUINO_REVISION < 13
|
||||||
#define P4 Pd7 /* 4 - PD7 */
|
#define P2 Pb2 /* 2 - PB2 */
|
||||||
#define P5 Pb3 /* 5 - PB3 */
|
#define P3 Pd6 /* 3 - PD6 */
|
||||||
|
#define P4 Pd7 /* 4 - PD7 */
|
||||||
|
#define P5 Pb3 /* 5 - PB3 */
|
||||||
|
#else
|
||||||
|
#define P2 Pd2 /* 2 - PD2 */
|
||||||
|
#define P3 Pd3 /* 3 - PD3 */
|
||||||
|
#define P4 Pd6 /* 4 - PD6 */
|
||||||
|
#define P5 Pd7 /* 5 - PD7 */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define P6 Pb4 /* 6 - PB4 */
|
#define P6 Pb4 /* 6 - PB4 */
|
||||||
#define P7 Pa0 /* 7 - PA0 */
|
#define P7 Pa0 /* 7 - PA0 */
|
||||||
#define P8 Pa1 /* 8 - PA1 */
|
#define P8 Pa1 /* 8 - PA1 */
|
||||||
|
@ -685,8 +694,15 @@ public:
|
||||||
#define P12 Pa5 /* 12 - PA5 */
|
#define P12 Pa5 /* 12 - PA5 */
|
||||||
#define P13 Pc1 /* 13 - PC1 */
|
#define P13 Pc1 /* 13 - PC1 */
|
||||||
#define P14 Pc0 /* 14 - PC0 */
|
#define P14 Pc0 /* 14 - PC0 */
|
||||||
#define P15 Pd2 /* 15 - PD2 */
|
|
||||||
#define P16 Pd3 /* 16 - PD3 */
|
#if BALANDUINO_REVISION < 13
|
||||||
|
#define P15 Pd2 /* 15 - PD2 */
|
||||||
|
#define P16 Pd3 /* 16 - PD3 */
|
||||||
|
#else
|
||||||
|
#define P15 Pb2 /* 15 - PB2 */
|
||||||
|
#define P16 Pb3 /* 16 - PB2 */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define P17 Pd4 /* 17 - PD4 */
|
#define P17 Pd4 /* 17 - PD4 */
|
||||||
#define P18 Pd5 /* 18 - PD5 */
|
#define P18 Pd5 /* 18 - PD5 */
|
||||||
#define P19 Pc2 /* 19 - PC2 */
|
#define P19 Pc2 /* 19 - PC2 */
|
||||||
|
@ -945,6 +961,57 @@ MAKE_PIN(P78, PIOB, PIO_PB23); // Unconnected
|
||||||
|
|
||||||
#undef MAKE_PIN
|
#undef MAKE_PIN
|
||||||
|
|
||||||
|
#elif defined(RBL_NRF51822)
|
||||||
|
|
||||||
|
#define MAKE_PIN(className, pin) \
|
||||||
|
class className { \
|
||||||
|
public: \
|
||||||
|
static void Set() { \
|
||||||
|
nrf_gpio_pin_set(pin); \
|
||||||
|
} \
|
||||||
|
static void Clear() { \
|
||||||
|
nrf_gpio_pin_clear(pin); \
|
||||||
|
} \
|
||||||
|
static void SetDirRead() { \
|
||||||
|
nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL); \
|
||||||
|
} \
|
||||||
|
static void SetDirWrite() { \
|
||||||
|
nrf_gpio_cfg_output(pin); \
|
||||||
|
} \
|
||||||
|
static uint8_t IsSet() { \
|
||||||
|
return (uint8_t)nrf_gpio_pin_read(pin); \
|
||||||
|
} \
|
||||||
|
};
|
||||||
|
|
||||||
|
// See: pin_transform.c in RBL nRF51822 SDK
|
||||||
|
MAKE_PIN(P0, Pin_nRF51822_to_Arduino(D0));
|
||||||
|
MAKE_PIN(P1, Pin_nRF51822_to_Arduino(D1));
|
||||||
|
MAKE_PIN(P2, Pin_nRF51822_to_Arduino(D2));
|
||||||
|
MAKE_PIN(P3, Pin_nRF51822_to_Arduino(D3));
|
||||||
|
MAKE_PIN(P4, Pin_nRF51822_to_Arduino(D4));
|
||||||
|
MAKE_PIN(P5, Pin_nRF51822_to_Arduino(D5));
|
||||||
|
MAKE_PIN(P6, Pin_nRF51822_to_Arduino(D6));
|
||||||
|
MAKE_PIN(P7, Pin_nRF51822_to_Arduino(D7));
|
||||||
|
MAKE_PIN(P8, Pin_nRF51822_to_Arduino(D8));
|
||||||
|
MAKE_PIN(P9, Pin_nRF51822_to_Arduino(D9)); // INT
|
||||||
|
MAKE_PIN(P10, Pin_nRF51822_to_Arduino(D10)); // SS
|
||||||
|
MAKE_PIN(P11, Pin_nRF51822_to_Arduino(D11));
|
||||||
|
MAKE_PIN(P12, Pin_nRF51822_to_Arduino(D12));
|
||||||
|
MAKE_PIN(P13, Pin_nRF51822_to_Arduino(D13));
|
||||||
|
MAKE_PIN(P14, Pin_nRF51822_to_Arduino(D14));
|
||||||
|
MAKE_PIN(P15, Pin_nRF51822_to_Arduino(D15));
|
||||||
|
MAKE_PIN(P17, Pin_nRF51822_to_Arduino(D17)); // MISO
|
||||||
|
MAKE_PIN(P18, Pin_nRF51822_to_Arduino(D18)); // MOSI
|
||||||
|
MAKE_PIN(P16, Pin_nRF51822_to_Arduino(D16)); // CLK
|
||||||
|
MAKE_PIN(P19, Pin_nRF51822_to_Arduino(D19));
|
||||||
|
MAKE_PIN(P20, Pin_nRF51822_to_Arduino(D20));
|
||||||
|
MAKE_PIN(P21, Pin_nRF51822_to_Arduino(D21));
|
||||||
|
MAKE_PIN(P22, Pin_nRF51822_to_Arduino(D22));
|
||||||
|
MAKE_PIN(P23, Pin_nRF51822_to_Arduino(D23));
|
||||||
|
MAKE_PIN(P24, Pin_nRF51822_to_Arduino(D24));
|
||||||
|
|
||||||
|
#undef MAKE_PIN
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Please define board in avrpins.h"
|
#error "Please define board in avrpins.h"
|
||||||
|
|
||||||
|
|
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_HIDREPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00,
|
uint8_t rcode = pUsb->ctrlReq(bAddress, ep, bmREQ_HID_REPORT, 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_HIDREPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00,
|
uint8_t rcode = pUsb->ctrlReq(bAddress, 0x00, bmREQ_HID_REPORT, 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_HIDOUT, HID_REQUEST_SET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL));
|
return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HID_OUT, 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_HIDIN, HID_REQUEST_GET_REPORT, report_id, report_type, iface, nbytes, nbytes, dataptr, NULL));
|
return ( pUsb->ctrlReq(bAddress, ep, bmREQ_HID_IN, 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_HIDIN, HID_REQUEST_GET_IDLE, reportID, 0, iface, 0x0001, 0x0001, dataptr, NULL));
|
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_IN, 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_HIDOUT, HID_REQUEST_SET_IDLE, reportID, duration, iface, 0x0000, 0x0000, NULL, NULL));
|
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_OUT, 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_HIDOUT, HID_REQUEST_SET_PROTOCOL, protocol, 0x00, iface, 0x0000, 0x0000, NULL, NULL));
|
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_OUT, 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_HIDIN, HID_REQUEST_GET_PROTOCOL, 0x00, 0x00, iface, 0x0001, 0x0001, dataptr, NULL));
|
return ( pUsb->ctrlReq(bAddress, 0, bmREQ_HID_IN, 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) {
|
||||||
|
|
6
hid.h
6
hid.h
|
@ -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_HIDOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
#define bmREQ_HID_OUT USB_SETUP_HOST_TO_DEVICE|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_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
|
||||||
#define bmREQ_HIDREPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE
|
#define bmREQ_HID_REPORT 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 */
|
||||||
|
|
|
@ -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 && (mod & 2)) ||
|
if ((kbdLockingKeys.kbdLeds.bmCapsLock == 0 && shift) ||
|
||||||
(kbdLockingKeys.kbdLeds.bmCapsLock == 1 && (mod & 2) == 0))
|
(kbdLockingKeys.kbdLeds.bmCapsLock == 1 && shift == 0))
|
||||||
return (key - 4 + 'A');
|
return (key - 4 + 'A');
|
||||||
|
|
||||||
// Lower case letters
|
// Lower case letters
|
||||||
|
|
|
@ -232,6 +232,10 @@ 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);
|
||||||
|
|
|
@ -418,3 +418,8 @@ 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,6 +100,9 @@ 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__
|
||||||
|
|
|
@ -50,6 +50,13 @@ public:
|
||||||
SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz
|
SPI.setClockDivider(4); // Set speed to 84MHz/4=21MHz - the MAX3421E can handle up to 26MHz
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#elif defined(RBL_NRF51822)
|
||||||
|
static void init() {
|
||||||
|
SPI_SS::SetDirWrite();
|
||||||
|
SPI_SS::Set();
|
||||||
|
SPI.begin();
|
||||||
|
// SPI.setFrequency(SPI_FREQUENCY_8M);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
static void init() {
|
static void init() {
|
||||||
//uint8_t tmp;
|
//uint8_t tmp;
|
||||||
|
@ -78,6 +85,8 @@ typedef SPi< Pb7, Pb5, Pb6, Pb4 > spi;
|
||||||
typedef SPi< P13, P11, P12, P10 > spi;
|
typedef SPi< P13, P11, P12, P10 > spi;
|
||||||
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
#elif defined(ARDUINO_SAM_DUE) && defined(__SAM3X8E__)
|
||||||
typedef SPi< P76, P75, P74, P10 > spi;
|
typedef SPi< P76, P75, P74, P10 > spi;
|
||||||
|
#elif defined(RBL_NRF51822)
|
||||||
|
typedef SPi< P16, P18, P17, P10 > spi;
|
||||||
#elif defined(__MIPSEL__)
|
#elif defined(__MIPSEL__)
|
||||||
typedef SPi< P13, P11, P12, P10 > spi;
|
typedef SPi< P13, P11, P12, P10 > spi;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue