My progress so far is slow and I was wondering if anybody has done something similar and has some examples to share?
What I have managed so far is to have Windows detect my BluePill as a "HID UPS Battery" by using the USBHID class and creating a simple ReportDescriptor:
Code: Select all
#define HID_POWER_DEVICE_REPORT_DESCRIPTOR \
0x05, 0x84, /* USAGE_PAGE (Power Device)*/ \
0x09, 0x04, /* USAGE (UPS)*/ \
0xa1, 0x01, /* COLLECTION (Application)*/ \
0x09, 0x1e, /* USAGE (Flow)*/ \
0xa1, 0x02, /* COLLECTION (Logical)*/ \
0x85, 0x01, /* REPORT_ID (1)*/ \
0x09, 0x1f, /* USAGE (FlowID)*/ \
0x75, 0x04, /* REPORT_SIZE (4)*/ \
0x95, 0x01, /* REPORT_COUNT (1)*/ \
0x15, 0x00, /* LOGICAL_MINIMUM (0)*/ \
0x25, 0x0f, /* LOGICAL_MAXIMUM (15)*/ \
0xb1, 0x03, /* FEATURE (Cnst,Var,Abs)*/ \
0x75, 0x04, /* REPORT_SIZE (4)*/ \
0x95, 0x01, /* REPORT_COUNT (1)*/ \
0xb1, 0x03, /* FEATURE (Cnst,Var,Abs)*/ \
0x09, 0x01, /* USAGE (iName)*/ \
0x75, 0x08, /* REPORT_SIZE (8)*/ \
0x95, 0x01, /* REPORT_COUNT (1)*/ \
0x15, 0x00, /* LOGICAL_MINIMUM (0)*/ \
0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255)*/ \
0xb1, 0x03, /* FEATURE (Cnst,Var,Abs)*/ \
0x09, 0x40, /* USAGE (ConfigVoltage)*/ \
0x75, 0x08, /* REPORT_SIZE (8)*/ \
0x95, 0x01, /* REPORT_COUNT (1)*/ \
0x67, 0x21, 0xd1, 0xf0, 0x00, /* UNIT (SI Lin:Volts)*/ \
0x55, 0x07, /* UNIT_EXPONENT (7)*/ \
0x15, 0x00, /* LOGICAL_MINIMUM (0)*/ \
0x26, 0xfa, 0x00, /* LOGICAL_MAXIMUM (250)*/ \
0xb1, 0x03, /* FEATURE (Cnst,Var,Abs)*/ \
0x09, 0x42, /* USAGE (ConfigFrequency)*/ \
0x75, 0x08, /* REPORT_SIZE (8)*/ \
0x95, 0x01, /* REPORT_COUNT (1)*/ \
0x66, 0x01, 0xf0, /* UNIT (SI Lin:Hertz)*/ \
0x55, 0x00, /* UNIT_EXPONENT (0)*/ \
0x15, 0x00, /* LOGICAL_MINIMUM (0)*/ \
0x25, 0x3c, /* LOGICAL_MAXIMUM (60)*/ \
0xb1, 0x03, /* FEATURE (Cnst,Var,Abs)*/ \
0x65, 0x00, /* UNIT (None)*/ \
0xc0, /* END_COLLECTION*/ \
0xc0 /* END_COLLECTION*/
Code: Select all
sendReport();
Not sure if it's relevant but in the HID v1.11 documentation they also mention "Only Input reports are sent via the Interrupt In pipe. Feature and Output reports must be initiated by the host via the Control pipe or an optional Interrupt Out pipe."
If anybody has some ideas or suggestions that would be great?