Ejemplo n.º 1
0
bool Endpoint_ConfigureEndpoint_Prv(uint8_t corenum,
									const uint8_t Number,
									const uint8_t UECFG0XData,
									const uint8_t UECFG1XData)
{
#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)
	Endpoint_SelectEndpoint(corenum, Number);
	Endpoint_EnableEndpoint();

	//	UECFG1X = 0;
	//	UECFG0X = UECFG0XData;
	//	UECFG1X = UECFG1XData;

	return Endpoint_IsConfigured();
#else
	for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS(corenum); EPNum++) {
		//		uint8_t UECFG0XTemp;
		//		uint8_t UECFG1XTemp;
		//		uint8_t UEIENXTemp;

		Endpoint_SelectEndpoint(corenum, EPNum);

		if (EPNum == Number) {
			//			UECFG0XTemp = UECFG0XData;
			//			UECFG1XTemp = UECFG1XData;
			//			UEIENXTemp  = 0;
		}
		else {
			//			UECFG0XTemp = UECFG0X;
			//			UECFG1XTemp = UECFG1X;
			//			UEIENXTemp  = UEIENX;
		}

		//		if (!(UECFG1XTemp & (1 << ALLOC)))
		//		  continue;

		Endpoint_DisableEndpoint();
		//		UECFG1X &= ~(1 << ALLOC);

		Endpoint_EnableEndpoint();
		//		UECFG0X = UECFG0XTemp;
		//		UECFG1X = UECFG1XTemp;
		//		UEIENX  = UEIENXTemp;

		if (!(Endpoint_IsConfigured())) {
			return false;
		}
	}

	Endpoint_SelectEndpoint(corenum, Number);
	return true;
#endif
}
Ejemplo n.º 2
0
void Endpoint_ClearEndpoints(uint8_t corenum)
{
	//	UEINT = 0;

	for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS(corenum); EPNum++) {
		Endpoint_SelectEndpoint(corenum, EPNum);
		//		UEIENX  = 0;
		//		UEINTX  = 0;
		//		UECFG1X = 0;
		Endpoint_DisableEndpoint();
	}
}
bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{
	memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State));

	for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS(CDCInterfaceInfo->Config.PortNumber); EndpointNum++)
	{
		uint16_t Size;
		uint8_t  Type;
		uint8_t  Direction;
		bool     DoubleBanked;

		if (EndpointNum == CDCInterfaceInfo->Config.DataINEndpointNumber)
		{
			Size         = CDCInterfaceInfo->Config.DataINEndpointSize;
			Direction    = ENDPOINT_DIR_IN;
			Type         = EP_TYPE_BULK;
			DoubleBanked = CDCInterfaceInfo->Config.DataINEndpointDoubleBank;
		}
		else if (EndpointNum == CDCInterfaceInfo->Config.DataOUTEndpointNumber)
		{
			Size         = CDCInterfaceInfo->Config.DataOUTEndpointSize;
			Direction    = ENDPOINT_DIR_OUT;
			Type         = EP_TYPE_BULK;
			DoubleBanked = CDCInterfaceInfo->Config.DataOUTEndpointDoubleBank;
		}
		else if (EndpointNum == CDCInterfaceInfo->Config.NotificationEndpointNumber)
		{
			Size         = CDCInterfaceInfo->Config.NotificationEndpointSize;
			Direction    = ENDPOINT_DIR_IN;
			Type         = EP_TYPE_INTERRUPT;
			DoubleBanked = CDCInterfaceInfo->Config.NotificationEndpointDoubleBank;
		}
		else
		{
			continue;
		}

		if (!(Endpoint_ConfigureEndpoint(CDCInterfaceInfo->Config.PortNumber, EndpointNum, Type, Direction, Size,
		                                 DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))
		{
			return false;
		}
	}

	return true;
}