Ejemplo n.º 1
0
void usb_device_init(
	usb_device_t* const device
) {
	if( device->controller == 0 ) {
		usb_devices[0] = device;
	
		usb_phy_enable();
		usb_controller_reset(device);
		usb_controller_set_device_mode(device);
	
		// Set interrupt threshold interval to 0
		USB0_USBCMD_D &= ~USB0_USBCMD_D_ITC_MASK;

		// Configure endpoint list address 
		USB0_ENDPOINTLISTADDR = (uint32_t)usb_qh[0];
	
		// Enable interrupts
		USB0_USBINTR_D =
			  USB0_USBINTR_D_UE
			| USB0_USBINTR_D_UEE
			| USB0_USBINTR_D_PCE
			| USB0_USBINTR_D_URE
			//| USB0_USBINTR_D_SRE
			| USB0_USBINTR_D_SLE
			//| USB0_USBINTR_D_NAKE
			;
	}
	if( device->controller == 1 ) {
		usb_devices[1] = device;
	
		//usb_phy_enable();
		usb_controller_reset(device);
		usb_controller_set_device_mode(device);
	
		// Set interrupt threshold interval to 0
		USB1_USBCMD_D &= ~USB0_USBCMD_D_ITC_MASK;

		// Configure endpoint list address 
		USB1_ENDPOINTLISTADDR = (uint32_t)usb_qh[1];
	
		// Enable interrupts
		USB1_USBINTR_D =
			  USB1_USBINTR_D_UE
			| USB1_USBINTR_D_UEE
			| USB1_USBINTR_D_PCE
			| USB1_USBINTR_D_URE
			//| USB1_USBINTR_D_SRE
			| USB1_USBINTR_D_SLE
			//| USB1_USBINTR_D_NAKE
			;
	}
}
Ejemplo n.º 2
0
void usb_device_init(
	const uint_fast8_t device_ordinal,
	usb_device_t* const device
) {
	if( device_ordinal == 0 ) {
		usb_device_usb0 = device;
	
		usb_phy_enable();
		usb_controller_reset();
		usb_controller_set_device_mode();
	
		// Set interrupt threshold interval to 0
		USB0_USBCMD_D &= ~USB0_USBCMD_D_ITC_MASK;

		// Configure endpoint list address 
		USB0_ENDPOINTLISTADDR = (uint32_t)usb_qh;
	
		// Enable interrupts
		USB0_USBINTR_D =
			  USB0_USBINTR_D_UE
			| USB0_USBINTR_D_UEE
			| USB0_USBINTR_D_PCE
			| USB0_USBINTR_D_URE
			//| USB0_USBINTR_D_SRE
			| USB0_USBINTR_D_SLE
			//| USB0_USBINTR_D_NAKE
			;
	}
}