//***************************************************************************** // //! Initializes a USB buffer object to be used with a given USB controller and //! device or host class driver. //! //! \param psBuffer points to a structure containing information on the buffer //! memory to be used and the underlying device or host class driver whose data //! is to be buffered. This structure must remain accessible for as long as //! the buffer is in use. //! //! This function is used to initialize a USB buffer object and insert it //! into the function and callback interfaces between an underlying driver //! and the application. The caller supplies information on both the RAM //! to be used to buffer data, the type of buffer to be created (transmit or //! receive) and the functions to be called in the lower layer to transfer //! data to or from the USB controller. //! //! \return Returns the original buffer structure pointer if successful or //! NULL if an error is detected. // //***************************************************************************** const tUSBBuffer * USBBufferInit(const tUSBBuffer *psBuffer) { tUSBBufferVars *psVars; // // Check parameter validity. // ASSERT(psBuffer && psBuffer->pvWorkspace && psBuffer->pcBuffer && psBuffer->ulBufferSize && psBuffer->pfnAvailable && psBuffer->pfnTransfer && psBuffer->pfnCallback); // // Get a pointer to the buffer workspace and inttialize the variables it // contains. // psVars = psBuffer->pvWorkspace; USBRingBufInit(&psVars->sRingBuf, psBuffer->pcBuffer, psBuffer->ulBufferSize); // // If all is well, return the same pointer we were originally passed. // return(psBuffer); }
//***************************************************************************** // //! Initializes a USB buffer object to be used with a given USB controller and //! device or host class driver. //! //! \param psBuffer points to a structure containing information on the buffer //! memory to be used and the underlying device or host class driver whose data //! is to be buffered. This structure must remain accessible for as long as //! the buffer is in use. //! //! This function is used to initialize a USB buffer object and insert it //! into the function and callback interfaces between an underlying driver //! and the application. The caller supplies information on both the RAM //! to be used to buffer data, the type of buffer to be created (transmit or //! receive) and the functions to be called in the lower layer to transfer //! data to or from the USB controller. //! //! \return Returns the original buffer structure pointer if successful or //! NULL if an error is detected. // //***************************************************************************** const tUSBBuffer * USBBufferInit(tUSBBuffer *psBuffer) { // // Check parameter validity. // ASSERT(psBuffer && psBuffer->pui8Buffer && psBuffer->ui32BufferSize && psBuffer->pfnAvailable && psBuffer->pfnTransfer && psBuffer->pfnCallback); // // Get a pointer to the buffer workspace and initialize the variables it // contains. // psBuffer->sPrivateData.ui32Flags = 0; USBRingBufInit(&psBuffer->sPrivateData.sRingBuf, psBuffer->pui8Buffer, psBuffer->ui32BufferSize); // // If all is well, return the same pointer we were originally passed. // return(psBuffer); }