/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_usb_init
* Returned Value   : 0 for success, -1 for failure
* Comments         :
*    This function performs BSP-specific initialization related to USB
*
*END*----------------------------------------------------------------------*/
_mqx_int _bsp_usb_dev_init(struct usb_dev_if_struct *usb_if)
{
    _mqx_int result = _bsp_usb_io_init(); 
    
    if (result != MQX_OK) return result;
    
    /* Configure enable USB regulator for device */
    SIM_SOPT1_REG(SIM_BASE_PTR) |= SIM_SOPT1_USBREGEN_MASK;
    /* Reset USB peripheral */
    USB_USBTRC0_REG(USB0_BASE_PTR) |= USB_USBTRC0_USBRESET_MASK;
    /* Wait while resetting */
    while (USB_USBTRC0_REG(USB0_BASE_PTR) & USB_USBTRC0_USBRESET_MASK)
    {}

    /* reset USB CTRL register */
    USB_USBCTRL_REG(USB0_BASE_PTR) = 0;
    
    /* Enable internal pull-up resistor */
    USB_CONTROL_REG(USB0_BASE_PTR) = USB_CONTROL_DPPULLUPNONOTG_MASK;
    USB_USBTRC0_REG(USB0_BASE_PTR) |= 0x40; /* Software must set this bit to 1 */
    
    /* setup interrupt */
    _bsp_int_init(INT_USB0, BSP_USB_INT_LEVEL, 0, TRUE);
    
    return MQX_OK;
}
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_usb_dev_init
* Returned Value   : 0 for success, -1 for failure
* Comments         :
*    This function performs BSP-specific initialization related to USB
*
*END*----------------------------------------------------------------------*/
_mqx_int _bsp_usb_dev_init(struct usb_dev_if_struct *usb_if)
{
    _mqx_int result;

    if (usb_if == NULL) {
        return IO_ERROR;
    }
    
    result = _bsp_usb_dev_io_init(usb_if);

    if (result != MQX_OK)
        return result;

    if (usb_if->DEV_INIT_PARAM == &_khci0_dev_init_param) {
        /* Configure enable USB regulator for device */
        SIM_SOPT1CFG_REG(SIM_BASE_PTR) |= SIM_SOPT1CFG_URWE_MASK;
        SIM_SOPT1_REG(SIM_BASE_PTR) |= SIM_SOPT1_USBREGEN_MASK;
        /* Reset USB peripheral */
        USB_USBTRC0_REG(USB0_BASE_PTR) |= USB_USBTRC0_USBRESET_MASK;
        /* Wait while resetting */
        while (USB_USBTRC0_REG(USB0_BASE_PTR) & USB_USBTRC0_USBRESET_MASK)
        {}

        /* reset USB CTRL register */
        USB_USBCTRL_REG(USB0_BASE_PTR) = 0;

        /* Enable internal pull-up resistor */
        USB_CONTROL_REG(USB0_BASE_PTR) = USB_CONTROL_DPPULLUPNONOTG_MASK;
        USB_USBTRC0_REG(USB0_BASE_PTR) |= 0x40; /* Software must set this bit to 1 */

        /* setup interrupt */
        _bsp_int_init(INT_USB0, BSP_USB_INT_LEVEL, 0, TRUE);
    }
    else if (usb_if->DEV_INIT_PARAM == &_ehci0_dev_init_param) {
        USBHS_USBCMD |= USBHS_USBCMD_RST_MASK;    
        while (USBHS_USBCMD & USBHS_USBCMD_RST_MASK)
        { /* delay while resetting USB controller */ } 

        USBHS_USBMODE =	USBHS_USBMODE_CM_DEVICE_MASK;                
        USBHS_USBCMD &= ~( USBHS_USBCMD_ITC(0xFF));	// Set interrupt threshold control = 0
        USBHS_USBMODE |= USBHS_USBMODE_SLOM_MASK;	// Setup Lockouts Off

        /* setup interrupt */
       _bsp_int_init(INT_USBHS, BSP_USB_INT_LEVEL, 0, TRUE);
    }
    else {
        /* unknown controller */
        result = IO_ERROR;
    }

    return MQX_OK;
}
Exemple #3
0
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_usb_dev_init
* Returned Value   : 0 for success, -1 for failure
* Comments         :
*    This function performs BSP-specific initialization related to USB
*
*END*----------------------------------------------------------------------*/
_mqx_int _bsp_usb_dev_init(struct usb_dev_if_struct *usb_if)
{
    _mqx_int result = _bsp_usb_dev_io_init(usb_if); 
    
    if (result != MQX_OK) return result;
    
    /* Configure enable USB regulator for device */
    SIM_SOPT1_REG(SIM_BASE_PTR) |= SIM_SOPT1_USBREGEN_MASK;    
    
    /* reset USB CTRL register */
    USB_USBCTRL_REG(USB0_BASE_PTR) = 0;
    
    /* Enable internal pull-up resistor */
    USB_CONTROL_REG(USB0_BASE_PTR) = USB_CONTROL_DPPULLUPNONOTG_MASK;
        
    /* setup interrupt */
    _bsp_int_init(INT_USB0, BSP_USB_INT_LEVEL, 0, TRUE);
    
    return MQX_OK;
}
Exemple #4
0
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_usb_dev_init
* Returned Value   : 0 for success, -1 for failure
* Comments         :
*    This function performs BSP-specific initialization related to USB
*
*END*----------------------------------------------------------------------*/
_mqx_int _bsp_usb_dev_init(pointer param)
{
    _mqx_uint dev_num = (_mqx_uint) param;
    _mqx_int result = _bsp_usb_io_init(dev_num);

    if (result != MQX_OK)
        return result;

    if (dev_num == USBCFG_CONTROLLER_KHCI) {
        /* Configure enable USB regulator for device */
        SIM_SOPT1CFG_REG(SIM_BASE_PTR) |= SIM_SOPT1CFG_URWE_MASK;
        SIM_SOPT1_REG(SIM_BASE_PTR) |= SIM_SOPT1_USBREGEN_MASK;
        /* Reset USB peripheral */
        USB_USBTRC0_REG(USB0_BASE_PTR) |= USB_USBTRC0_USBRESET_MASK;
        /* Wait while resetting */
        while (USB_USBTRC0_REG(USB0_BASE_PTR) & USB_USBTRC0_USBRESET_MASK)
        {}

        /* reset USB CTRL register */
        USB_USBCTRL_REG(USB0_BASE_PTR) = 0;

        /* Enable internal pull-up resistor */
        USB_CONTROL_REG(USB0_BASE_PTR) = USB_CONTROL_DPPULLUPNONOTG_MASK;
        USB_USBTRC0_REG(USB0_BASE_PTR) |= 0x40; /* Software must set this bit to 1 */
    
        /* setup interrupt */
        _bsp_int_init(INT_USB0, BSP_USB_INT_LEVEL, 0, TRUE);
    }   
    else if (dev_num == USBCFG_CONTROLLER_EHCI) {
    }
    else {
        /* unknown controller */
        result = IO_ERROR;
    }

    return MQX_OK;
}