Exemplo n.º 1
0
/*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;
}
Exemplo n.º 2
0
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_usb_host_init
* Returned Value   : 0 for success, -1 for failure
* Comments         :
*    This function performs BSP-specific initialization related to USB
*
*END*----------------------------------------------------------------------*/
_mqx_int _bsp_usb_host_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) {
        /* Do not configure enable USB regulator for host */
//      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;

        /* 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 result;
}
Exemplo n.º 3
0
int32_t bsp_usb_dev_init(uint8_t controller_id)
{
    int32_t result = 0;

    result = bsp_usb_dev_io_init(controller_id);
    if (result != 0)
    {
        return result;
    }
    /* MPU is disabled. All accesses from all bus masters are allowed */
    MPU_CESR=0;
    if (USB_CONTROLLER_KHCI_0 == controller_id)
    {
        /* Configure enable USB regulator for device */
        //SIM_SOPT1_REG(SIM_BASE_PTR) |= SIM_SOPT1CFG_URWE_MASK;
        //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;
        USB_USBTRC0_REG(USB0_BASE_PTR) |= 0x40; /* Software must set this bit to 1 */
        /* setup interrupt */
        OS_intr_init(soc_get_usb_vector_number(0), BSP_USB_INT_LEVEL, 0, TRUE);
    }
    else
    {
        /* unknown controller */
        result = -1;
    }

    return result;
}
Exemplo n.º 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(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;
}
Exemplo n.º 5
0
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_usb_host_init
* Returned Value   : 0 for success, -1 for failure
* Comments         :
*    This function performs BSP-specific initialization related to USB
*
*END*----------------------------------------------------------------------*/
_mqx_int _bsp_usb_host_init(struct usb_host_if_struct *usb_if)
{
    _mqx_int result;

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

    result = _bsp_usb_host_io_init(usb_if);

    if (result != MQX_OK)
        return result;

    if (usb_if->HOST_INIT_PARAM == &_khci0_host_init_param) {
        /* Do not configure enable USB regulator for host */
//      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;

        /* setup interrupt */
        _bsp_int_init(INT_USB0, BSP_USB_INT_LEVEL, 0, TRUE);
    }
    else if (usb_if->HOST_INIT_PARAM == &_ehci0_host_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_HOST_MASK;
        USBHS_USBCMD = USBHS_USBCMD_ASP(3) | USBHS_USBCMD_ITC(0);

        /* setup interrupt */
       _bsp_int_init(INT_USBHS, BSP_USB_INT_LEVEL, 0, TRUE);

    }
    else {
        /* unknown controller */
        result = IO_ERROR;
    }

    return result;
}
Exemplo n.º 6
0
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_usb_host_init
* Returned Value   : 0 for success, -1 for failure
* Comments         :
*    This function performs BSP-specific initialization related to USB
*
*END*----------------------------------------------------------------------*/
_mqx_int _bsp_usb_host_init(struct usb_host_if_struct *usb_if)
{
    _mqx_int result = _bsp_usb_host_io_init(usb_if); 

    if (result != MQX_OK) return result;

    /* Do not configure enable USB regulator for host */
    /* SIM_SOPT1_REG(SIM_BASE_PTR) |= SIM_SOPT1_USBREGEN_MASK; */

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

    /* setup interrupt */
    _bsp_int_init(INT_USB0, BSP_USB_INT_LEVEL, 0, TRUE);
    return MQX_OK;
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name    : _bsp_usb_host_init
* Returned Value   : 0 for success, -1 for failure
* Comments         :
*    This function performs BSP-specific initialization related to USB
*
*END*----------------------------------------------------------------------*/
_mqx_int _bsp_usb_host_init(struct usb_host_if_struct *usb_if)
{
    _mqx_int result = _bsp_usb_io_init(); 
    
    if (result != MQX_OK) return result;

    /* Do not configure enable USB regulator for host */
//    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;

    /* setup interrupt */
    _bsp_int_init(INT_USB0, BSP_USB_INT_LEVEL, 0, TRUE);
    
    return MQX_OK;
}
Exemplo n.º 9
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;
}