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 16-bit registers.


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


  • write(register, valueMSB, valueLSB) - writes two byte of data, MSB first, 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:




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 WM8523 codec:


write(0x02, 0x00, 0x01)
write(0x02, 0x00, 0x02)
write(0x02, 0x00, 0x03)
write(0x05, 0x00, 0x0F)
write(0x06, 0x00, 0x01)
write(0x07, 0x00, 0x01)
write(0x03, 0x18, 0x11)



This generates the following binary array:


02 00 01 02 00 02 02 00 03 05 00 0F 06 00 01 07 00 01 03 18 11



  • USB Bridges
  • Knowledge Base Articles
  • Interface