Merge pull request #979 from jeremybrodt/usbcallbacks

USB - Add macros to alias the endpoint callback functions to support configurability
pull/1022/head
Martin Kojtal 2015-04-08 08:38:31 +02:00
commit 158cbeb292
17 changed files with 46 additions and 16 deletions

View File

@ -119,7 +119,7 @@ float USBAudio::getVolume() {
} }
bool USBAudio::EP3_OUT_callback() { bool USBAudio::EPISO_OUT_callback() {
uint32_t size = 0; uint32_t size = 0;
interruptOUT = true; interruptOUT = true;
if (buf_stream_in != NULL) { if (buf_stream_in != NULL) {
@ -132,7 +132,7 @@ bool USBAudio::EP3_OUT_callback() {
} }
bool USBAudio::EP3_IN_callback() { bool USBAudio::EPISO_IN_callback() {
interruptIN = true; interruptIN = true;
writeIN = true; writeIN = true;
return true; return true;

View File

@ -216,12 +216,12 @@ protected:
/* /*
* Callback called when a packet is received * Callback called when a packet is received
*/ */
virtual bool EP3_OUT_callback(); virtual bool EPISO_OUT_callback();
/* /*
* Callback called when a packet has been sent * Callback called when a packet has been sent
*/ */
virtual bool EP3_IN_callback(); virtual bool EPISO_IN_callback();
private: private:

View File

@ -81,12 +81,18 @@
/* Bulk endpoints */ /* Bulk endpoints */
#define EPBULK_OUT (EP2OUT) #define EPBULK_OUT (EP2OUT)
#define EPBULK_IN (EP2IN) #define EPBULK_IN (EP2IN)
#define EPBULK_OUT_callback EP2_OUT_callback
#define EPBULK_IN_callback EP2_IN_callback
/* Interrupt endpoints */ /* Interrupt endpoints */
#define EPINT_OUT (EP1OUT) #define EPINT_OUT (EP1OUT)
#define EPINT_IN (EP1IN) #define EPINT_IN (EP1IN)
#define EPINT_OUT_callback EP1_OUT_callback
#define EPINT_IN_callback EP1_IN_callback
/* Isochronous endpoints */ /* Isochronous endpoints */
#define EPISO_OUT (EP3OUT) #define EPISO_OUT (EP3OUT)
#define EPISO_IN (EP3IN) #define EPISO_IN (EP3IN)
#define EPISO_OUT_callback EP3_OUT_callback
#define EPISO_IN_callback EP3_IN_callback
#define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2) #define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2)
#define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1) #define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1)

View File

@ -53,12 +53,18 @@
/* Bulk endpoint */ /* Bulk endpoint */
#define EPBULK_OUT (EP2OUT) #define EPBULK_OUT (EP2OUT)
#define EPBULK_IN (EP2IN) #define EPBULK_IN (EP2IN)
#define EPBULK_OUT_callback EP2_OUT_callback
#define EPBULK_IN_callback EP2_IN_callback
/* Interrupt endpoint */ /* Interrupt endpoint */
#define EPINT_OUT (EP1OUT) #define EPINT_OUT (EP1OUT)
#define EPINT_IN (EP1IN) #define EPINT_IN (EP1IN)
#define EPINT_OUT_callback EP1_OUT_callback
#define EPINT_IN_callback EP1_IN_callback
/* Isochronous endpoint */ /* Isochronous endpoint */
#define EPISO_OUT (EP3OUT) #define EPISO_OUT (EP3OUT)
#define EPISO_IN (EP3IN) #define EPISO_IN (EP3IN)
#define EPISO_OUT_callback EP3_OUT_callback
#define EPISO_IN_callback EP3_IN_callback
#define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2) #define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2)
#define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1) #define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1)

View File

@ -81,12 +81,18 @@
/* Bulk endpoints */ /* Bulk endpoints */
#define EPBULK_OUT (EP2OUT) #define EPBULK_OUT (EP2OUT)
#define EPBULK_IN (EP2IN) #define EPBULK_IN (EP2IN)
#define EPBULK_OUT_callback EP2_OUT_callback
#define EPBULK_IN_callback EP2_IN_callback
/* Interrupt endpoints */ /* Interrupt endpoints */
#define EPINT_OUT (EP1OUT) #define EPINT_OUT (EP1OUT)
#define EPINT_IN (EP1IN) #define EPINT_IN (EP1IN)
#define EPINT_OUT_callback EP1_OUT_callback
#define EPINT_IN_callback EP1_IN_callback
/* Isochronous endpoints */ /* Isochronous endpoints */
#define EPISO_OUT (EP3OUT) #define EPISO_OUT (EP3OUT)
#define EPISO_IN (EP3IN) #define EPISO_IN (EP3IN)
#define EPISO_OUT_callback EP3_OUT_callback
#define EPISO_IN_callback EP3_IN_callback
#define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2) #define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2)
#define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1) #define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1)

View File

@ -65,12 +65,18 @@
/* Bulk endpoints */ /* Bulk endpoints */
#define EPBULK_OUT (EP2OUT) #define EPBULK_OUT (EP2OUT)
#define EPBULK_IN (EP2IN) #define EPBULK_IN (EP2IN)
#define EPBULK_OUT_callback EP2_OUT_callback
#define EPBULK_IN_callback EP2_IN_callback
/* Interrupt endpoints */ /* Interrupt endpoints */
#define EPINT_OUT (EP1OUT) #define EPINT_OUT (EP1OUT)
#define EPINT_IN (EP1IN) #define EPINT_IN (EP1IN)
#define EPINT_OUT_callback EP1_OUT_callback
#define EPINT_IN_callback EP1_IN_callback
/* Isochronous endpoints */ /* Isochronous endpoints */
#define EPISO_OUT (EP3OUT) #define EPISO_OUT (EP3OUT)
#define EPISO_IN (EP3IN) #define EPISO_IN (EP3IN)
#define EPISO_OUT_callback EP3_OUT_callback
#define EPISO_IN_callback EP3_IN_callback
#define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2) #define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2)
#define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1) #define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1)

View File

@ -49,12 +49,18 @@
/* Bulk endpoint */ /* Bulk endpoint */
#define EPBULK_OUT (EP2OUT) #define EPBULK_OUT (EP2OUT)
#define EPBULK_IN (EP2IN) #define EPBULK_IN (EP2IN)
#define EPBULK_OUT_callback EP2_OUT_callback
#define EPBULK_IN_callback EP2_IN_callback
/* Interrupt endpoint */ /* Interrupt endpoint */
#define EPINT_OUT (EP1OUT) #define EPINT_OUT (EP1OUT)
#define EPINT_IN (EP1IN) #define EPINT_IN (EP1IN)
#define EPINT_OUT_callback EP1_OUT_callback
#define EPINT_IN_callback EP1_IN_callback
/* Isochronous endpoint */ /* Isochronous endpoint */
#define EPISO_OUT (EP3OUT) #define EPISO_OUT (EP3OUT)
#define EPISO_IN (EP3IN) #define EPISO_IN (EP3IN)
#define EPISO_OUT_callback EP3_OUT_callback
#define EPISO_IN_callback EP3_IN_callback
#define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2) #define MAX_PACKET_SIZE_EPBULK (MAX_PACKET_SIZE_EP2)
#define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1) #define MAX_PACKET_SIZE_EPINT (MAX_PACKET_SIZE_EP1)

View File

@ -420,7 +420,7 @@ uint8_t * USBKeyboard::reportDesc() {
} }
bool USBKeyboard::EP1_OUT_callback() { bool USBKeyboard::EPINT_OUT_callback() {
uint32_t bytesRead = 0; uint32_t bytesRead = 0;
uint8_t led[65]; uint8_t led[65];
USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE); USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE);

View File

@ -150,7 +150,7 @@ public:
* *
* @returns if handle by subclass, return true * @returns if handle by subclass, return true
*/ */
virtual bool EP1_OUT_callback(); virtual bool EPINT_OUT_callback();
/** /**
* Read status of lock keys. Useful to switch-on/off leds according to key pressed. Only the first three bits of the result is important: * Read status of lock keys. Useful to switch-on/off leds according to key pressed. Only the first three bits of the result is important:

View File

@ -548,7 +548,7 @@ uint8_t * USBMouseKeyboard::reportDesc() {
return NULL; return NULL;
} }
bool USBMouseKeyboard::EP1_OUT_callback() { bool USBMouseKeyboard::EPINT_OUT_callback() {
uint32_t bytesRead = 0; uint32_t bytesRead = 0;
uint8_t led[65]; uint8_t led[65];
USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE); USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE);

View File

@ -202,7 +202,7 @@ class USBMouseKeyboard: public USBHID, public Stream
* *
* @returns if handle by subclass, return true * @returns if handle by subclass, return true
*/ */
virtual bool EP1_OUT_callback(); virtual bool EPINT_OUT_callback();
private: private:

View File

@ -35,7 +35,7 @@ void USBMIDI::attach(void (*fptr)(MIDIMessage)) {
} }
bool USBMIDI::EP2_OUT_callback() { bool USBMIDI::EPBULK_OUT_callback() {
uint8_t buf[64]; uint8_t buf[64];
uint32_t len; uint32_t len;
readEP(EPBULK_OUT, buf, &len, 64); readEP(EPBULK_OUT, buf, &len, 64);

View File

@ -78,7 +78,7 @@ public:
protected: protected:
virtual bool EP2_OUT_callback(); virtual bool EPBULK_OUT_callback();
virtual bool USBCallback_setConfiguration(uint8_t configuration); virtual bool USBCallback_setConfiguration(uint8_t configuration);
/* /*
* Get string product descriptor * Get string product descriptor

View File

@ -147,7 +147,7 @@ void USBMSD::reset() {
// Called in ISR context called when a data is received // Called in ISR context called when a data is received
bool USBMSD::EP2_OUT_callback() { bool USBMSD::EPBULK_OUT_callback() {
uint32_t size = 0; uint32_t size = 0;
uint8_t buf[MAX_PACKET_SIZE_EPBULK]; uint8_t buf[MAX_PACKET_SIZE_EPBULK];
readEP(EPBULK_OUT, buf, &size, MAX_PACKET_SIZE_EPBULK); readEP(EPBULK_OUT, buf, &size, MAX_PACKET_SIZE_EPBULK);
@ -184,7 +184,7 @@ bool USBMSD::EP2_OUT_callback() {
} }
// Called in ISR context when a data has been transferred // Called in ISR context when a data has been transferred
bool USBMSD::EP2_IN_callback() { bool USBMSD::EPBULK_IN_callback() {
switch (stage) { switch (stage) {
// the device has to send data to the host // the device has to send data to the host

View File

@ -158,12 +158,12 @@ protected:
/* /*
* Callback called when a packet is received * Callback called when a packet is received
*/ */
virtual bool EP2_OUT_callback(); virtual bool EPBULK_OUT_callback();
/* /*
* Callback called when a packet has been sent * Callback called when a packet has been sent
*/ */
virtual bool EP2_IN_callback(); virtual bool EPBULK_IN_callback();
/* /*
* Set configuration of device. Add endpoints * Set configuration of device. Add endpoints

View File

@ -46,7 +46,7 @@ bool USBSerial::writeBlock(uint8_t * buf, uint16_t size) {
bool USBSerial::EP2_OUT_callback() { bool USBSerial::EPBULK_OUT_callback() {
uint8_t c[65]; uint8_t c[65];
uint32_t size = 0; uint32_t size = 0;

View File

@ -145,7 +145,7 @@ public:
} }
protected: protected:
virtual bool EP2_OUT_callback(); virtual bool EPBULK_OUT_callback();
virtual void lineCodingChanged(int baud, int bits, int parity, int stop){ virtual void lineCodingChanged(int baud, int bits, int parity, int stop){
if (settingsChangedCallback) { if (settingsChangedCallback) {
settingsChangedCallback(baud, bits, parity, stop); settingsChangedCallback(baud, bits, parity, stop);