libeasymcp2221 2.0.3
Macros
mcp2221_constants.h File Reference

Public constants used by the libeasymcp2221 v2 API. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MCP2221_DEV_DEFAULT_VID   0x04D8
 Default Microchip USB vendor ID for MCP2221 devices. More...
 
#define MCP2221_DEV_DEFAULT_PID   0x00DD
 Default USB product ID for MCP2221/MCP2221A devices. More...
 
#define MCP2221_PACKET_SIZE   64
 MCP2221 HID report size in bytes. More...
 
#define MCP2221_DIR_OUTPUT   0
 Public direction value selecting GPIO output mode. More...
 
#define MCP2221_DIR_INPUT   1
 Public direction value selecting GPIO input mode. More...
 
#define MCP2221_I2C_ADDR_7BIT_MAX   127
 Largest valid 7-bit I2C address. More...
 
#define MCP2221_I2C_TRANSFER_MAX   65535u
 Maximum I2C transfer length accepted by the public API, in bytes. More...
 
#define MCP2221_I2C_SPEED_MAX_HZ   400000u
 Maximum supported MCP2221 I2C bus clock frequency, in hertz. More...
 
#define MCP2221_USB_CURRENT_MAX_MA   500u
 Maximum requested USB bus current accepted by the public API, in mA. More...
 
#define MCP2221_MIN_VDD_VOLTS   3.0
 Minimum VDD value accepted by mcp2221_analog_set_vdd(), in volts. More...
 
#define MCP2221_MAX_VDD_VOLTS   5.5
 Maximum VDD value accepted by mcp2221_analog_set_vdd(), in volts. More...
 
MCP2221 command identifiers

Raw protocol command bytes used by low-level communication helpers.

#define MCP2221_CMD_POLL_STATUS_SET_PARAMETERS   0x10
 
#define MCP2221_CMD_SET_GPIO_OUTPUT_VALUES   0x50
 
#define MCP2221_CMD_GET_GPIO_VALUES   0x51
 
#define MCP2221_CMD_SET_SRAM_SETTINGS   0x60
 
#define MCP2221_CMD_GET_SRAM_SETTINGS   0x61
 
#define MCP2221_CMD_I2C_READ_DATA_GET_I2C_DATA   0x40
 
#define MCP2221_CMD_I2C_WRITE_DATA   0x90
 
#define MCP2221_CMD_I2C_READ_DATA   0x91
 
#define MCP2221_CMD_I2C_WRITE_DATA_REPEATED_START   0x92
 
#define MCP2221_CMD_I2C_READ_DATA_REPEATED_START   0x93
 
#define MCP2221_CMD_I2C_WRITE_DATA_NO_STOP   0x94
 
#define MCP2221_CMD_READ_FLASH_DATA   0xB0
 
#define MCP2221_CMD_WRITE_FLASH_DATA   0xB1
 
#define MCP2221_CMD_SEND_FLASH_ACCESS_PASSWORD   0xB2
 
#define MCP2221_CMD_RESET_CHIP   0x70
 
Common response fields
#define MCP2221_RESPONSE_RESULT_OK   0
 
#define MCP2221_RESPONSE_ECHO_BYTE   0
 
#define MCP2221_RESPONSE_STATUS_BYTE   1
 
Flash section identifiers

Values accepted by mcp2221_flash_read() and, where appropriate, mcp2221_flash_write().

#define MCP2221_FLASH_DATA_CHIP_SETTINGS   0x00
 
#define MCP2221_FLASH_DATA_GP_SETTINGS   0x01
 
#define MCP2221_FLASH_DATA_USB_MANUFACTURER   0x02
 
#define MCP2221_FLASH_DATA_USB_PRODUCT   0x03
 
#define MCP2221_FLASH_DATA_USB_SERIALNUM   0x04
 
#define MCP2221_FLASH_DATA_CHIP_SERIALNUM   0x05
 
GP pin selectors
#define MCP2221_GPIO_GP0   0
 
#define MCP2221_GPIO_GP1   1
 
#define MCP2221_GPIO_GP2   2
 
#define MCP2221_GPIO_GP3   3
 
GPIO function selectors

Values used by mcp2221_sram_config(). Not every alternate function is valid on every GP pin; see mcp2221_sram_gp_config_t::function.

#define MCP2221_GPIO_FUNC_GPIO   0x00u
 
#define MCP2221_GPIO_FUNC_DEDICATED   0x01u
 
#define MCP2221_GPIO_FUNC_ALT_0   0x02u
 
#define MCP2221_GPIO_FUNC_ALT_1   0x03u
 
#define MCP2221_GPIO_FUNC_ALT_2   0x04u
 
#define MCP2221_GPIO_FUNC_ADC   MCP2221_GPIO_FUNC_ALT_0
 
#define MCP2221_GPIO_FUNC_DAC   MCP2221_GPIO_FUNC_ALT_1
 
ADC SRAM reference configuration

Values used by mcp2221_sram_adc_config_t.

#define MCP2221_ADC_VRM_OFF   (0x00u << 1)
 
#define MCP2221_ADC_VRM_1024   (0x01u << 1)
 
#define MCP2221_ADC_VRM_2048   (0x02u << 1)
 
#define MCP2221_ADC_VRM_4096   (0x03u << 1)
 
#define MCP2221_ADC_REF_VRM   1
 
#define MCP2221_ADC_REF_VDD   0
 
DAC SRAM reference configuration
#define MCP2221_DAC_VRM_OFF   (0x00u << 1)
 
#define MCP2221_DAC_VRM_1024   (0x01u << 1)
 
#define MCP2221_DAC_VRM_2048   (0x02u << 1)
 
#define MCP2221_DAC_VRM_4096   (0x03u << 1)
 
#define MCP2221_DAC_REF_VRM   1
 
#define MCP2221_DAC_REF_VDD   0
 
Clock-output configuration
#define MCP2221_CLK_DUTY_0   (0x00u << 3)
 
#define MCP2221_CLK_DUTY_25   (0x01u << 3)
 
#define MCP2221_CLK_DUTY_50   (0x02u << 3)
 
#define MCP2221_CLK_DUTY_75   (0x03u << 3)
 
#define MCP2221_CLK_DIV_1   0x01u
 
#define MCP2221_CLK_DIV_2   0x02u
 
#define MCP2221_CLK_DIV_3   0x03u
 
#define MCP2221_CLK_DIV_4   0x04u
 
#define MCP2221_CLK_DIV_5   0x05u
 
#define MCP2221_CLK_DIV_6   0x06u
 
#define MCP2221_CLK_DIV_7   0x07u
 
#define MCP2221_CLK_FREQ_375kHz   MCP2221_CLK_DIV_7
 
#define MCP2221_CLK_FREQ_750kHz   MCP2221_CLK_DIV_6
 
#define MCP2221_CLK_FREQ_1_5MHz   MCP2221_CLK_DIV_5
 
#define MCP2221_CLK_FREQ_3MHz   MCP2221_CLK_DIV_4
 
#define MCP2221_CLK_FREQ_6MHz   MCP2221_CLK_DIV_3
 
#define MCP2221_CLK_FREQ_12MHz   MCP2221_CLK_DIV_2
 
#define MCP2221_CLK_FREQ_24MHz   MCP2221_CLK_DIV_1
 

Detailed Description

Public constants used by the libeasymcp2221 v2 API.

This header contains device defaults, protocol constants, flash section identifiers, GPIO selectors, SRAM configuration values, clock settings, and analog limits used by the public API.

Definition in file mcp2221_constants.h.

Macro Definition Documentation

◆ MCP2221_ADC_REF_VDD

#define MCP2221_ADC_REF_VDD   0

Select VDD as the ADC reference.

Definition at line 114 of file mcp2221_constants.h.

◆ MCP2221_ADC_REF_VRM

#define MCP2221_ADC_REF_VRM   1

Select the internal ADC voltage-reference module.

Definition at line 113 of file mcp2221_constants.h.

◆ MCP2221_ADC_VRM_1024

#define MCP2221_ADC_VRM_1024   (0x01u << 1)

Internal ADC reference set to 1.024 V.

Definition at line 110 of file mcp2221_constants.h.

◆ MCP2221_ADC_VRM_2048

#define MCP2221_ADC_VRM_2048   (0x02u << 1)

Internal ADC reference set to 2.048 V.

Definition at line 111 of file mcp2221_constants.h.

◆ MCP2221_ADC_VRM_4096

#define MCP2221_ADC_VRM_4096   (0x03u << 1)

Internal ADC reference set to 4.096 V.

Definition at line 112 of file mcp2221_constants.h.

◆ MCP2221_ADC_VRM_OFF

#define MCP2221_ADC_VRM_OFF   (0x00u << 1)

Internal ADC voltage-reference module disabled.

Definition at line 109 of file mcp2221_constants.h.

◆ MCP2221_CLK_DIV_1

#define MCP2221_CLK_DIV_1   0x01u

Clock divider 1; 24 MHz output.

Definition at line 137 of file mcp2221_constants.h.

◆ MCP2221_CLK_DIV_2

#define MCP2221_CLK_DIV_2   0x02u

Clock divider 2; 12 MHz output.

Definition at line 138 of file mcp2221_constants.h.

◆ MCP2221_CLK_DIV_3

#define MCP2221_CLK_DIV_3   0x03u

Clock divider 3; 6 MHz output.

Definition at line 139 of file mcp2221_constants.h.

◆ MCP2221_CLK_DIV_4

#define MCP2221_CLK_DIV_4   0x04u

Clock divider 4; 3 MHz output.

Definition at line 140 of file mcp2221_constants.h.

◆ MCP2221_CLK_DIV_5

#define MCP2221_CLK_DIV_5   0x05u

Clock divider 5; 1.5 MHz output.

Definition at line 141 of file mcp2221_constants.h.

◆ MCP2221_CLK_DIV_6

#define MCP2221_CLK_DIV_6   0x06u

Clock divider 6; 750 kHz output.

Definition at line 142 of file mcp2221_constants.h.

◆ MCP2221_CLK_DIV_7

#define MCP2221_CLK_DIV_7   0x07u

Clock divider 7; 375 kHz output.

Definition at line 143 of file mcp2221_constants.h.

◆ MCP2221_CLK_DUTY_0

#define MCP2221_CLK_DUTY_0   (0x00u << 3)

0 percent duty-cycle selector.

Definition at line 133 of file mcp2221_constants.h.

◆ MCP2221_CLK_DUTY_25

#define MCP2221_CLK_DUTY_25   (0x01u << 3)

25 percent duty-cycle selector.

Definition at line 134 of file mcp2221_constants.h.

◆ MCP2221_CLK_DUTY_50

#define MCP2221_CLK_DUTY_50   (0x02u << 3)

50 percent duty-cycle selector.

Definition at line 135 of file mcp2221_constants.h.

◆ MCP2221_CLK_DUTY_75

#define MCP2221_CLK_DUTY_75   (0x03u << 3)

75 percent duty-cycle selector.

Definition at line 136 of file mcp2221_constants.h.

◆ MCP2221_CLK_FREQ_12MHz

#define MCP2221_CLK_FREQ_12MHz   MCP2221_CLK_DIV_2

Alias selecting 12 MHz.

Definition at line 149 of file mcp2221_constants.h.

◆ MCP2221_CLK_FREQ_1_5MHz

#define MCP2221_CLK_FREQ_1_5MHz   MCP2221_CLK_DIV_5

Alias selecting 1.5 MHz.

Definition at line 146 of file mcp2221_constants.h.

◆ MCP2221_CLK_FREQ_24MHz

#define MCP2221_CLK_FREQ_24MHz   MCP2221_CLK_DIV_1

Alias selecting 24 MHz.

Definition at line 150 of file mcp2221_constants.h.

◆ MCP2221_CLK_FREQ_375kHz

#define MCP2221_CLK_FREQ_375kHz   MCP2221_CLK_DIV_7

Alias selecting 375 kHz.

Definition at line 144 of file mcp2221_constants.h.

◆ MCP2221_CLK_FREQ_3MHz

#define MCP2221_CLK_FREQ_3MHz   MCP2221_CLK_DIV_4

Alias selecting 3 MHz.

Definition at line 147 of file mcp2221_constants.h.

◆ MCP2221_CLK_FREQ_6MHz

#define MCP2221_CLK_FREQ_6MHz   MCP2221_CLK_DIV_3

Alias selecting 6 MHz.

Definition at line 148 of file mcp2221_constants.h.

◆ MCP2221_CLK_FREQ_750kHz

#define MCP2221_CLK_FREQ_750kHz   MCP2221_CLK_DIV_6

Alias selecting 750 kHz.

Definition at line 145 of file mcp2221_constants.h.

◆ MCP2221_CMD_GET_GPIO_VALUES

#define MCP2221_CMD_GET_GPIO_VALUES   0x51

Read GPIO values.

Definition at line 43 of file mcp2221_constants.h.

◆ MCP2221_CMD_GET_SRAM_SETTINGS

#define MCP2221_CMD_GET_SRAM_SETTINGS   0x61

Read runtime SRAM settings.

Definition at line 45 of file mcp2221_constants.h.

◆ MCP2221_CMD_I2C_READ_DATA

#define MCP2221_CMD_I2C_READ_DATA   0x91

I2C read command.

Definition at line 48 of file mcp2221_constants.h.

◆ MCP2221_CMD_I2C_READ_DATA_GET_I2C_DATA

#define MCP2221_CMD_I2C_READ_DATA_GET_I2C_DATA   0x40

Retrieve buffered I2C read data.

Definition at line 46 of file mcp2221_constants.h.

◆ MCP2221_CMD_I2C_READ_DATA_REPEATED_START

#define MCP2221_CMD_I2C_READ_DATA_REPEATED_START   0x93

I2C read using repeated-start sequencing.

Definition at line 50 of file mcp2221_constants.h.

◆ MCP2221_CMD_I2C_WRITE_DATA

#define MCP2221_CMD_I2C_WRITE_DATA   0x90

I2C write command.

Definition at line 47 of file mcp2221_constants.h.

◆ MCP2221_CMD_I2C_WRITE_DATA_NO_STOP

#define MCP2221_CMD_I2C_WRITE_DATA_NO_STOP   0x94

I2C write without issuing a stop condition.

Definition at line 51 of file mcp2221_constants.h.

◆ MCP2221_CMD_I2C_WRITE_DATA_REPEATED_START

#define MCP2221_CMD_I2C_WRITE_DATA_REPEATED_START   0x92

I2C write using repeated-start sequencing.

Definition at line 49 of file mcp2221_constants.h.

◆ MCP2221_CMD_POLL_STATUS_SET_PARAMETERS

#define MCP2221_CMD_POLL_STATUS_SET_PARAMETERS   0x10

Poll status / set I2C parameters.

Definition at line 41 of file mcp2221_constants.h.

◆ MCP2221_CMD_READ_FLASH_DATA

#define MCP2221_CMD_READ_FLASH_DATA   0xB0

Read persistent flash data.

Definition at line 52 of file mcp2221_constants.h.

◆ MCP2221_CMD_RESET_CHIP

#define MCP2221_CMD_RESET_CHIP   0x70

Reset the MCP2221.

Definition at line 55 of file mcp2221_constants.h.

◆ MCP2221_CMD_SEND_FLASH_ACCESS_PASSWORD

#define MCP2221_CMD_SEND_FLASH_ACCESS_PASSWORD   0xB2

Send the flash access password.

Definition at line 54 of file mcp2221_constants.h.

◆ MCP2221_CMD_SET_GPIO_OUTPUT_VALUES

#define MCP2221_CMD_SET_GPIO_OUTPUT_VALUES   0x50

Set GPIO output values.

Definition at line 42 of file mcp2221_constants.h.

◆ MCP2221_CMD_SET_SRAM_SETTINGS

#define MCP2221_CMD_SET_SRAM_SETTINGS   0x60

Set runtime SRAM settings.

Definition at line 44 of file mcp2221_constants.h.

◆ MCP2221_CMD_WRITE_FLASH_DATA

#define MCP2221_CMD_WRITE_FLASH_DATA   0xB1

Write persistent flash data.

Definition at line 53 of file mcp2221_constants.h.

◆ MCP2221_DAC_REF_VDD

#define MCP2221_DAC_REF_VDD   0

Select VDD as the DAC reference.

Definition at line 126 of file mcp2221_constants.h.

◆ MCP2221_DAC_REF_VRM

#define MCP2221_DAC_REF_VRM   1

Select the internal DAC voltage-reference module.

Definition at line 125 of file mcp2221_constants.h.

◆ MCP2221_DAC_VRM_1024

#define MCP2221_DAC_VRM_1024   (0x01u << 1)

Internal DAC reference set to 1.024 V.

Definition at line 122 of file mcp2221_constants.h.

◆ MCP2221_DAC_VRM_2048

#define MCP2221_DAC_VRM_2048   (0x02u << 1)

Internal DAC reference set to 2.048 V.

Definition at line 123 of file mcp2221_constants.h.

◆ MCP2221_DAC_VRM_4096

#define MCP2221_DAC_VRM_4096   (0x03u << 1)

Internal DAC reference set to 4.096 V.

Definition at line 124 of file mcp2221_constants.h.

◆ MCP2221_DAC_VRM_OFF

#define MCP2221_DAC_VRM_OFF   (0x00u << 1)

Internal DAC voltage-reference module disabled.

Definition at line 121 of file mcp2221_constants.h.

◆ MCP2221_DEV_DEFAULT_PID

#define MCP2221_DEV_DEFAULT_PID   0x00DD

Default USB product ID for MCP2221/MCP2221A devices.

Definition at line 17 of file mcp2221_constants.h.

◆ MCP2221_DEV_DEFAULT_VID

#define MCP2221_DEV_DEFAULT_VID   0x04D8

Default Microchip USB vendor ID for MCP2221 devices.

Definition at line 14 of file mcp2221_constants.h.

◆ MCP2221_DIR_INPUT

#define MCP2221_DIR_INPUT   1

Public direction value selecting GPIO input mode.

Definition at line 26 of file mcp2221_constants.h.

◆ MCP2221_DIR_OUTPUT

#define MCP2221_DIR_OUTPUT   0

Public direction value selecting GPIO output mode.

Definition at line 23 of file mcp2221_constants.h.

◆ MCP2221_FLASH_DATA_CHIP_SERIALNUM

#define MCP2221_FLASH_DATA_CHIP_SERIALNUM   0x05

Factory/chip serial-number data.

Definition at line 76 of file mcp2221_constants.h.

◆ MCP2221_FLASH_DATA_CHIP_SETTINGS

#define MCP2221_FLASH_DATA_CHIP_SETTINGS   0x00

Persistent chip settings.

Definition at line 71 of file mcp2221_constants.h.

◆ MCP2221_FLASH_DATA_GP_SETTINGS

#define MCP2221_FLASH_DATA_GP_SETTINGS   0x01

Persistent GP pin settings.

Definition at line 72 of file mcp2221_constants.h.

◆ MCP2221_FLASH_DATA_USB_MANUFACTURER

#define MCP2221_FLASH_DATA_USB_MANUFACTURER   0x02

USB manufacturer string descriptor.

Definition at line 73 of file mcp2221_constants.h.

◆ MCP2221_FLASH_DATA_USB_PRODUCT

#define MCP2221_FLASH_DATA_USB_PRODUCT   0x03

USB product string descriptor.

Definition at line 74 of file mcp2221_constants.h.

◆ MCP2221_FLASH_DATA_USB_SERIALNUM

#define MCP2221_FLASH_DATA_USB_SERIALNUM   0x04

USB serial-number string descriptor.

Definition at line 75 of file mcp2221_constants.h.

◆ MCP2221_GPIO_FUNC_ADC

#define MCP2221_GPIO_FUNC_ADC   MCP2221_GPIO_FUNC_ALT_0

Alias for the ADC alternate function.

Definition at line 101 of file mcp2221_constants.h.

◆ MCP2221_GPIO_FUNC_ALT_0

#define MCP2221_GPIO_FUNC_ALT_0   0x02u

Pin-specific alternate function 0.

Definition at line 98 of file mcp2221_constants.h.

◆ MCP2221_GPIO_FUNC_ALT_1

#define MCP2221_GPIO_FUNC_ALT_1   0x03u

Pin-specific alternate function 1.

Definition at line 99 of file mcp2221_constants.h.

◆ MCP2221_GPIO_FUNC_ALT_2

#define MCP2221_GPIO_FUNC_ALT_2   0x04u

Pin-specific alternate function 2.

Definition at line 100 of file mcp2221_constants.h.

◆ MCP2221_GPIO_FUNC_DAC

#define MCP2221_GPIO_FUNC_DAC   MCP2221_GPIO_FUNC_ALT_1

Alias for the DAC alternate function.

Definition at line 102 of file mcp2221_constants.h.

◆ MCP2221_GPIO_FUNC_DEDICATED

#define MCP2221_GPIO_FUNC_DEDICATED   0x01u

Pin-specific dedicated function.

Definition at line 97 of file mcp2221_constants.h.

◆ MCP2221_GPIO_FUNC_GPIO

#define MCP2221_GPIO_FUNC_GPIO   0x00u

General-purpose GPIO function.

Definition at line 96 of file mcp2221_constants.h.

◆ MCP2221_GPIO_GP0

#define MCP2221_GPIO_GP0   0

GP0 pin index.

Definition at line 85 of file mcp2221_constants.h.

◆ MCP2221_GPIO_GP1

#define MCP2221_GPIO_GP1   1

GP1 pin index.

Definition at line 86 of file mcp2221_constants.h.

◆ MCP2221_GPIO_GP2

#define MCP2221_GPIO_GP2   2

GP2 pin index.

Definition at line 87 of file mcp2221_constants.h.

◆ MCP2221_GPIO_GP3

#define MCP2221_GPIO_GP3   3

GP3 pin index.

Definition at line 88 of file mcp2221_constants.h.

◆ MCP2221_I2C_ADDR_7BIT_MAX

#define MCP2221_I2C_ADDR_7BIT_MAX   127

Largest valid 7-bit I2C address.

Definition at line 29 of file mcp2221_constants.h.

◆ MCP2221_I2C_SPEED_MAX_HZ

#define MCP2221_I2C_SPEED_MAX_HZ   400000u

Maximum supported MCP2221 I2C bus clock frequency, in hertz.

Definition at line 35 of file mcp2221_constants.h.

◆ MCP2221_I2C_TRANSFER_MAX

#define MCP2221_I2C_TRANSFER_MAX   65535u

Maximum I2C transfer length accepted by the public API, in bytes.

Definition at line 32 of file mcp2221_constants.h.

◆ MCP2221_MAX_VDD_VOLTS

#define MCP2221_MAX_VDD_VOLTS   5.5

Maximum VDD value accepted by mcp2221_analog_set_vdd(), in volts.

Definition at line 157 of file mcp2221_constants.h.

◆ MCP2221_MIN_VDD_VOLTS

#define MCP2221_MIN_VDD_VOLTS   3.0

Minimum VDD value accepted by mcp2221_analog_set_vdd(), in volts.

Definition at line 154 of file mcp2221_constants.h.

◆ MCP2221_PACKET_SIZE

#define MCP2221_PACKET_SIZE   64

MCP2221 HID report size in bytes.

Definition at line 20 of file mcp2221_constants.h.

◆ MCP2221_RESPONSE_ECHO_BYTE

#define MCP2221_RESPONSE_ECHO_BYTE   0

Response byte containing the echoed command.

Definition at line 62 of file mcp2221_constants.h.

◆ MCP2221_RESPONSE_RESULT_OK

#define MCP2221_RESPONSE_RESULT_OK   0

Successful device response status.

Definition at line 61 of file mcp2221_constants.h.

◆ MCP2221_RESPONSE_STATUS_BYTE

#define MCP2221_RESPONSE_STATUS_BYTE   1

Response byte containing command status.

Definition at line 63 of file mcp2221_constants.h.

◆ MCP2221_USB_CURRENT_MAX_MA

#define MCP2221_USB_CURRENT_MAX_MA   500u

Maximum requested USB bus current accepted by the public API, in mA.

Definition at line 80 of file mcp2221_constants.h.