mirror of
https://github.com/gdsports/USBHost_t36
synced 2024-11-24 01:52:23 -05:00
Device status functions must treat device pointer as volatile
This commit is contained in:
parent
ef1452ad84
commit
8f09965162
@ -381,21 +381,34 @@ protected:
|
|||||||
// All USB device drivers inherit from this base class.
|
// All USB device drivers inherit from this base class.
|
||||||
class USBDriver : public USBHost {
|
class USBDriver : public USBHost {
|
||||||
public:
|
public:
|
||||||
operator bool() { return (device != nullptr); }
|
//operator bool() { return (*(Device_t * volatile *)&device != nullptr); }
|
||||||
uint16_t idVendor() { return (device != nullptr) ? device->idVendor : 0; }
|
operator bool() {
|
||||||
uint16_t idProduct() { return (device != nullptr) ? device->idProduct : 0; }
|
Device_t *dev = *(Device_t * volatile *)&device;
|
||||||
|
return dev != nullptr;
|
||||||
const uint8_t *manufacturer()
|
}
|
||||||
{ return ((device == nullptr) || (device->strbuf == nullptr)) ? nullptr : &device->strbuf->buffer[device->strbuf->iStrings[strbuf_t::STR_ID_MAN]]; }
|
uint16_t idVendor() {
|
||||||
const uint8_t *product()
|
Device_t *dev = *(Device_t * volatile *)&device;
|
||||||
{ return ((device == nullptr) || (device->strbuf == nullptr)) ? nullptr : &device->strbuf->buffer[device->strbuf->iStrings[strbuf_t::STR_ID_PROD]]; }
|
return (device != nullptr) ? device->idVendor : 0;
|
||||||
const uint8_t *serialNumber()
|
}
|
||||||
{ return ((device == nullptr) || (device->strbuf == nullptr)) ? nullptr : &device->strbuf->buffer[device->strbuf->iStrings[strbuf_t::STR_ID_SERIAL]]; }
|
uint16_t idProduct() {
|
||||||
|
Device_t *dev = *(Device_t * volatile *)&device;
|
||||||
// TODO: user-level functions
|
return (device != nullptr) ? device->idProduct : 0;
|
||||||
// check if device is bound/active/online
|
}
|
||||||
// query vid, pid
|
const uint8_t *manufacturer() {
|
||||||
// query string: manufacturer, product, serial number
|
Device_t *dev = *(Device_t * volatile *)&device;
|
||||||
|
if (dev == nullptr || dev->strbuf == nullptr) return nullptr;
|
||||||
|
return &dev->strbuf->buffer[dev->strbuf->iStrings[strbuf_t::STR_ID_MAN]];
|
||||||
|
}
|
||||||
|
const uint8_t *product() {
|
||||||
|
Device_t *dev = *(Device_t * volatile *)&device;
|
||||||
|
if (dev == nullptr || dev->strbuf == nullptr) return nullptr;
|
||||||
|
return &dev->strbuf->buffer[dev->strbuf->iStrings[strbuf_t::STR_ID_PROD]];
|
||||||
|
}
|
||||||
|
const uint8_t *serialNumber() {
|
||||||
|
Device_t *dev = *(Device_t * volatile *)&device;
|
||||||
|
if (dev == nullptr || dev->strbuf == nullptr) return nullptr;
|
||||||
|
return &dev->strbuf->buffer[dev->strbuf->iStrings[strbuf_t::STR_ID_SERIAL]];
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
USBDriver() : next(NULL), device(NULL) {}
|
USBDriver() : next(NULL), device(NULL) {}
|
||||||
// Check if a driver wishes to claim a device or interface or group
|
// Check if a driver wishes to claim a device or interface or group
|
||||||
|
Loading…
Reference in New Issue
Block a user