|
libeasymcp2221 2.0.3
|
USB enumeration attributes staged for persistent flash storage. More...
#include "mcp2221.h"Go to the source code of this file.
Functions | |
| mcp2221_error_code_t | mcp2221_usb_set_remote_wakeup (mcp2221_t *dev, int enable) |
| Stage the USB Remote Wake-up capability setting. More... | |
| mcp2221_error_code_t | mcp2221_usb_get_remote_wakeup (mcp2221_t *dev, int *enabled) |
| Return the effective USB Remote Wake-up setting. More... | |
| mcp2221_error_code_t | mcp2221_usb_set_cdc_serial_enabled (mcp2221_t *dev, int enable) |
| Stage USB CDC serial-number enumeration. More... | |
| mcp2221_error_code_t | mcp2221_usb_get_cdc_serial_enabled (mcp2221_t *dev, int *enabled) |
| Return the effective USB CDC serial-number enumeration setting. More... | |
| mcp2221_error_code_t | mcp2221_usb_set_self_powered (mcp2221_t *dev, int self_powered) |
| Stage whether the MCP2221 advertises itself as self-powered. More... | |
| mcp2221_error_code_t | mcp2221_usb_get_self_powered (mcp2221_t *dev, int *self_powered) |
| Return the effective self-powered setting. More... | |
| mcp2221_error_code_t | mcp2221_usb_set_requested_current (mcp2221_t *dev, unsigned ma) |
| Stage the USB bus current advertised by the MCP2221. More... | |
| mcp2221_error_code_t | mcp2221_usb_get_requested_current (mcp2221_t *dev, unsigned *ma) |
| Return the effective requested USB bus current in milliamperes. More... | |
USB enumeration attributes staged for persistent flash storage.
Definition in file mcp2221_usb.h.
| mcp2221_error_code_t mcp2221_usb_get_cdc_serial_enabled | ( | mcp2221_t * | dev, |
| int * | enabled | ||
| ) |
Return the effective USB CDC serial-number enumeration setting.
A staged value takes precedence over the value currently stored in flash. On success, enabled is normalized to 0 or 1.
| [in] | dev | Open MCP2221 device handle. |
| [out] | enabled | Receives 0 when disabled or 1 when enabled. |
| mcp2221_error_code_t mcp2221_usb_get_remote_wakeup | ( | mcp2221_t * | dev, |
| int * | enabled | ||
| ) |
Return the effective USB Remote Wake-up setting.
If mcp2221_usb_set_remote_wakeup() has staged a value that has not yet been persisted with mcp2221_flash_save_config(), the staged value is returned. Otherwise the value currently stored in MCP2221 flash is read and returned.
This reports the effective library configuration. It does not report whether the USB host currently has Remote Wake-up enabled for the device.
| [in] | dev | Open MCP2221 device handle. |
| [out] | enabled | Receives 0 when disabled or 1 when enabled. |
| mcp2221_error_code_t mcp2221_usb_get_requested_current | ( | mcp2221_t * | dev, |
| unsigned * | ma | ||
| ) |
Return the effective requested USB bus current in milliamperes.
A staged value takes precedence over the value currently stored in flash. The returned value is decoded to milliamperes; it is not the raw USBREQCRT register value.
| [in] | dev | Open MCP2221 device handle. |
| [out] | ma | Receives the effective requested current in milliamperes. |
| mcp2221_error_code_t mcp2221_usb_get_self_powered | ( | mcp2221_t * | dev, |
| int * | self_powered | ||
| ) |
Return the effective self-powered setting.
A staged value takes precedence over the value currently stored in flash. On success, the returned value is normalized to 0 or 1.
| [in] | dev | Open MCP2221 device handle. |
| [out] | self_powered | Receives 0 for bus-powered or 1 for self-powered. |
| mcp2221_error_code_t mcp2221_usb_set_cdc_serial_enabled | ( | mcp2221_t * | dev, |
| int | enable | ||
| ) |
Stage USB CDC serial-number enumeration.
A value of 0 disables the CDC serial-number feature; any nonzero value enables it. This controls the MCP2221 CDCSNEN bit in the persistent CDCSEC chip setting.
The value is staged in the device handle until mcp2221_flash_save_config() persists it. Unrelated CDCSEC bits are preserved. The new enumeration setting takes effect after USB re-enumeration.
| [in] | dev | Open MCP2221 device handle. |
| [in] | enable | 0 to disable CDC serial-number enumeration, nonzero to enable it. |
| mcp2221_error_code_t mcp2221_usb_set_remote_wakeup | ( | mcp2221_t * | dev, |
| int | enable | ||
| ) |
Stage the USB Remote Wake-up capability setting.
A value of 0 disables the capability; any nonzero value enables it.
This function changes only the staged configuration stored in the device handle. Call mcp2221_flash_save_config() to persist the setting in MCP2221 flash. The USB host sees the persisted value only after the device is re-enumerated.
Advertising Remote Wake-up capability does not by itself wake the host. A suitable wake-up source, such as GP1 interrupt-on-change, must be configured and the host operating system must permit the device to wake it.
| [in] | dev | Open MCP2221 device handle. |
| [in] | enable | 0 to disable Remote Wake-up capability, nonzero to enable it. |
| mcp2221_error_code_t mcp2221_usb_set_requested_current | ( | mcp2221_t * | dev, |
| unsigned | ma | ||
| ) |
Stage the USB bus current advertised by the MCP2221.
The MCP2221 USBREQCRT field uses units of 2 mA. This API accepts the requested current directly in milliamperes and performs the register encoding internally. Valid values are even numbers from 0 through 500 mA; for example, 100 mA is encoded as register value 50.
This attribute only describes the device to the USB host. It does not electrically limit, regulate, or switch current.
The setting remains staged in the device handle until mcp2221_flash_save_config() persists it. The USB host observes the persisted value only after re-enumeration.
| [in] | dev | Open MCP2221 device handle. |
| [in] | ma | Requested USB bus current in mA. Must be even and in the range 0 through 500 inclusive. |
| mcp2221_error_code_t mcp2221_usb_set_self_powered | ( | mcp2221_t * | dev, |
| int | self_powered | ||
| ) |
Stage whether the MCP2221 advertises itself as self-powered.
A value of 0 advertises the device as bus-powered; any nonzero value advertises it as self-powered.
This setting changes only the USB enumeration attribute and does not change the actual hardware power source. It should be enabled only when the physical device is in fact self-powered.
The setting remains staged in the device handle until mcp2221_flash_save_config() persists it. The USB host observes the persisted value only after re-enumeration.
| [in] | dev | Open MCP2221 device handle. |
| [in] | self_powered | 0 for bus-powered, nonzero for self-powered. |