/* ** =================================================================== ** Method : usb_device__usb_device_init_endpoint (component USB_DEVICE_STACK) ** Description : ** This function initializes an endpoint the Device layer and ** the Controller layer in the S08 USB stack. It validate ** whether all endpoints have already been initialized or not ** and then calls the controller layer endpoint initialize ** function ** Parameters : ** NAME - DESCRIPTION ** handle - [IN] USB Device handle ** endpoint_number - [IN] Endpoint ** number ** max_packet_size - [IN] Maximum ** packet size (in bytes) for the endpoint ** direction - [IN] Direction of transfer ** endpoint_type - [IN] Type of endpoint ** flag - [IN] Zero termination flag ** Returns : ** --- - Error code ** =================================================================== */ uint_8 _usb_device_init_endpoint(_usb_device_handle handle, uint_8 endpoint_number, uint_16 max_packet_size, uint_8 direction, uint_8 endpoint_type, uint_8 flag) { USB_EP_STRUCT ep_str; uint_8 status=USB_OK; /* check if all endpoint have already been initialised */ if((g_EPn == 0) && (endpoint_number != CONTROL_ENDPOINT)) { return USBERR_EP_INIT_FAILED; } ep_str.direction = direction; ep_str.ep_num = endpoint_number; ep_str.size = max_packet_size; ep_str.type = endpoint_type; /* call controller layer for initiazation */ status = USB_DCI_Init_EndPoint(*((uint_8*)handle), &ep_str, flag); /* if endpoint successfully initialised update counter */ if ((ep_str.ep_num != CONTROL_ENDPOINT) && (status == USB_OK)) { g_EPn--; } return status; }
/**************************************************************************//*! * * @name _usb_device_init_endpoint * * @brief The function initializes the endpoint * * @param handle : USB Device handle * @param endpoint_number : Endpoint number * @param max_packet_size : Maximum packet size (in bytes) for the endpoint * @param direction : Direction of transfer * @param endpoint_type : Type of endpoint * @param flag : Zero termination flag * * @return status * USB_OK : When Successfull * USBERR_EP_INIT_FAILED : When endpoints > max Supported ****************************************************************************** * * This function initializes an endpoint the Device layer and the Controller * layer in the S08 USB stack. It validate whether all endpoints have already * been initialized or not and then calls the controller layer endpoint * initialize function * *****************************************************************************/ uint_8 _usb_device_init_endpoint ( _usb_device_handle handle, /* [IN] USB Device handle */ uint_8 endpoint_number, /* [IN] Endpoint number*/ uint_16 max_packet_size, /* [IN] Maximum packet size (in bytes) for the endpoint */ uint_8 direction, /* [IN] Direction of transfer */ uint_8 endpoint_type, /* [IN] Type of endpoint */ uint_8 flag /* [IN] Zero termination flag */ ) { USB_EP_STRUCT ep_str; uint_8 status = USB_OK; /* check if all endpoint have already been initialised */ if((g_EPn == 0) && (endpoint_number != CONTROL_ENDPOINT)) { return USBERR_EP_INIT_FAILED; } ep_str.direction = direction; ep_str.ep_num = endpoint_number; #if 0 /* << EST */ #ifndef _MC9S08JS16_H ep_str.size = max_packet_size; #else ep_str.size = (char)max_packet_size; #endif #else /* device is Kinetis L2K << EST */ ep_str.size = max_packet_size; #endif ep_str.type = endpoint_type; /* call controller layer for initiazation */ status = USB_DCI_Init_EndPoint(*((uint_8*)handle), &ep_str, flag); /* if endpoint successfully initialised update counter */ if ((ep_str.ep_num != CONTROL_ENDPOINT) && (status == USB_OK)) { g_EPn--; } return status; }