|Shopping Cart Checkout Shipping Cost Download Website|
|Home||MP3 Player||8051 Tools||All Projects||PJRC Store||Site Map|
|You are here: Teensy Reference HalfKay Protocol|
HalfKay Communication ProtocolTthis section, together with the command line source code, serves to document the communication protocol used by HalfKay.
HalfKay uses only 2 very simple commands. Both are USB control transfers which also correspond to a HID output report.
Write Block CommandTo write a 128 byte block, simply send this 130 byte control transfer. The first 2 bytes are the address, which should be aligned to a 128 byte block boundry.
buf = addr & 255; buf = (addr >> 8) & 255; ihex_get_data(addr, 128, buf + 2); usb_control_msg(handle, 0x21, 9, 0x0200, 0, (char *)buf, 130, first_block ? 3000 : 200);
HalfKay always preforms a complete erase of all blocks when it receives the first write command. A timeout of 3 seconds should be allowed during the first write, through the erase operation typically takes less than 1 second. All other writes can use a timeout of 0.2 seconds.
Reboot CommandTo reboot the AVR processor, simply send HalfKay a write command to address 0xFFFF. The 128 data bytes are ignored.
buf = 0xFF; buf = 0xFF; memset(buf + 2, 0, sizeof(buf) - 2); usb_control_msg(handle, 0x21, 9, 0x0200, 0, (char *)buf, 130, 200);
On Linux and Macintosh, this command will typically return a failure result, because the AVR processor executes the command very rapidly and the operating system quickly detects the device is no longer attached. On Windows, the return result is less consistent.