Skip to content
Snippets Groups Projects
Commit 5592d15a authored by Micah Elizabeth Scott's avatar Micah Elizabeth Scott
Browse files

Frame rate benchmarking tool

parent 3e411789
No related branches found
No related tags found
No related merge requests found
......@@ -162,6 +162,14 @@ Byte Offset | Bits | Description
1 | 0 | Disable dithering
2 … 63 | 7 … 0 | (reserved)
In addition to the OUT endpoint, the device also supports vendor-specific control requests:
bmRequestType | bRequest | wValue | wIndex | wLength | Description
------------- | -------- | ------ | ------ | ------- | ---------------------------------------------
0xC0 | 0x01 | 0 | 0 | 4 | Read frame counter (32-bit, little endian)
0xC0 | 0x7E | x | 4 | x | Read Microsoft WCID descriptor
0xC0 | 0x7E | x | 5 | x | Read Microsoft Extended Properties descriptor
Contact
-------
......
......@@ -499,6 +499,9 @@ extern "C" int main()
for (unsigned i = 0; i < CHANNELS_TOTAL; ++i)
residual[i] = 0;
}
// Performance counter, for monitoring frame rate externally
perf_frameCounter++;
}
// Reboot into DFU bootloader
......
......@@ -55,6 +55,9 @@ uint16_t usb_rx_byte_count_data[NUM_ENDPOINTS];
static uint8_t reply_buffer[8];
// Performance counters
volatile uint32_t perf_frameCounter;
static uint8_t tx_state[NUM_ENDPOINTS];
#define TX_STATE_BOTH_FREE_EVEN_FIRST 0
#define TX_STATE_BOTH_FREE_ODD_FIRST 1
......@@ -302,6 +305,12 @@ static void usb_setup(void)
endpoint0_stall();
return;
case 0x01C0: // Read frame counter
case 0x01C1:
data = (uint8_t*) &perf_frameCounter;
datalen = sizeof perf_frameCounter;
break;
case (MSFT_VENDOR_CODE << 8) | 0xC0: // Get Microsoft descriptor
case (MSFT_VENDOR_CODE << 8) | 0xC1:
if (setup.wIndex == 0x0004) {
......
......@@ -59,6 +59,9 @@ extern volatile uint8_t usb_dfu_state;
#define DFU_appIDLE 0
#define DFU_appDETACH 1
// Performance counters
extern volatile uint32_t perf_frameCounter;
extern uint16_t usb_rx_byte_count_data[NUM_ENDPOINTS];
static inline uint32_t usb_rx_byte_count(uint32_t endpoint) __attribute__((always_inline));
static inline uint32_t usb_rx_byte_count(uint32_t endpoint)
......
#!/usr/bin/env python
#
# Read the device's performance counters, calculate benchmark values.
#
# Micah Elizabeth Scott
# This example code is released into the public domain.
#
import usb.core
import usb.util
import time, struct, sys
dev = usb.core.find(idVendor=0x1d50, idProduct=0x607a)
if not dev:
raise IOError("No Fadecandy interfaces found")
dev.set_configuration()
print "Serial number: %s" % usb.util.get_string(dev, 255, dev.iSerialNumber)
def readFrameCounter():
return struct.unpack('<I', dev.ctrl_transfer(0xC0, 0x01, 0, 0, 4, 1000))[0]
sys.stderr.write("Calculating frame rate average...\n")
t1 = time.time()
c1 = readFrameCounter()
try:
while True:
time.sleep(0.1)
t2 = time.time()
c2 = readFrameCounter()
fps = ((c2 - c1) & 0xFFFFFFFF) / (t2 - t1)
sys.stderr.write("\r %.3f FPS " % fps)
except KeyboardInterrupt:
sys.stderr.write("\n")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment