Example #1
0
/*******************************************************************************
* Function Name  : SetDeviceAddress.
* Description    : Set the device and all the used Endpoints addresses.
* Input          : - Val: device address.
* Output         : None.
* Return         : None.
*******************************************************************************/
void SetDeviceAddress(uint8_t Val) {
	uint8_t i;
	uint32_t nEP = Device_Table.Total_Endpoint;

	// set address in every used endpoint
	for (i = 0; i < nEP; i++) SetEPAddress(i,i);
	*DADDR = Val | DADDR_EF; // set device address and enable function
}
Example #2
0
/*******************************************************************************
* Function Name  : SetDeviceAddress.
* Description    : Set the device and all the used Endpoints addresses.
* Input          : - Val: device address.
* Output         : None.
* Return         : None.
*******************************************************************************/
void SetDeviceAddress(uint8_t Val) {
	uint32_t i;
	uint32_t nEP = Device_Table.Total_Endpoint;

	// set address in every used endpoint
	for (i = 0; i < nEP; i++) SetEPAddress((uint8_t)i,(uint8_t)i);
	USB->DADDR = (uint16_t)(Val | DADDR_EF); // set device address and enable function
}
Example #3
0
static int8_t stm32_usbd_get_ep(uint8_t idx)
{
	int8_t i;
	
	i = stm32_usbd_ep(idx);
	if (i >= 0)
	{
		return i;
	}
	
	for (i = 0; i < sizeof(stm32_usbd_epaddr); i++)
	{
		if (-1 == stm32_usbd_epaddr[i])
		{
			stm32_usbd_epaddr[i] = idx;
			SetEPAddress(i, idx);
			return i;
		}
	}
	return -1;
}