-
Notifications
You must be signed in to change notification settings - Fork 1
/
USB_PROTOCOL
92 lines (71 loc) · 3.36 KB
/
USB_PROTOCOL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
========== FlexFloppy ===========
USB Multi-pupose Floppy Interface
=================================
FlexFloppy is a USB device, identified by vendor 0x1209 and product 0xAFDD.
The device utilizes 3 endpoints:
* EP 0x00 (for setup and commands)
* EP 0x01 (bulk endpoint for data streamed out to the device)
* EP 0x82 (bulk endpoint for data streamed in to the PC)
Initialization
==============
A standard USB initialization process will reset the device, assign an address
and enable configuration 1. This is the only supported configuration, and will
enable all other functions.
Commands
========
All commands are send to EP0 as control transfers with bmRequestType=0x41 and
wIndex=0. bRequest contains a command code (listed below) and wValue contains
the parameter for the command.
bRequest | wValue | Description
------------------------------------------------------------------------------
0x00 | 0x00 | Enable drive and motor
0x01 | 0x00 | Disable drive and motor
0x11 | 0x00 | Return the head to track zero
0x12 | track | Select a track to read/write and seek head
0x21 | revs | Read the current track for the given number of revolutions
0x22 | 0x00 | Write the current track
Reading data
============
After command 0x21 is initiated, the device will wait until the next index
pulse. As soon as this occurs, data will begin streaming to to EP 0x82. The
read will finish after the requested number of revolutions have completed as
detected by subsequet index pulses.
The stream will consist of three transfers:
* Flux timing data.
A continuous stream of 16-bit timing values. Values increment continuously
and wrap at 65536. An increment of one represents a single 40MHz period.
* Index timing data.
A fixed length transfer of 512 bytes consisting of 64 x 8-byte index timing
entries. Each entry contains a 32-bit timestamp (number of 40MHz cycles since
pulse 0), followed by a data offset (the number of flux timing data since the
start of the stream). The number of useful entries will be "revs + 1".
* Status
A 2-byte status code:
0x0001 = Success
0x0002 = Buffer overrun
0x0003 = Timeout (index pulses not detected)
It is essential that the host receives data as fast as possible, as buffer
space it limited and the read operation cannot be paused if the host is
blocking. If the buffer becomes full, the transfer will end with status code
0x0002 which must be considered an error state.
Writing data
============
After command 0x22 is initiated, the device will start receiving data on
EP 0x01. The stream of data should consist of a single transfer of many
16-bit (40MHz) delta timing values. The transfer should end with a 16-bit
value of 0x0000.
A buffer will be filled then writing will begin on the next index pulse.
Writing will end when the last timing value has been processed or the
next index pulse occurs, whichever occurs first.
After the transfer has completed, a 2-byte status code will be returned on
EP 0x82.
* Status
A 2-byte status code:
0x0001 = Success
0x0002 = Buffer underrun
0x0003 = Timeout (index pulse not detected) (**)
It is essential that the host sends data as fast as possible, as buffer
space it limited and the write operation cannot be paused if the host is
blocking. If the buffer becomes empty, the transfer will end with status
code 0x0002 which must be considered an error state.
(**) NOT IMPLEMENTED YET