Attached to this article is a python 3 script to generate the I2C command arrays for a CP2114-B01 device, interfacing with a codec with 8-bit registers.

 

This script interprets the following commands to construct the command byte-array.

 

  • write(register, data) - writes a byte of data to the codec's register over I2C
  • delay_ms(delay) - delays the next command by delay milliseconds
  • delay_us(delay) - delays the next command by delay microseconds
  • reenumerate() - immediately reenumerates the CP2112 device
  • setGPIO(state, gpioNum) - sets the gpio gpioNum to state, where 1 = high, 0 = low

 

The commands may also start with one of the following tags:

 

  • SUSPEND_SEQUENCE - specifies that this is the start of the sequence of I2C commands that will be issued when the device enters suspend mode
  • ACTIVE_SEQUENCE - specifies that this is the start of the sequence of I2C commands that will be issued when the device wakes from suspend mode into active mode

If no tag begins the sequence, the device defaults to using this string as the initialization sequence of commands to be after reset, as long as this is the first sequence after the 30-byte configuration string.

 

Note - only one sequence can be generated at a time with this script. If all three sequences are needed, they will need to be generated individually, then appended together into one large byte array, with the reset sequence being first.

 

Here is an example image of the script running:

 

b01_8bit.png

 

The left panel is the 'input' field, where commands are typed. The right panel is the 'output' field, where the byte array is generated. The byte array is refreshed any time return/enter are pressed in the input field.

 

The bottom panel is for any errors that may arise.

 

As an example, this is the input text required to generate a reset configuration for the CS42L55 codec:

 

setGPIO(0, 4)
delay_us(0xFF)
delay_us(0xFF)
delay_us(0xFF)
delay_us(0xFF)
setGPIO(1, 4)
delay_us(0x01)
write(0x00, 0x99)
write(0x2E, 0x30)
write(0x32, 0x07)
write(0x33, 0xFD)
write(0x34, 0xF8)
write(0x35, 0xDC)
write(0x36, 0xF8)
write(0x37, 0x6C)
write(0x3A, 0xF8)
write(0x3C, 0xD3)
write(0x3D, 0x23)
write(0x3E, 0x81)
write(0x3F, 0x46)
write(0x00, 0x00)
write(0x04, 0x02)
write(0x05, 0x09)
write(0x1A, 0xC4)
write(0x1B, 0xC4)
write(0x1C, 0xC4)
write(0x1D, 0xC4)
write(0x02, 0x08)
delay_us(0xFF)
delay_us(0xFF)
delay_us(0xFF)
write(0x03, 0x00)
write(0x06, 0x20)
write(0x2A, 0x00)

 

 

This generates the following binary array:

 

FE 04 FD FF FD FF FD FF FD FF FE 84 FD 01 00 99 2E 30 32 07 33 FD 34 F8 
35 DC 36 F8 37 6C 3A F8 3C D3 3D 23 3E 81 3F 46 00 00 04 02 05 09 1A C4
1B C4 1C C4 1D C4 02 08 FD FF FD FF FD FF 03 00 06 20 2A 00

 

 

  • USB Bridges
  • Knowledge Base Articles
  • Interface