UACInit

Syntax

#include <cafe/uac.h>

int UACInit(void* pv_cx, usb_event_handler_t pfn_event);

Parameters

pv_cx Pointer to an application provided context that is the first argument in the event callback.
pfn_event A function pointer to the application's UAC event handler of type usb_event_handler_t.

Return Values

A value of zero indicates success and any other value the type of error that was encountered.

Description

This function is called once to initialize the UAC stack and to register an event callback function. Subsequent events, attach, detach, error, will be sent from the UAC stack to the application via this callback.

This function is called once per instantiation of the UAC library and driver stack. The same event handler will be called for all events of all devices.

A separate thread within the UAC stack services the event handler. It is permissible to put synchronization objects into that handler, such as a mutex. Care must be taken that no deadlock can occur, however.

The UAC API set is designed to be called from within the event handler, with the exception of UACInit and UACUninit.

In the event that a foreground to background switch occurs, the entire UAC stack will be shut down and left in a quiescent state. Upon reacquiring foreground status, the application will need to reinitialize the entire stack and that includes calling this function. See overview for more information on foreground and background switching and how to handle the required processing.

This function requires tens milliseconds to complete, although much of that time is spent waiting on synchronization objects. It is not recommended to call this function from a timing sensitive thread.

Do Not Call From

Background Do not call this function from the background.
Multiple threads This function is not thread-safe.
Callbacks Do not call this function from any callback function.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.

See Also

usb_event_handler_t
UACUninit
Error Codes

Revision History

2013/05/29 Initial version.


CONFIDENTIAL