pic_usb.h File Reference

Pic USB routines. More...

#include "pic_utils.h"

Include dependency graph for pic_usb.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _buffer_descriptor
struct  _CDC_ACM_functional_descriptor
struct  _CDC_call_mgt_functional_descriptor
struct  _CDC_header_functional_descriptor
struct  _CDC_union_functional_descriptor
struct  _configuration_descriptor
struct  _device_descriptor
struct  _endpoint_descriptor
struct  _hid_descriptor
struct  _interface_descriptor
struct  _setup_data_packet

Defines

#define BC8   0
#define BC9   1
#define BSTALL   2
#define DATA_STAGE_DIR   7
#define dt_CONFIGURATION   0x02
#define dt_CS_INTERFACE   0x24
#define dt_DEBUG   0x0a
#define dt_DEVICE   0x01
#define dt_DEVICE_QUALIFIER   0x06
#define dt_ENDPOINT   0x05
#define dt_HID   0x21
#define dt_HID_REPORT   0x22
#define dt_INTERFACE   0x04
#define dt_INTERFACE_ASSOC   0x0b
#define dt_INTERFACE_POWER   0x08
#define dt_OTG   0x09
#define dt_OTHER_SPEED_CONFIG   0x07
#define dt_STRING   0x03
#define DTS   6
#define DTSEN   3
#define INCDIS   4
#define KEN   5
#define PID0   2
#define PID1   3
#define PID2   4
#define PID3   5
#define pid_ACK   0b00000010
#define pid_DATA0   0b00000011
#define pid_DATA1   0b00001011
#define pid_DATA2   0b00000111
#define pid_IN   0b00001001
#define pid_MDATA   0b00001111
#define pid_NAK   0b00001010
#define pid_NYET   0b00000110
#define pid_OUT   0b00000001
#define pid_SETUP   0b00001101
#define pid_SOF   0b00000101
#define pid_STALL   0b00001110
#define req_Clear_Feature   0x01
#define req_Get_Configuration   0x08
#define req_Get_Descriptor   0x06
#define req_Get_Interface   0x0a
#define req_Get_Status   0x00
#define req_Set_Address   0x05
#define req_Set_Configuration   0x09
#define req_Set_Descriptor   0x07
#define req_Set_Feature   0x03
#define req_Set_Interface   0x0b
#define req_Synch_Frame   0x0c
#define REQUEST_TYPE0   5
#define REQUEST_TYPE1   6
#define UOWN   7
#define usb_send_status_ack()   usb_send_empty_data_pkt()

Typedefs

typedef struct _buffer_descriptor buffer_descriptor
typedef struct
_CDC_ACM_functional_descriptor 
CDC_ACM_functional_descriptor
typedef struct
_CDC_call_mgt_functional_descriptor 
CDC_call_mgt_functional_descriptor
typedef struct
_CDC_header_functional_descriptor 
CDC_header_functional_descriptor
typedef struct
_CDC_union_functional_descriptor 
CDC_union_functional_descriptor
typedef struct
_configuration_descriptor 
configuration_descriptor
typedef enum _control_mode_type control_mode_type
typedef struct _device_descriptor device_descriptor
typedef enum _direction_type direction_type
typedef struct _endpoint_descriptor endpoint_descriptor
typedef struct _hid_descriptor hid_descriptor
typedef struct
_interface_descriptor 
interface_descriptor
typedef struct _setup_data_packet setup_data_packet
typedef enum _usb_state_type usb_state_type
typedef enum _usb_status_type usb_status_type

Enumerations

enum  _control_mode_type {
  cm_IDLE, cm_CTRL_WRITE_DATA_STAGE, cm_CTRL_WRITE_DATA_STAGE_CLASS, cm_CTRL_READ_DATA_STAGE,
  cm_CTRL_READ_DATA_STAGE_CLASS, cm_CTRL_READ_AWAITING_STATUS, cm_CTRL_WRITE_SENDING_STATUS, cm_SENDING_STATUS
}
enum  _direction_type { IN, OUT }
enum  _usb_state_type {
  st_POWERED, st_DEFAULT, st_ADDRESS, st_CONFIGURED,
  stPOWERED, stDEFAULT, stADDRESS, stCONFIGURED
}
enum  _usb_status_type { us_IDLE, us_SET_ADDRESS }

Functions

void usb_device_configured_callback ()
void usb_enable_module ()
void usb_ep_data_in_callback (uns8 end_point, uns16 byte_count)
void usb_ep_data_out_callback (uns8 end_point, uns8 *buffer_location, uns16 byte_count)
void usb_get_descriptor_callback (uns8 descriptor_type, uns8 descriptor_num, uns8 **rtn_descriptor_ptr, uns16 *rtn_descriptor_size)
usb_state_type usb_get_state ()
void usb_handle_class_request (setup_data_packet sdp)
void usb_handle_ctrl_read_class ()
void usb_handle_ctrl_write_class (uns8 *data, uns16 count)
void usb_handle_isr ()
void usb_send_data (uns8 ep, uns8 *data, uns8 send_count, bit first)
void usb_send_empty_data_pkt ()
void usb_setup ()
void usb_SOF_callback (uns16 frame)
void usb_stall_ep0 ()

Variables

control_mode_type control_mode
uns8 usb_address
setup_data_packet usb_sdp
usb_state_type usb_state


Detailed Description

It's the way cool interrupt driven usb library

Ian Harris 2008 imharris [at] gmail.com

Released under the "do whatever you like with this but if it breaks, you get to keep both pieces" license

Definition in file pic_usb.h.


Define Documentation

#define BC8   0

#define BC9   1

#define BSTALL   2

#define DATA_STAGE_DIR   7

Definition at line 50 of file pic_usb.h.

#define dt_CONFIGURATION   0x02

Definition at line 126 of file pic_usb.h.

#define dt_CS_INTERFACE   0x24

Definition at line 139 of file pic_usb.h.

#define dt_DEBUG   0x0a

Definition at line 134 of file pic_usb.h.

#define dt_DEVICE   0x01

Definition at line 125 of file pic_usb.h.

#define dt_DEVICE_QUALIFIER   0x06

Definition at line 130 of file pic_usb.h.

#define dt_ENDPOINT   0x05

Definition at line 129 of file pic_usb.h.

#define dt_HID   0x21

Definition at line 136 of file pic_usb.h.

#define dt_HID_REPORT   0x22

Definition at line 137 of file pic_usb.h.

#define dt_INTERFACE   0x04

Definition at line 128 of file pic_usb.h.

#define dt_INTERFACE_ASSOC   0x0b

Definition at line 135 of file pic_usb.h.

#define dt_INTERFACE_POWER   0x08

Definition at line 132 of file pic_usb.h.

#define dt_OTG   0x09

Definition at line 133 of file pic_usb.h.

#define dt_OTHER_SPEED_CONFIG   0x07

Definition at line 131 of file pic_usb.h.

#define dt_STRING   0x03

Definition at line 127 of file pic_usb.h.

#define DTS   6

#define DTSEN   3

#define INCDIS   4

#define KEN   5

#define PID0   2

Definition at line 81 of file pic_usb.h.

#define PID1   3

Definition at line 80 of file pic_usb.h.

#define PID2   4

Definition at line 79 of file pic_usb.h.

#define PID3   5

Definition at line 78 of file pic_usb.h.

#define pid_ACK   0b00000010

Definition at line 103 of file pic_usb.h.

Referenced by usb_handle_transaction().

#define pid_DATA0   0b00000011

Definition at line 96 of file pic_usb.h.

#define pid_DATA1   0b00001011

Definition at line 97 of file pic_usb.h.

#define pid_DATA2   0b00000111

Definition at line 98 of file pic_usb.h.

#define pid_IN   0b00001001

Definition at line 90 of file pic_usb.h.

Referenced by usb_handle_transaction().

#define pid_MDATA   0b00001111

Definition at line 99 of file pic_usb.h.

#define pid_NAK   0b00001010

Definition at line 104 of file pic_usb.h.

#define pid_NYET   0b00000110

Definition at line 106 of file pic_usb.h.

#define pid_OUT   0b00000001

Definition at line 89 of file pic_usb.h.

Referenced by usb_handle_transaction().

#define pid_SETUP   0b00001101

Definition at line 92 of file pic_usb.h.

Referenced by usb_handle_transaction().

#define pid_SOF   0b00000101

Definition at line 91 of file pic_usb.h.

#define pid_STALL   0b00001110

Definition at line 105 of file pic_usb.h.

#define req_Clear_Feature   0x01

Definition at line 112 of file pic_usb.h.

#define req_Get_Configuration   0x08

Definition at line 117 of file pic_usb.h.

#define req_Get_Descriptor   0x06

Definition at line 115 of file pic_usb.h.

Referenced by usb_handle_standard_request().

#define req_Get_Interface   0x0a

Definition at line 119 of file pic_usb.h.

Referenced by usb_handle_standard_request().

#define req_Get_Status   0x00

Definition at line 111 of file pic_usb.h.

Referenced by usb_handle_standard_request().

#define req_Set_Address   0x05

Definition at line 114 of file pic_usb.h.

Referenced by usb_handle_standard_request().

#define req_Set_Configuration   0x09

Definition at line 118 of file pic_usb.h.

Referenced by usb_handle_standard_request().

#define req_Set_Descriptor   0x07

Definition at line 116 of file pic_usb.h.

#define req_Set_Feature   0x03

Definition at line 113 of file pic_usb.h.

#define req_Set_Interface   0x0b

Definition at line 120 of file pic_usb.h.

#define req_Synch_Frame   0x0c

Definition at line 121 of file pic_usb.h.

#define REQUEST_TYPE0   5

Definition at line 53 of file pic_usb.h.

Referenced by usb_handle_transaction().

#define REQUEST_TYPE1   6

Definition at line 52 of file pic_usb.h.

Referenced by usb_handle_transaction().

#define UOWN   7

 
#define usb_send_status_ack (  )     usb_send_empty_data_pkt()


Typedef Documentation


Enumeration Type Documentation

Enumerator:
cm_IDLE 
cm_CTRL_WRITE_DATA_STAGE 
cm_CTRL_WRITE_DATA_STAGE_CLASS 
cm_CTRL_READ_DATA_STAGE 
cm_CTRL_READ_DATA_STAGE_CLASS 
cm_CTRL_READ_AWAITING_STATUS 
cm_CTRL_WRITE_SENDING_STATUS 
cm_SENDING_STATUS 

Definition at line 237 of file pic_usb.h.

Enumerator:
IN 
OUT 

Definition at line 253 of file pic_usb.h.

Enumerator:
st_POWERED 
st_DEFAULT 
st_ADDRESS 
st_CONFIGURED 
stPOWERED 
stDEFAULT 
stADDRESS 
stCONFIGURED 

Definition at line 19 of file pic_usb.h.

Enumerator:
us_IDLE 
us_SET_ADDRESS 

Definition at line 248 of file pic_usb.h.


Function Documentation

void usb_device_configured_callback (  ) 

Referenced by usb_handle_standard_request().

Here is the caller graph for this function:

void usb_enable_module (  ) 

Definition at line 736 of file pic_usb.c.

void usb_ep_data_in_callback ( uns8  end_point,
uns16  byte_count 
)

Definition at line 162 of file usb_cdc_class.c.

References usb_cdc_handle_tx().

Referenced by usb_handle_transaction().

Here is the call graph for this function:

Here is the caller graph for this function:

void usb_ep_data_out_callback ( uns8  end_point,
uns8 *  buffer_location,
uns16  byte_count 
)

Definition at line 138 of file usb_cdc_class.c.

References cdc_rx_buffer, cdc_rx_end, cdc_rx_start, serial_print_int(), serial_print_str(), and uns8.

Referenced by usb_handle_transaction().

Here is the call graph for this function:

Here is the caller graph for this function:

void usb_get_descriptor_callback ( uns8  descriptor_type,
uns8  descriptor_num,
uns8 **  rtn_descriptor_ptr,
uns16 *  rtn_descriptor_size 
)

Referenced by usb_handle_standard_request().

Here is the caller graph for this function:

usb_state_type usb_get_state (  ) 

Definition at line 743 of file pic_usb.c.

References usb_state.

void usb_handle_class_request ( setup_data_packet  sdp  ) 

void usb_handle_ctrl_read_class (  ) 

Definition at line 125 of file usb_cdc_class.c.

References _setup_data_packet::bRequest, cm_CTRL_READ_AWAITING_STATUS, control_mode, req_GET_LINE_CODING, serial_print_int(), serial_print_str(), and usb_sdp.

Referenced by usb_handle_transaction().

Here is the call graph for this function:

Here is the caller graph for this function:

void usb_handle_ctrl_write_class ( uns8 *  data,
uns16  count 
)

void usb_handle_isr (  ) 

Definition at line 643 of file pic_usb.c.

void usb_send_data ( uns8  ep,
uns8 *  data,
uns8  send_count,
bit  first 
)

Definition at line 183 of file pic_usb.c.

References _buffer_descriptor::addr, BC8, BC9, BSTALL, _buffer_descriptor::count, DTS, DTSEN, ep_in_bd_location, ep_in_buffer_location, INCDIS, KEN, serial_print_str(), serial_putc(), _buffer_descriptor::stat, uns16, uns8, and UOWN.

Referenced by usb_handle_class_request().

Here is the call graph for this function:

Here is the caller graph for this function:

void usb_send_empty_data_pkt (  ) 

void usb_setup (  ) 

void usb_SOF_callback ( uns16  frame  ) 

Definition at line 269 of file usb_cdc_class.c.

References usb_cdc_handle_tx().

Referenced by usb_handle_isr().

Here is the call graph for this function:

Here is the caller graph for this function:

void usb_stall_ep0 (  ) 

Definition at line 175 of file pic_usb.c.

References bd0in, bd0out, BSTALL, _buffer_descriptor::stat, and UOWN.

Referenced by usb_handle_class_request(), and usb_handle_standard_request().

Here is the caller graph for this function:


Variable Documentation

Definition at line 28 of file pic_usb.c.

Definition at line 26 of file pic_usb.c.

Referenced by usb_handle_ctrl_read_class(), and usb_handle_ctrl_write_class().

Definition at line 24 of file pic_usb.c.


Generated on Tue Jul 22 09:32:46 2008 for Pic Pack by  doxygen 1.5.5