lophtware

Logo

lophtware projects

GitHub Profile

I2C - Master Configuration

Report Type: IN / OUT
Report Size: 27 Bytes
Acknowledged By: Command Acknowledgement

Report ID Unlock Key Baud Rate Flags Baud Rate LSB Baud Rate MSB Address ACK Timeout Flags Address ACK Timeout LSB Address ACK Timeout MSB Slave Data ACK Timeout Flags Slave Data ACK Timeout LSB Slave Data ACK Timeout MSB Slave Data In Timeout Flags Slave Data In Timeout LSB Slave Data In Timeout MSB Master Data ACK Timeout Flags Master Data ACK Timeout LSB Master Data ACK Timeout MSB Collision Stop Bit Timeout Flags Collision Stop Bit Timeout LSB Collision Stop Bit Timeout MSB
0000011 I 8 bytes u i 000000 bbbbbbbb bbbbbbbb u i 000000 aaaaaaaa aaaaaaaa u i 000000 ssssssss ssssssss u i 000000 dddddddd dddddddd u i 000000 mmmmmmmm mmmmmmmm u i 000000 cccccccc cccccccc

Report ID

HID Report ID. Always 0x06 for OUT Reports.

IN Reports can use the I flag to indicate whether the Host should receive the immediate values of the Master peripheral (when I is 1) or whether the Host should receive the configuration settings (when I is 0).

Unlock Key

An 8-byte key that is used to prevent accidental changes to certain configuration values. If the supplied key does not match the stored key then this report is ignored.

For IN Reports the field is set as all zeroes.

Common Flags

These flags are common across multiple fields and have the same semantics for each:

Bits Direction Meaning
u OUT Update the field; 1 if the field is to be updated, 0 if no change is to be made (any supplied values will be ignored). For IN Reports this will be set to 0.
i OUT Immediate update; 1 if an update is to be applied immediately, 0 if the change will be stored in the configuration to be applied later. Note that no configuration changes are persisted until Store Current Configuration is issued. This flag makes no sense if u is 0, so will be ignored. For IN Reports this will be set to 0.

Baud Rate

This field is the value given to the I2C Baud Rate Generator and directly specifies the spacing of the bits put onto the bus. The desired value can be in the range [11, 65535] (values outside this range will be clamped) and is calculated from three parameters - Pulse Gobbler Delay, Peripheral Clock Frequency and I2C Clock (SCL) Frequency - which are discussed below.

This field is Little Endian, ie. the Least Significant Byte of the word appears first. Bit numbering within the constituent bytes is unaffected.

Pulse Gobbler Delay, Tpgd (ns)

The Pulse Gobbler Delay, Tpgd, is a datasheet parameter given in nanoseconds. It varies significantly over process, voltage and temperature:

Min Typ Max
52 104 312

Peripheral Clock Frequency, Fpc (MHz)

The Peripheral Clock Frequency, Fpc, is the input clock to the I2C Baud Rate Generator and is derived from the internal RC oscillator. The datasheet specifies a variation of +/- 2% over process, voltage and temperature, although when locked to the USB Frame Packets the variation can be as little as +/- 0.2%:

Min Typ Max
23.52 24.00 24.48

I2C Clock Frequency, SCL (kHz)

The frequency of the SCL line is dictated by the slowest device on the bus, the amount of capacitance on the bus and the pull-up resistors (nominal 3.3k). The formulae for determining the SCL Frequency range, in kHz, are given in the table below:

SCL Frequency, kHz Formula
Minimum 1000 * Fpcmin / ((2 * Baud Rate) + 2 + (Fpcmin * 0.001 * Tpgdmax))
Typical 1000 * Fpctyp / ((2 * Baud Rate) + 2 + (Fpctyp * 0.001 * Tpgdtyp))
Maximum 1000 * Fpcmax / ((2 * Baud Rate) + 2 + (Fpcmax * 0.001 * Tpgdmin))

Some sample Baud Rate values for 100kHz and 400kHz SCL frequencies have been calculated for convenience:

Baud Rate Minimum (kHz) Typical (kHz) Maximum SCL (kHz)
121 93.579 97.365 99.807
118 95.868 99.794 102.310
113 99.941 104.123 106.772
29 349.281 384.025 399.524
28 359.973 396.720 413.005
25 396.372 440.399 459.520

Address ACK Timeout

The number of ‘ticks’ (10ms intervals) to wait for a slave to ACK or NACK the address. Normally slaves can respond immediately but it is possible for them to stretch the clock. This value includes the address bit times as well as the ACK bit, so if Baud Rate is a low frequency this needs to be taken into account. Valid values for the timeout are in the range [0, 65535] where a 0 indicates that there is no timeout.

This field is Little Endian, ie. the Least Significant Byte of the word appears first. Bit numbering within the constituent bytes is unaffected.

Slave Data ACK Timeout

The number of ‘ticks’ (10ms intervals) to wait for a slave to ACK or NACK its data byte. This value includes the data bit times as well as the ACK bit, so if Baud Rate is a low frequency this needs to be taken into account. Valid values for the timeout are in the range [0, 65535] where a 0 indicates that there is no timeout.

This field is Little Endian, ie. the Least Significant Byte of the word appears first. Bit numbering within the constituent bytes is unaffected.

Slave Data In Timeout

The number of ‘ticks’ (10ms intervals) that the master will wait to receive a slave’s data byte. If Baud Rate is a low frequency this needs to be taken into account when selecting an appropriate length of time. Valid values for the timeout are in the range [0, 65535] where a 0 indicates that there is no timeout.

This field is Little Endian, ie. the Least Significant Byte of the word appears first. Bit numbering within the constituent bytes is unaffected.

Master Data ACK Timeout

The number of ‘ticks’ (10ms intervals) that the master will wait after sending its ACK or NACK. Ordinarily this can be a low value but it is possible that the slave is stretching the clock. Valid values for the timeout are in the range [0, 65535] where a 0 indicates that there is no timeout.

This field is Little Endian, ie. the Least Significant Byte of the word appears first. Bit numbering within the constituent bytes is unaffected.

Collision Stop Bit Timeout

The number of ‘ticks’ (10ms intervals) that the master will wait between events whilst looking for another master to send its Stop Bit. This condition occurs when there is a bus collision. If the timeout occurs then the transmission will be abandoned and the next one will be attempted when the bus becomes free. Valid values for the timeout are in the range [0, 65535] where a 0 indicates that there is no timeout.

This field is Little Endian, ie. the Least Significant Byte of the word appears first. Bit numbering within the constituent bytes is unaffected.