USBD_CfgAdd
Description
Adds a configuration to the device.
Files
usbd_core.h/usbd_core.c
Prototype
CPU_INT08U USBD_CfgAdd ( CPU_INT08U dev_nbr, CPU_INT08U attrib, CPU_INT16U max_pwr, USBD_DEV_SPD spd, const CPU_CHAR *p_name, USBD_ERR *p_err);
Arguments
dev_nbr
Device number.
attrib
Configuration attributes.
USBD_DEV_ATTRIB_REMOTE_WAKEUP
USBD_DEV_ATTRIB_SELF_POWERED
max_pwr
Bus power required for this device (see Note #1).
spd
Configuration speed.
USBD_DEV_SPD_FULL
USBD_DEV_SPD_HIGH
p_name
Pointer to string describing the configuration (See Note #2).
p_err
Pointer to variable that will receive the return error code from this function.
USBD_ERR_NONE
USBD_ERR_DEV_INVALID_NBR
USBD_ERR_DEV_INVALID_STATE
USBD_ERR_CFG_ALLOC
USBD_ERR_CFG_INVALID_MAX_PWR
Returned Value
Configuration number,
If no error(s).
USBD_CFG_NBR_NONE,
otherwise.
Callers
Application.
Notes / Warnings
- USB spec 2.0, section 7.2.1.3/4 defines power constrains for bus-powered devices:
- “A low-power function is one that draws up to one unit load from the USB cable when operational”
- “A function is defined as being high-power if, when fully powered, it draws over one but no more than five unit loads from the USB cable.”
- A unit load is defined as 100mA, thus max_pwr argument should be between 0 mA and 500mA.
- String support is optional, in this case '
p_name
' can be aNULL
string pointer. - Configuration can only be added when the device is in either the
USBD_DEV_STATE_NONE
orUSB_DEV_STATE_INIT
states.