Microchip® Advanced Software Framework

usb_host_task.h File Reference
#include "conf_usb.h"
#include "compiler.h"
#include "usb_host_enum.h"

Data Structures

struct  S_pipe_int
 

Macros

#define DEVICE_ADDRESSED   4
 
#define DEVICE_ATTACHED   1
 
#define DEVICE_CONFIGURED   5
 
#define DEVICE_DEFAULT   3
 
#define DEVICE_ERROR   7
 
#define DEVICE_POWERED   2
 
#define DEVICE_READY   6
 
#define DEVICE_SUSPENDED   8
 
#define DEVICE_UNATTACHED   0
 
#define DEVICE_WAIT_RESUME   9
 
#define Host_ack_request_resume()   (request_resume = false)
 Private ack for resume software event. More...
 
#define Host_clear_configured()   (Clr_bits(device_status, 0x04))
 
#define Host_clear_device_ready()   (Clr_bits(device_status, 0x02))
 
#define Host_clear_device_status()   (device_status = 0x00)
 
#define Host_clear_device_supported()   (Clr_bits(device_status, 0x01))
 
#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 Host_set_configured()   (Set_bits(device_status, 0x04))
 
#define Host_set_device_ready()   (Set_bits(device_status, 0x02))
 
#define Host_set_device_supported()   (Set_bits(device_status, 0x01))
 
#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_configured()   (Tst_bits(device_status, 0x04))
 
#define Is_host_device_ready()   (Tst_bits(device_status, 0x02))
 
#define Is_host_device_supported()   (Tst_bits(device_status, 0x01))
 
#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)
 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]
 Public: U8 data_stage[SIZEOF_DATA_STAGE] Internal RAM buffer for USB data stage content This buffer is required to setup host enumeration process It contains the device descriptors received. More...
 
volatile U8 device_state
 Public: U8 device_state Its value represents the current state of the device connected to the USB host controller Value can be: More...
 
volatile U8 device_status
 
volatile bool request_resume
 
volatile S_usb_setup_data usb_request
 For control requests management over control pipe. More...