Beispiel #1
0
/**************************************************************************//*!
 *
 * @name  _usb_device_init
 *
 * @brief The function initializes the Device and Controller layer
 *
 * @param device_number       : USB Device controller to initialize
 * @param handle              : pointer to USB Device handle
 * @param number_of_endpoints : Endpoint count of the application
 *
 * @return status
 *         USB_OK                              : When Successfull
 *         USBERR_INVALID_NUM_OF_ENDPOINTS     : When endpoints > max Supported
 ******************************************************************************
 * This function initializes the Device layer and the Controller layer of the
 * S08 USB stack. It initializes the variables used for this layer and then
 * calls the controller layer initialize function
 *****************************************************************************/
uint_8 _usb_device_init (
    uint_8    device_number,			/* [IN] USB Device controller to initialize */
    _usb_device_handle _PTR_  handle,	/* [IN] Pointer to USB Device handle */
    uint_8    number_of_endpoints,		/* [IN] Number of endpoints to initialize */
    uint_8    bVregEn        			/* Enables or disables internal regulator */
)
{
	UNUSED(handle);

    /* validate endpoints param */
    if((number_of_endpoints > MAX_SUPPORTED_ENDPOINTS) ||
      (number_of_endpoints < MIN_SUPPORTED_ENDPOINTS))
    {
        return USBERR_INVALID_NUM_OF_ENDPOINTS;
    }

    /* init variables */
    g_EPn_max = (uint_8)(number_of_endpoints - 1);

    USB_Device_Init_Params();

#ifdef MULTIPLE_DEVICES
    /* Initialize all services to null value */
    Clear_Mem((uint_8_ptr)g_usb_CB,
        (uint_32)(sizeof(USB_SERVICE_CALLBACK) * USB_SERVICE_MAX), (uint_8)0);
#endif
    /* Call controller layer initialization function */
    return USB_DCI_Init(device_number, bVregEn);

}
Beispiel #2
0
/*
** ===================================================================
**     Method      :  usb_device__usb_device_init (component USB_DEVICE_STACK)
**     Description :
**         This function initializes the Device layer and the
**         Controller layer of the S08 USB stack. It initialised the
**         variables used for this layer and then calls the controller
**         layer initialize function
**     Parameters  :
**         NAME            - DESCRIPTION
**         device_number   - [IN] USB Device
**                           controller to initialize
**       * handle          - [IN] Pointer to USB Device handle
**         number_of_endpoints - [IN]
**                           Number of endpoints to initialize
**     Returns     :
**         ---             - Error code
** ===================================================================
*/
uint_8  _usb_device_init(uint_8 device_number, _usb_device_handle _PTR_ handle, uint_8 number_of_endpoints)
{
    UNUSED(handle);

    /* validate endpoints param */
    if((number_of_endpoints > MAX_SUPPORTED_ENDPOINTS) ||
       (number_of_endpoints < MIN_SUPPORTED_ENDPOINTS))
    {
        return USBERR_INVALID_NUM_OF_ENDPOINTS;
    }

    /*init variables */
    g_EPn_max = (uint_8)(number_of_endpoints - 1);

    USB_Device_Init_Params();

    /* Initialize all services to null value */
    Clear_Mem((uint_8_ptr)g_usb_CB,
        (sizeof(USB_SERVICE_CALLBACK) * USB_SERVICE_MAX), (uint_8)NULL);
    /* Call controller layer initialization function */
    return USB_DCI_Init(device_number);
}