mcp2221
index
/Users/vpaeder/Projects/pymcp2221/mcp2221/__init__.py

A driver for the Microchip MCP2221/MCP2221A USB 2.0 to I2C/UART
protocol converters, together with helper functions and classes.
 
   Classes:
       MCP2221
   
   Functions:
       find_devices
   
   Submodules:
       enums
       exceptions

 
Package Contents
       
enums
exceptions

 
Classes
       
builtins.object
MCP2221

 
class MCP2221(builtins.object)
    MCP2221(dev_descriptor: dict = None, password: str = '')
 
A driver for the Microchip MCP2221/MCP2221A
USB 2.0 to I2C/UART protocol converters
 
Attributes:
    i2c_speed(I2CSpeed): enum code for I2C transfer speed
    default_memory_target(MemoryType): default memory target
    cdc_sn_enumeration_enable_flag(bool): CDC serial number enumeration enable flag
    led_idle_uart_rx_level(bool): UART RX LED idle signal level
    led_idle_uart_tx_level(bool): UART TX LED idle signal level
    led_idle_i2c_level(bool): I2C LED idle signal level
    suspend_mode_logic_level(bool): suspend mode signal level
    usb_configured_logic_level(bool): level of 'USB configured' signal
    security_option(SecurityOption): chip security option
    clock_output_frequency(ClockFrequency): clock output frequency
    clock_output_duty_cycle(ClockDutyCycle): clock output duty cycle
    usb_vid(int): USB vendor ID
    usb_pid(int): USB product ID
    usb_self_powered_attribute(bool): USB self-powered attribute
    usb_remote_wake_up_attribute(bool): USB remote wake-up attribute
    usb_current(int): USB current in enumeration phase, in mA
    usb_manufacturer_descriptor(str): USB manufacturer descriptor
    usb_product_descriptor(str): USB product descriptor
    usb_serial_number_descriptor(str): USB serial number descriptor
    chip_factory_serial_number(str): chip factory serial number
    password(str): flash access password (set only)
    interrupt_on_falling_edge(bool): interrupt on falling edge flag
    interrupt_on_rising_edge(bool): interrupt on rising edge flag
    interrupt_flag(bool): interrupt occurred flag
    gpio0_powerup_value(bool): GPIO pin 0 power-up value
    gpio1_powerup_value(bool): GPIO pin 1 power-up value
    gpio2_powerup_value(bool): GPIO pin 2 power-up value
    gpio3_powerup_value(bool): GPIO pin 3 power-up value
    gpio0_powerup_direction(GPIODirection): GPIO pin 0 power-up direction
    gpio1_powerup_direction(GPIODirection): GPIO pin 1 power-up direction
    gpio2_powerup_direction(GPIODirection): GPIO pin 2 power-up direction
    gpio3_powerup_direction(GPIODirection): GPIO pin 3 power-up direction
    gpio0_function(GPIO0Function): GPIO pin 0 function
    gpio1_function(GPIO1Function): GPIO pin 1 function
    gpio2_function(GPIO2Function): GPIO pin 2 function
    gpio3_function(GPIO3Function): GPIO pin 3 function
    gpio0_direction(GPIODirection): GPIO pin 0 direction
    gpio1_direction(GPIODirection): GPIO pin 1 direction
    gpio2_direction(GPIODirection): GPIO pin 2 direction
    gpio3_direction(GPIODirection): GPIO pin 3 direction
    gpio0_value(bool): GPIO pin 0 value
    gpio1_value(bool): GPIO pin 1 value
    gpio2_value(bool): GPIO pin 2 value
    gpio3_value(bool): GPIO pin 3 value
    adc_reference_voltage(ReferenceVoltageValue): ADC reference voltage settings
    adc_reference_source(ReferenceVoltageSource): ADC reference voltage source
    dac_reference_voltage(ReferenceVoltageValue): DAC reference voltage settings
    dac_reference_source(ReferenceVoltageSource): DAC reference voltage source
    dac_powerup_value(int): DAC power-up value
    adc0_value(int): ADC 0 value (read-only)
    adc1_value(int): ADC 1 value (read-only)
    adc2_value(int): ADC 2 value (read-only)
    dac_value(int): DAC value (write-only, 5 bit)
 
Protected attributes:
    _opened(bool): True if associated device is opened, False otherwise
    _password(str): password string
    _mem_target(MemoryType): default memory target for data both in flash and SRAM
 
  Methods defined here:
__init__(self, dev_descriptor: dict = None, password: str = '')
Class constructor.
 
Parameters:
    dev_descriptor(dict): the device descriptor to open device from.
                          Use find_devices to obtain one. (default None)
    password(str): 8 byte password to modify flash content (default "")
 
Note:
    If dev_descriptor is provided, device is opened automatically. If you
    don't want this to happen, provide no descriptor and use open() method
    at a later time.
clear_interrupt_flag(self) -> None
Clears the interrupt flag.
close(self)
Closes access to associated device.
get_default_memory_target(self) -> mcp2221.enums.MemoryType
Gets default memory target.
 
Returns:
    MemoryType: enum code for memory type.
gpio0_read_function(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.GPIO0Function
Reads GPIO pin 0 function.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    GPIO0Function: enum code for GPIO pin 0 function.
gpio0_write_function(self, value: mcp2221.enums.GPIO0Function, mem: mcp2221.enums.MemoryType = None) -> None
Writes GPIO pin 0 function.
 
Parameters:
    value(GPIO0Function): enum code for GPIO pin 0 function.
    mem(MemoryType): enum code for memory type (flash or SRAM)
gpio1_read_function(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.GPIO1Function
Reads GPIO pin 1 function.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    GPIO1Function: enum code for GPIO pin 1 function.
gpio1_write_function(self, value: mcp2221.enums.GPIO1Function, mem: mcp2221.enums.MemoryType = None) -> None
Writes GPIO pin 1 function.
 
Parameters:
    value(GPIO1Function): enum code for GPIO pin 1 function.
    mem(MemoryType): enum code for memory type (flash or SRAM)
gpio2_read_function(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.GPIO2Function
Reads GPIO pin 2 function.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    GPIO2Function: enum code for GPIO pin 2 function.
gpio2_write_function(self, value: mcp2221.enums.GPIO2Function, mem: mcp2221.enums.MemoryType = None) -> None
Writes GPIO pin 2 function.
 
Parameters:
    value(GPIO2Function): enum code for GPIO pin 2 function.
    mem(MemoryType): enum code for memory type (flash or SRAM)
gpio3_read_function(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.GPIO3Function
Reads GPIO pin 3 function.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    GPIO3Function: enum code for GPIO pin 3 function.
gpio3_write_function(self, value: mcp2221.enums.GPIO3Function, mem: mcp2221.enums.MemoryType = None) -> None
Writes GPIO pin 3 function.
 
Parameters:
    value(GPIO3Function): enum code for GPIO pin 3 function.
    mem(MemoryType): enum code for memory type (flash or SRAM)
gpio_read_direction(self, pin: int) -> mcp2221.enums.GPIODirection
Reads GPIO pin direction.
 
Parameters:
    pin(int): GPIO pin index
 
Returns:
    GPIODirection: GPIO pin direction code.
gpio_read_powerup_direction(self, gpio_num: int) -> mcp2221.enums.GPIODirection
Reads GPIO pin power-up direction from flash memory.
 
Parameters:
    gpio_num(int): GPIO pin index
 
Returns:
    GPIODirection: pin power-up direction code.
gpio_read_powerup_value(self, gpio_num: int) -> bool
Reads GPIO pin power-up value from flash memory.
 
Parameters:
    gpio_num(int): GPIO pin index
 
Returns:
    bool: pin power-up value.
gpio_read_value(self, pin: int) -> bool
Gets GPIO pin value.
 
Parameters:
    pin(int): GPIO pin index
 
Returns:
    bool: GPIO pin value.
gpio_write_direction(self, pin: int, mode: mcp2221.enums.GPIODirection) -> None
Writes GPIO pin direction.
 
Parameters:
    pin(int): GPIO pin index
    mode(GPIODirection): GPIO pin direction code
gpio_write_powerup_direction(self, gpio_num: int, value: mcp2221.enums.GPIODirection) -> None
Writes GPIO pin power-up direction to flash memory.
 
Parameters:
    gpio_num(int): GPIO pin index
    value(GPIODirection): pin power-up direction code
gpio_write_powerup_value(self, gpio_num: int, value: bool) -> None
Writes GPIO pin power-up value to flash memory.
 
Parameters:
    gpio_num(int): GPIO pin index
    value(bool): pin power-up value
gpio_write_value(self, pin: int, value: bool) -> None
Sets GPIO pin direction.
 
Parameters:
    pin(int): GPIO pin index
    value(bool): GPIO pin value
i2c_cancel_transfer(self) -> mcp2221.enums.I2CCancelTransferResponse
Cancel pending I2C transfer.
 
Returns:
    I2CCancelTransferResponse: response code returned by device.
i2c_has_pending_value(self) -> int
Tells if I2C bus has pending data to be read.
 
Returns:
    int: 0 for no, 1 for yes and 2 for irrelevant?.
i2c_read_data(self, address: bytes, length: int, i2c_mode: mcp2221.enums.I2CMode = <I2CMode.Start: 144>) -> bytearray
Reads data from given I2C address.
 
Parameters:
    address(bytes): 7-bit I2C slave address
    length(int): amount of data to read
    i2c_mode(I2CMode): enum code for I2C mode
 
Returns:
    bytearray: data read from I2C slave.
i2c_read_speed(self) -> mcp2221.enums.I2CSpeed
Read configured I2C speed.
 
Returns:
    I2CSpeed: enum code describing current I2C speed.
i2c_write_data(self, address: bytes, data: str, i2c_mode: mcp2221.enums.I2CMode = <I2CMode.Start: 144>) -> None
Writes data to given I2C address.
 
Parameters:
    address(bytes): 7-bit I2C slave address
    data(str): data string
    i2c_mode(I2CMode): enum code for I2C mode
i2c_write_speed(self, speed: mcp2221.enums.I2CSpeed) -> mcp2221.enums.I2CSetSpeedResponse
Write I2C speed to flash memory.
 
Parameters:
    speed (I2CSpeed): enum code describing I2C speed
 
Returns:
    I2CSetSpeedResponse: response code returned by device.
open(self, dev_descriptor: dict) -> bool
Opens device with given descriptor.
 
Parameters:
    dev_descriptor(dict): the device descriptor to open device from.
                          Use find_devices to obtain one.
 
Returns:
    bool: True if device could be opened, False otherwise.
read_adc(self, idx: int) -> int
Reads ADC value.
 
Parameters:
    idx(int): ADC index
 
Raises:
    InvalidParameterException: if ADC index is below 0 or above 2
 
Returns:
    int: ADC value.
read_adc_reference_source(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.ReferenceVoltageSource
Reads ADC reference flag.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    ReferenceVoltageSource: enum code for reference voltage source.
read_adc_reference_voltage(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.ReferenceVoltageValue
Reads ADC reference voltage settings.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    ReferenceVoltageValue: enum code for reference voltage settings.
read_cdc_sn_enumeration_enable(self) -> bool
Reads CDC serial number enumeration enable bit from flash memory.
 
Returns:
    bool: value of CDC serial number enumeration enable bit.
read_chip_factory_serial_number(self) -> str
Reads chip factory serial number from flash memory.
 
Returns:
    str: USB chip factory serial number.
read_clock_output_duty_cycle(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.ClockDutyCycle
Reads clock output duty cycle. This is the duty cycle of clock output
signal if directed to GPIO pin 1.
 
Parameters:
    mem(MemoryType): memory to read from (default SRAM)
 
Returns:
    ClockDutyCycle: enum code for clock duty cycle.
read_clock_output_frequency(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.ClockFrequency
Reads clock output frequency. This is the frequency of clock output
signal if directed to GPIO pin 1.
 
Parameters:
    mem(MemoryType): memory to read from (default SRAM)
 
Returns:
    ClockFrequency: enum code for clock output frequency.
read_dac_powerup_value(self) -> int
Reads DAC power-up value from flash memory.
 
Returns:
    int: DAC power-up value.
read_dac_reference_source(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.ReferenceVoltageSource
Reads DAC reference flag.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    ReferenceVoltageSource: enum code for reference voltage source.
read_dac_reference_voltage(self, mem: mcp2221.enums.MemoryType = None) -> mcp2221.enums.ReferenceVoltageValue
Reads DAC reference voltage settings.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    ReferenceVoltageValue: enum code for reference voltage settings.
read_firmware_version(self) -> str
Reads chip firmware version.
 
Returns:
    str: chip firmware version string.
read_interrupt_flag(self) -> bool
Reads flag telling whether an interrupt occurred.
 
Returns:
    bool: if True, an interrupt has occurred.
read_interrupt_on_falling_edge(self, mem: mcp2221.enums.MemoryType = None) -> bool
Reads interrupt on falling edge flag. This tells the state of interrupt
detection on falling edge.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    bool: value of interrupt on falling edge flag (True = active).
read_interrupt_on_rising_edge(self, mem: mcp2221.enums.MemoryType = None) -> bool
Reads interrupt on rising edge flag. This tells the state of interrupt
detection on rising edge.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    bool: value of interrupt on rising edge flag (True = active).
read_led_idle_i2c_level(self) -> bool
Reads idle level for I2C LED signal. This is the value given
to the I2C LED signal when no I2C transfer is ongoing.
 
Returns:
    bool: value of I2C LED idle signal level.
read_led_idle_uart_rx_level(self) -> bool
Reads idle level for UART RX LED signal. This is the value given
to the UART RX LED signal when no RX transfer is ongoing.
 
Returns:
    bool: value of UART RX LED idle signal level.
read_led_idle_uart_tx_level(self) -> bool
Reads idle level for UART TX LED signal. This is the value given
to the UART TX LED signal when no TX transfer is ongoing.
 
Returns:
    bool: value of UART TX LED idle signal level.
read_security_option(self) -> mcp2221.enums.SecurityOption
Reads chip security option.
 
Returns:
    SecurityOption: enum code for security option.
read_suspend_mode_logic_level(self) -> bool
Reads pin level for suspend mode signal. This is the value given
to the suspend mode signal when chip is NOT in suspend mode.
 
Returns:
    bool: value of suspend mode signal level.
read_usb_configured_logic_level(self) -> bool
Reads level for 'USB configured' signal. This is the value given
when USB enumeration is complete.
 
Returns:
    bool: level of 'USB configured' signal.
read_usb_current(self) -> int
Reads USB current value for enumeration phase, in mA.
 
Returns:
    int: value of USB current in enumeration phase, in mA.
read_usb_manufacturer_descriptor(self) -> str
Reads USB manufacturer descriptor from flash memory.
 
Returns:
    str: USB manufacturer descriptor string.
read_usb_pid(self) -> int
Reads USB product ID from flash memory.
 
Returns:
    int: USB product ID.
read_usb_product_descriptor(self) -> str
Reads USB product descriptor from flash memory.
 
Returns:
    str: USB product descriptor string.
read_usb_remote_wake_up_attribute(self) -> bool
Reads 'USB remote wake-up' attribute.
 
Returns:
    bool: value of 'USB remote wake-up' attribute.
read_usb_self_powered_attribute(self) -> bool
Reads 'USB self-powered' attribute.
 
Returns:
    bool: value of 'USB self-powered' attribute.
read_usb_serial_number_descriptor(self) -> str
Reads USB serial number descriptor from flash memory.
 
Returns:
    str: USB serial number descriptor string.
read_usb_vid(self) -> int
Reads USB vendor ID from flash memory.
 
Returns:
    int: USB vendor ID.
reset_chip(self) -> None
Resets chip.
set_default_memory_target(self, mem: mcp2221.enums.MemoryType) -> None
Sets default memory target.
 
Parameters:
    mem(MemoryType): enum code for memory type
unlock(self, value: str) -> None
Tries to unlock flash memory with given password.
 
Parameters:
    value(str): password string (max. 8 characters)
write_adc_reference_source(self, value: mcp2221.enums.ReferenceVoltageSource, mem: mcp2221.enums.MemoryType = None) -> None
Writes ADC reference flag.
 
Parameters:
    value(ReferenceVoltageSource): enum code for reference voltage source
    mem(MemoryType): enum code for memory type (flash or SRAM)
write_adc_reference_voltage(self, value: mcp2221.enums.ReferenceVoltageValue, mem: mcp2221.enums.MemoryType = None) -> None
Writes ADC reference voltage settings.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
    ReferenceVoltageValue: enum code for reference voltage settings
write_cdc_sn_enumeration_enable(self, value: bool) -> None
Writes CDC serial number enumeration enable bit to flash memory.
 
Parameters:
    value(bool): value to set
write_chip_factory_serial_number(self, value: str) -> None
Writes chip factory serial number to flash memory.
 
Parameters:
    value(str): chip factory serial number
write_clock_output_duty_cycle(self, value: mcp2221.enums.ClockDutyCycle, mem: mcp2221.enums.MemoryType = None) -> None
Writes clock output duty cycle. This is the duty cycle of clock output
signal if directed to GPIO pin 1.
 
Parameters:
    value(ClockDutyCycle): enum code for clock duty cycle
    mem(MemoryType): memory to write to (default SRAM)
write_clock_output_frequency(self, value: mcp2221.enums.ClockFrequency, mem: mcp2221.enums.MemoryType = None) -> None
Writes clock output frequency. This is the frequency of clock output
signal if directed to GPIO pin 1. It doesn't change internal clock frequency.
 
Parameters:
    value(ClockFrequency): enum code for clock output frequency
    mem(MemoryType): memory to write to (default SRAM)
write_dac(self, value: int) -> None
Writes DAC value.
 
Parameters:
    value(int): DAC value (5 bit)
write_dac_powerup_value(self, value: int) -> None
Writes DAC power-up value to flash memory.
 
Parameters:
    value(int): DAC power-up value
write_dac_reference_source(self, value: mcp2221.enums.ReferenceVoltageSource, mem: mcp2221.enums.MemoryType = None) -> None
Writes DAC reference flag.
 
Parameters:
    value(ReferenceVoltageSource): enum code for reference voltage source
    mem(MemoryType): enum code for memory type (flash or SRAM)
write_dac_reference_voltage(self, value: mcp2221.enums.ReferenceVoltageValue, mem: mcp2221.enums.MemoryType = None) -> None
Writes DAC reference voltage settings.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
    ReferenceVoltageValue: enum code for reference voltage settings
write_flash_access_password(self, value: str) -> None
Writes flash memory access password. To activate password protection,
set security option to SecurityOption.PasswordProtected.
 
Parameters:
    value(str): password string (max. 8 characters)
write_interrupt_on_falling_edge(self, value: bool, mem: mcp2221.enums.MemoryType = None) -> None
Writes interrupt on falling edge flag. This sets the state of interrupt
detection on falling edge.
 
Parameters:
    value(bool): value of interrupt on falling edge flag (True = active)
    mem(MemoryType): enum code for memory type (flash or SRAM)
write_interrupt_on_rising_edge(self, value: bool, mem: mcp2221.enums.MemoryType = None) -> None
Writes interrupt on rising edge flag. This sets the state of interrupt
detection on rising edge.
 
Parameters:
    value(bool): value of interrupt on rising edge flag (True = active)
    mem(MemoryType): enum code for memory type (flash or SRAM)
write_led_idle_i2c_level(self, value: bool) -> None
Writes idle level for I2C LED signal. This is the value given
to the I2C LED signal when no I2C transfer is ongoing.
 
Parameters:
    value(bool): value of I2C LED idle signal level
write_led_idle_uart_rx_level(self, value: bool) -> None
Writes idle level for UART RX LED signal. This is the value given
to the UART RX LED signal when no RX transfer is ongoing.
 
Parameters:
    value(bool): value of UART RX LED idle signal level
write_led_idle_uart_tx_level(self, value: bool) -> None
Writes idle level for UART TX LED signal. This is the value given
to the UART TX LED signal when no TX transfer is ongoing.
 
Parameters:
    value(bool): value of UART TX LED idle signal level
write_security_option(self, value: mcp2221.enums.SecurityOption) -> None
Writes chip security option.
!!!WARNING!!! If you choose SecurityOption.PermanentlyLocked,
it will make your chip permanently read-only.
 
Parameters:
    value(SecurityOption): enum code for security option
write_suspend_mode_logic_level(self, value: bool) -> None
Writes pin level for suspend mode signal. This is the value given
   to the suspend mode signal when chip is NOT in suspend mode.
 
Parameters:
    value(bool): value of suspend mode signal level
write_usb_configured_logic_level(self, value: bool) -> None
Writes level for 'USB configured' signal. This is the value given
when USB enumeration is complete.
 
Parameters:
    value(bool): level of 'USB configured' signal
write_usb_current(self, value: int) -> None
Writes USB current value for enumeration phase, in mA.
 
Parameters:
    value(int): value of USB current in enumeration phase, in mA
write_usb_manufacturer_descriptor(self, value: str) -> None
Writes USB manufacturer descriptor to flash memory.
 
Parameters:
    value(str): USB manufacturer descriptor string
write_usb_pid(self, value: int) -> None
Writes USB product ID to flash memory.
 
Parameters:
    value(int): USB product ID
write_usb_product_descriptor(self, value: str) -> None
Writes USB product descriptor to flash memory.
 
Parameters:
    value(str): USB product descriptor string
write_usb_remote_wake_up_attribute(self, value: bool) -> None
Writes 'USB remote wake-up' attribute.
 
Parameters:
    value(bool): value of 'USB remote wake-up' attribute
write_usb_self_powered_attribute(self, value: bool) -> None
Writes 'USB self-powered' attribute.
 
Parameters:
    value(bool): value of 'USB self-powered' attribute
write_usb_serial_number_descriptor(self, value: str) -> None
Writes USB serial number descriptor to flash memory.
 
Parameters:
    value(str): USB serial number descriptor string
write_usb_vid(self, value: int) -> None
Writes USB vendor ID to flash memory.
 
Parameters:
    value(int): USB vendor ID

Readonly properties defined here:
adc0_value
adc1_value
adc2_value
firmware_version
Reads chip firmware version.
 
Returns:
    str: chip firmware version string.
i2c_already_transferred_length
Reads the number of bytes that have already been transferred
in the current I2C command.
 
Returns:
    int: amount of already transferred I2C bytes.
i2c_internal_buffer_counter
Reads the value of the I2C internal buffer counter.
 
Returns:
    int: value of internal I2C buffer counter.
i2c_requested_transfer_length
Reads the number of bytes requested in the current I2C command.
 
Returns:
    int: requested I2C transfer length.
i2c_scl_state
Reads the I2C clock (SCL) line state.
 
Returns:
    bool: I2C clock line state.
i2c_sda_state
Reads the I2C data (SDA) line state.
 
Returns:
    bool: I2C data line state.
i2c_slave_address
Reads the I2C slave address being used.
 
Returns:
    int: I2C slave address being used.
interrupt_flag
Reads flag telling whether an interrupt occurred.
 
Returns:
    bool: if True, an interrupt has occurred.
opened
Tells if a device associated with this instance
is currently opened.
 
Returns:
    bool: True if a device is opened, False otherwise.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
adc_reference_source
Reads ADC reference flag.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    ReferenceVoltageSource: enum code for reference voltage source.
adc_reference_voltage
Reads ADC reference voltage settings.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    ReferenceVoltageValue: enum code for reference voltage settings.
cdc_sn_enumeration_enable_flag
Reads CDC serial number enumeration enable bit from flash memory.
 
Returns:
    bool: value of CDC serial number enumeration enable bit.
chip_factory_serial_number
Reads chip factory serial number from flash memory.
 
Returns:
    str: USB chip factory serial number.
clock_output_duty_cycle
Reads clock output duty cycle. This is the duty cycle of clock output
signal if directed to GPIO pin 1.
 
Parameters:
    mem(MemoryType): memory to read from (default SRAM)
 
Returns:
    ClockDutyCycle: enum code for clock duty cycle.
clock_output_frequency
Reads clock output frequency. This is the frequency of clock output
signal if directed to GPIO pin 1.
 
Parameters:
    mem(MemoryType): memory to read from (default SRAM)
 
Returns:
    ClockFrequency: enum code for clock output frequency.
dac_powerup_value
Reads DAC power-up value from flash memory.
 
Returns:
    int: DAC power-up value.
dac_reference_source
Reads DAC reference flag.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    ReferenceVoltageSource: enum code for reference voltage source.
dac_reference_voltage
Reads DAC reference voltage settings.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    ReferenceVoltageValue: enum code for reference voltage settings.
dac_value
default_memory_target
Gets default memory target.
 
Returns:
    MemoryType: enum code for memory type.
gpio0_direction
gpio0_function
Reads GPIO pin 0 function.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    GPIO0Function: enum code for GPIO pin 0 function.
gpio0_powerup_direction
gpio0_powerup_value
gpio0_value
gpio1_direction
gpio1_function
Reads GPIO pin 1 function.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    GPIO1Function: enum code for GPIO pin 1 function.
gpio1_powerup_direction
gpio1_powerup_value
gpio1_value
gpio2_direction
gpio2_function
Reads GPIO pin 2 function.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    GPIO2Function: enum code for GPIO pin 2 function.
gpio2_powerup_direction
gpio2_powerup_value
gpio2_value
gpio3_direction
gpio3_function
Reads GPIO pin 3 function.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    GPIO3Function: enum code for GPIO pin 3 function.
gpio3_powerup_direction
gpio3_powerup_value
gpio3_value
i2c_speed
Read configured I2C speed.
 
Returns:
    I2CSpeed: enum code describing current I2C speed.
interrupt_on_falling_edge
Reads interrupt on falling edge flag. This tells the state of interrupt
detection on falling edge.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    bool: value of interrupt on falling edge flag (True = active).
interrupt_on_rising_edge
Reads interrupt on rising edge flag. This tells the state of interrupt
detection on rising edge.
 
Parameters:
    mem(MemoryType): enum code for memory type (flash or SRAM)
 
Returns:
    bool: value of interrupt on rising edge flag (True = active).
led_idle_i2c_level
Reads idle level for I2C LED signal. This is the value given
to the I2C LED signal when no I2C transfer is ongoing.
 
Returns:
    bool: value of I2C LED idle signal level.
led_idle_uart_rx_level
Reads idle level for UART RX LED signal. This is the value given
to the UART RX LED signal when no RX transfer is ongoing.
 
Returns:
    bool: value of UART RX LED idle signal level.
led_idle_uart_tx_level
Reads idle level for UART TX LED signal. This is the value given
to the UART TX LED signal when no TX transfer is ongoing.
 
Returns:
    bool: value of UART TX LED idle signal level.
password
security_option
Reads chip security option.
 
Returns:
    SecurityOption: enum code for security option.
suspend_mode_logic_level
Reads pin level for suspend mode signal. This is the value given
to the suspend mode signal when chip is NOT in suspend mode.
 
Returns:
    bool: value of suspend mode signal level.
usb_configured_logic_level
Reads level for 'USB configured' signal. This is the value given
when USB enumeration is complete.
 
Returns:
    bool: level of 'USB configured' signal.
usb_current
Reads USB current value for enumeration phase, in mA.
 
Returns:
    int: value of USB current in enumeration phase, in mA.
usb_manufacturer_descriptor
Reads USB manufacturer descriptor from flash memory.
 
Returns:
    str: USB manufacturer descriptor string.
usb_pid
Reads USB product ID from flash memory.
 
Returns:
    int: USB product ID.
usb_product_descriptor
Reads USB product descriptor from flash memory.
 
Returns:
    str: USB product descriptor string.
usb_remote_wake_up_attribute
Reads 'USB remote wake-up' attribute.
 
Returns:
    bool: value of 'USB remote wake-up' attribute.
usb_self_powered_attribute
Reads 'USB self-powered' attribute.
 
Returns:
    bool: value of 'USB self-powered' attribute.
usb_serial_number_descriptor
Reads USB serial number descriptor from flash memory.
 
Returns:
    str: USB serial number descriptor string.
usb_vid
Reads USB vendor ID from flash memory.
 
Returns:
    int: USB vendor ID.

 
Functions
       
find_devices(vendor_id: int = 1240, product_id: int = 221) -> list
Finds HID devices with given vendor and product IDs,
and returns a list of found descriptors.
 
Parameters:
    vendor_id(int): the vendor ID to search for (default 1240)
    product_id(int): the product ID to search for (default 221)

 
Data
        __all__ = ['MCP2221', 'find_devices']