-
Notifications
You must be signed in to change notification settings - Fork 1
USB Protocol
Command Byte | ||||||
---|---|---|---|---|---|---|
Group | Command Type | 0 | 1 | 2 | 3 | 4 |
Capture/Control | Capture |
Command 0x00 |
Flash Power 0x00 - 0xff |
Expected Size Low 0x00 - 0xff |
... 0x00 - 0xff |
Expected Size High 0x00 - 0xff |
Slave Capture Rising |
Command 0x01 |
Flash Power 0x00 - 0xff |
Expected Size Low 0x00 - 0xff |
... 0x00 - 0xff |
Expected Size High 0x00 - 0xff |
|
Reset |
Command 0x02 |
Level 0x00 - 0x01 |
Null 0x00 |
Null 0x00 |
Null 0x00 |
|
Flush |
Command 0x03 |
Null 0x00 |
Null 0x00 |
Null 0x00 |
Null 0x00 |
|
Master Capture |
Command 0x04 |
Flash Power 0x00 - 0xff |
Expected Size Low 0x00 - 0xff |
... 0x00 - 0xff |
Expected Size High 0x00 - 0xff |
|
Slave Capture Falling |
Command 0x05 |
Flash Power 0x00 - 0xff |
Expected Size Low 0x00 - 0xff |
... 0x00 - 0xff |
Expected Size High 0x00 - 0xff |
|
Registers | Write Register |
Command 0x10 |
Address Low 0x00 - 0xff |
Address High 0x00 - 0xff |
Value Low 0x00 - 0xff |
Value High 0x00 - 0xff |
Write Bit |
Command 0x11 |
Address Low 0x00 - 0xff |
Address High 0x00 - 0xff |
Bit Index 0x00 - 0x0f |
Bit Value 0x00 - 0x01 |
|
Queue Register |
Command 0x12 |
Address Low 0x00 - 0xff |
Address High 0x00 - 0xff |
Null 0x00 |
Null 0x00 |
|
Read Register Page |
Command 0x13 |
Page Index 0x00 - 0xff |
Null 0x00 |
Null 0x00 |
Null 0x00 |
|
I/O | Write Device |
Command 0x20 |
Index 0x00 - 0xff |
Value 0x00 - 0xff |
Null 0x00 |
Null 0x00 |
Queue Device |
Command 0x21 |
Index 0x00 - 0xff |
Null 0x00 |
Null 0x00 |
Null 0x00 |
|
Initialise Device |
Command 0x22 |
Index 0x00 - 0xff |
Configuration 0x00 - 0xff |
Null 0x00 |
Null 0x00 |
|
Write Block |
Command 0x23 |
Index 0x00 - 0xff |
Length Low 0x00 - 0xff |
... 0x00 - 0xff |
Length High 0x00 - 0xff |
|
Read Block |
Command 0x24 |
Index 0x00 - 0xff |
Maximum Length Low 0x00 - 0xff |
... 0x00 - 0xff |
Maximum Length High 0x00 - 0xff |
|
Channel |
Command 0x25 |
Index 0x00 - 0xff |
Mode 0x00 - 0x01 |
Channel Low 0x00 - 0xff |
Channel High 0x00 - 0xff |
|
Query |
Command 0x2f |
Index 0x00 - 0xff |
Null 0x00 |
Null 0x00 |
Null 0x00 |
Header | Control (0..1) | Commands (0..N) | Terminator | ||
---|---|---|---|---|---|
Description | Null | Capture/Slave/Reset/Flush | Write/Queue/Initialise | ... | 0xff |
Size (bytes) | 5 | 5 | 5 | ... | 1 |
If the command is a "Write Block" then the bytes that follow it are not a 5-byte command block but instead raw data to be written to the device index specified. The length of the raw data is declared in the command.
Header | Registers (0..N) | Devices (0..N) | ||||||
---|---|---|---|---|---|---|---|---|
Description | Register count | Address | Data | ... | Index | Length | Data | ... |
Size (bytes) | 1 | 2 | 2 | ... | 1 | 2 | 0 - 65k | ... |
Description | Image data |
---|---|
Size (bytes) | 0 - 16M |
Description | Page of registers |
---|---|
Size (bytes) | 512 |
Unlike other data packets in the protocol, the values in the page are high-low byte order and not low-high.
The reset command 0x02 can trigger different levels of reset:
0x00: Full chip reset
0x01: Communication buffers reset
Device 0xff can be used to query the camera. The layout for the response is as follows:
Header | Devices | ||||
---|---|---|---|---|---|
Description | Header size | Header Data | Device count | Index | ... |
Size (bytes) | 1 | 0-255 | 1 | 1 | ... |
If the device flush response is empty (i.e., 0x00 0xff 0x00 0x00) then the default chip configuration and devices are assumed.
When querying the device, the header data will contain the following information and can be extended for future use by simply increasing the header size (up to a maximum of 255 bytes).
0: Chip type -> 0x00 (v024), 0x01 (mt9)
1: Configuration -> bitmask (see below)
Configuration Bitmask
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
Description | Flash mode | Reserved | Reserved | Reserved | Reserved | Reserved | Reserved | Bayer |
A device can have multiple channels and the command 0x25
is used to select which channel to target for configuration, reading and writing.
A mode of 0x00
simply queries the current channel and a mode of 0x01
sets the channel to the supplied index.
Either function will result in the following response from the camera.
0: Channel low
1: Channel high
2: Type ID low
3: Type ID high
Where channel is the current channel and type ID indicates the type of device on that channel.
This allows you to have, for example, a single device index representing temperature sensors. The device then has multiple temperature sensors represented as different channels. Some of the temperature sensors may vary from others and the type ID allows the software to determine which type it is and therefore know how it should communicate with it.
Sending a query command 0x2f
will return the following structure.
0: Index -> which device was queried
1: Functionality low -> bitmask indicating which device functions are supported 0x20 - 0x2f
2: Functionality high
3: Channel low -> number of available channels
4: Channel high
5: Reserved 0 -> reserved register for future use
6: Reserved 1
7: Reserved 2
8: Reserved 3
9: Status 0 -> status flag registers
10: Status 1
11: Status 2
12: Status 3
Channels are always zero-indexed and contiguous, so the last channel available is always N - 1.