Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USB host task module

Modules

 Host controller states
 Defines for device state coding.
 

Data Structures

struct  S_pipe_int
 

Macros

#define Host_ack_request_resume()   (request_resume = false)
 Private ack for resume software event. More...
 
#define Host_request_resume()   (request_resume = true)
 Should be called to request the host controller to resume the USB bus. More...
 
#define Host_request_suspend()   (device_state = DEVICE_SUSPENDED)
 Should be called to make the host controller enter USB suspend mode. More...
 
#define Is_host_addressed()   (device_state >= DEVICE_ADDRESSED)
 Check if there is a device addressed by the host. More...
 
#define Is_host_attached()   (device_state >= DEVICE_ATTACHED)
 Check if there is a device attached to the host. More...
 
#define Is_host_error()   (device_state == DEVICE_ERROR)
 Check if there is an error. More...
 
#define Is_host_powered()   (device_state >= DEVICE_POWERED)
 Check if there is a device powered by the host. More...
 
#define Is_host_ready()   (device_state == DEVICE_READY)
 Returns true when device connected and correctly enumerated. More...
 
#define Is_host_request_resume()   (request_resume == true)
 Private check for resume sequence. More...
 
#define Is_host_suspended()
 Check if host controller is in suspend mode. More...
 
#define PIPE_CRC16   0x10
 
#define PIPE_DATA_PID   0x02
 
#define PIPE_DATA_TOGGLE   0x01
 
#define PIPE_DELAY_TIMEOUT   0x80
 
#define PIPE_GOOD   0x00
 
#define PIPE_NAK_TIMEOUT   0x40
 
#define PIPE_PID   0x04
 
#define PIPE_STALL   0x20
 
#define PIPE_TIMEOUT   0x08
 

Typedefs

typedef void Pipe_handler (Status_t status, U16 nb_byte)
 

Functions

Status_t host_get_data (U8 pipe, U16 *nb_data, void *ptr_buf)
 This function receives nb_data bytes pointed to by ptr_buf on the specified pipe. More...
 
Status_t host_send_data (U8 pipe, U16 nb_data, const void *ptr_buf)
 This function sends nb_data bytes pointed to by ptr_buf on the specified pipe. More...
 
void usb_host_task (void *pvParameters)
 Entry point of the USB host management. More...
 
void usb_host_task_init (void)
 This function initializes the USB host controller. More...
 

Variables

U8 data_stage [SIZEOF_DATA_STAGE]
 
volatile U8 device_state
 
volatile U8 device_status
 
volatile bool request_resume
 
volatile S_usb_setup_data usb_request
 

#define Host_ack_request_resume ( )    (request_resume = false)

Private ack for resume software event.

#define Host_request_resume ( )    (request_resume = true)

Should be called to request the host controller to resume the USB bus.

#define Host_request_suspend ( )    (device_state = DEVICE_SUSPENDED)

Should be called to make the host controller enter USB suspend mode.

#define Is_host_addressed ( )    (device_state >= DEVICE_ADDRESSED)

Check if there is a device addressed by the host.

#define Is_host_attached ( )    (device_state >= DEVICE_ATTACHED)

Check if there is a device attached to the host.

Referenced by usb_general_interrupt_non_naked().

#define Is_host_error ( )    (device_state == DEVICE_ERROR)

Check if there is an error.

#define Is_host_powered ( )    (device_state >= DEVICE_POWERED)

Check if there is a device powered by the host.

#define Is_host_ready ( )    (device_state == DEVICE_READY)

Returns true when device connected and correctly enumerated.

The host high-level application should test this before performing any applicative request.

#define Is_host_request_resume ( )    (request_resume == true)

Private check for resume sequence.

#define Is_host_suspended ( )
Value:
#define DEVICE_WAIT_RESUME
Definition: usb_host_task.h:139
#define DEVICE_SUSPENDED
Definition: usb_host_task.h:138
volatile U8 device_state

Check if host controller is in suspend mode.

#define PIPE_CRC16   0x10
#define PIPE_DATA_PID   0x02
#define PIPE_DATA_TOGGLE   0x01
#define PIPE_DELAY_TIMEOUT   0x80
#define PIPE_GOOD   0x00
#define PIPE_NAK_TIMEOUT   0x40
#define PIPE_PID   0x04
#define PIPE_STALL   0x20
#define PIPE_TIMEOUT   0x08

typedef void Pipe_handler(Status_t status, U16 nb_byte)

Status_t host_get_data ( U8  pipe,
U16 nb_data,
void *  ptr_buf 
)

This function receives nb_data bytes pointed to by ptr_buf on the specified pipe.

*nb_data is updated with the final number of data bytes received.

Note
This function activates the host SOF interrupt to detect time-outs. The initial enable state of this interrupt will be restored.
Parameters
pipe
nb_data
ptr_buf
Returns
Status_t: Pipe status
Status_t host_send_data ( U8  pipe,
U16  nb_data,
const void *  ptr_buf 
)

This function sends nb_data bytes pointed to by ptr_buf on the specified pipe.

Note
This function activates the host SOF interrupt to detect time-outs. The initial enable state of this interrupt will be restored.
Parameters
pipe
nb_data
ptr_buf
Returns
Status_t: Pipe status
void usb_host_task ( void *  pvParameters)

Entry point of the USB host management.

The aim is to manage the target device connection and enumeration. Depending on device_state, the function performs the required operations to get the device enumerated and configured. Once the device is operational, device_state is DEVICE_READY. This state should be tested by the host task before sending any applicative request to the device. This function is called from the usb_task function depending on the USB operating mode (device or host) currently engaged.

void usb_host_task_init ( void  )

This function initializes the USB host controller.

This function enables the USB controller for host-mode operation.

Referenced by usb_task().

U8 data_stage[SIZEOF_DATA_STAGE]
volatile U8 device_state
volatile U8 device_status
volatile bool request_resume
volatile S_usb_setup_data usb_request