|
libeasymcp2221 2.0.3
|
Low-level access to MCP2221 persistent flash sections. More...
Go to the source code of this file.
Functions | |
| mcp2221_error_code_t | mcp2221_flash_read (mcp2221_t *dev, uint8_t section, uint8_t out[60]) |
| Read one MCP2221 flash section. More... | |
| mcp2221_error_code_t | mcp2221_flash_write (mcp2221_t *dev, uint8_t section, const uint8_t data[60]) |
| Write one MCP2221 flash section using the legacy 60-byte payload. More... | |
| mcp2221_error_code_t | mcp2221_flash_write_ex (mcp2221_t *dev, uint8_t section, const uint8_t *data, size_t data_len) |
| Write a length-delimited MCP2221 Write Flash Data payload. More... | |
| mcp2221_error_code_t | mcp2221_flash_send_password (mcp2221_t *dev, const uint8_t pwd[8]) |
| Send the eight-byte flash access password. More... | |
Low-level access to MCP2221 persistent flash sections.
Definition in file mcp2221_flash.h.
| mcp2221_error_code_t mcp2221_flash_read | ( | mcp2221_t * | dev, |
| uint8_t | section, | ||
| uint8_t | out[60] | ||
| ) |
Read one MCP2221 flash section.
The raw 60-byte payload returned by the selected section is copied to out without further interpretation.
Public section identifiers include:
| [in] | dev | Open MCP2221 device handle. |
| [in] | section | Flash section identifier. Must be one of the public flash section identifiers. |
| [out] | out | Buffer receiving exactly 60 section-data bytes. |
| mcp2221_error_code_t mcp2221_flash_send_password | ( | mcp2221_t * | dev, |
| const uint8_t | pwd[8] | ||
| ) |
Send the eight-byte flash access password.
This command supplies the password used by subsequent flash-write commands on password-protected devices. The MCP2221 does not validate pwd when this command is accepted; the password is checked only when a flash write is attempted. MCP2221_ERR_OK therefore means that the password command was accepted, not that pwd was correct.
| [in] | dev | Open MCP2221 device handle. |
| [in] | pwd | Eight-byte flash access password. |
| mcp2221_error_code_t mcp2221_flash_write | ( | mcp2221_t * | dev, |
| uint8_t | section, | ||
| const uint8_t | data[60] | ||
| ) |
Write one MCP2221 flash section using the legacy 60-byte payload.
The 60 bytes are copied to Write Flash Data report bytes 2 through 61. This is sufficient for chip settings, GP settings, and USB string descriptors of up to 29 UTF-16 code units. Use mcp2221_flash_write_ex() when the complete 62-byte write payload is required.
| [in] | dev | Open MCP2221 device handle. |
| [in] | section | Writable flash section identifier. Valid values are MCP2221_FLASH_DATA_CHIP_SETTINGS through MCP2221_FLASH_DATA_USB_SERIALNUM. MCP2221_FLASH_DATA_CHIP_SERIALNUM is read-only. |
| [in] | data | Exactly 60 Write Flash Data payload bytes, corresponding to report bytes 2 through 61. |
| mcp2221_error_code_t mcp2221_flash_write_ex | ( | mcp2221_t * | dev, |
| uint8_t | section, | ||
| const uint8_t * | data, | ||
| size_t | data_len | ||
| ) |
Write a length-delimited MCP2221 Write Flash Data payload.
Bytes from data are copied starting at report byte 2, after the command and flash-section bytes. Up to 62 bytes can therefore be supplied. This permits a maximum-length MCP2221 USB string descriptor: its two descriptor metadata bytes followed by 60 UTF-16LE data bytes.
For USB manufacturer, product, and serial-number sections, data starts with the USB descriptor length and descriptor type (0x03), followed by the UTF-16LE string data. The caller remains responsible for constructing a section-valid payload.
| [in] | dev | Open MCP2221 device handle. |
| [in] | section | Writable flash section identifier. Valid values are MCP2221_FLASH_DATA_CHIP_SETTINGS through MCP2221_FLASH_DATA_USB_SERIALNUM. MCP2221_FLASH_DATA_CHIP_SERIALNUM is read-only. |
| [in] | data | Write Flash Data payload copied to report byte 2 onward. |
| [in] | data_len | Number of bytes in data. Must be from 1 through 62. |