Author | Albert Faber, Copyright © 2008..2009, all rights reserved. |
Adapted-by | - Matthew Schinkel |
Compiler | >=2.4q2 |
USB Communication Device Class (CDC) code This USB library files contains the low level implementation to perform serial communication over a USB interface. The usage of this library requires detailed knowledge of the USB interface and requires that several configuration parameters are defined correctly. In order to make USB serial communication more accessible for the end user, I would highly recommend to use the usb_serial library
http://www.usb.org for USB specifications
No dependency found
var volatile byte cdc_rx_wr = 0
const byte USB_REQ_GET_ENCAPSULATED_RESPONSE = 0x01
var volatile byte cdc_tx_wr=0
var byte cdc_line_status = 0x00
var volatile dword cdc_line_coding_dte_rate at cdc_line_coding[0]
const byte USB_REQ_SEND_BREAK = 0x23
var volatile byte cdc_rx_rd = 0
var volatile byte cdc_tx_rd=0
const byte USB_REQ_GET_LINE_CODING = 0x21
const byte USB_REQ_SET_LINE_CODING = 0x20
var volatile byte cdc_rx_free = USB_CDC_RX_BUFFER_SIZE
var byte cdc_rx_buffer[USB_CDC_RX_BUFFER_SIZE]
const byte USB_REQ_SET_COMM_FEATURE = 0x02
var volatile byte cdc_line_coding_parity at cdc_line_coding[5]
var volatile byte cdc_line_coding_stop_bits at cdc_line_coding[4]
const byte USB_REQ_CLEAR_COMM_FEATURE = 0x04
var volatile byte cdc_line_coding[7]
var bit last_packet_is_full = false
var volatile byte cdc_line_coding_data_bits at cdc_line_coding[6]
const byte USB_REQ_SEND_ENCAPSULATED_COMMAND = 0x00
const byte USB_REQ_SET_CONTROL_LINE_STATE = 0x22
usb_handle_class_request_callback()
usb_handle_class_ctrl_read_callback()
usb_ep_data_out_callback(byte in end_point, word in buffer_addr, byte in byte_count)
usb_cdc_putc(byte in c)
usb_cdc_handle_tx()
usb_ep_data_in_callback(byte in end_point, word in buffer_addr, byte in byte_count)
usb_handle_class_ctrl_write_callback()
usb_sof_callback()
usb_cdc_setup()
usb_cdc_rx_avail() return bit
does_sie_owns_tx_buffer() return bit
usb_cdc_line_status() return byte
usb_cdc_getc() return byte
usb_cdc_tx_empty() return byte
var volatile byte cdc_rx_wr = 0
No documentation found
const byte USB_REQ_GET_ENCAPSULATED_RESPONSE = 0x01
No documentation found
var volatile byte cdc_tx_wr=0
No documentation found
var byte cdc_line_status = 0x00
No documentation found
var volatile dword cdc_line_coding_dte_rate at cdc_line_coding[0]
No documentation found
const byte USB_REQ_SEND_BREAK = 0x23
No documentation found
var volatile byte cdc_rx_rd = 0
No documentation found
var volatile byte cdc_tx_rd=0
No documentation found
const byte USB_REQ_GET_LINE_CODING = 0x21
No documentation found
const byte USB_REQ_SET_LINE_CODING = 0x20
No documentation found
var volatile byte cdc_rx_free = USB_CDC_RX_BUFFER_SIZE
No documentation found
var byte cdc_rx_buffer[USB_CDC_RX_BUFFER_SIZE]
No documentation found
const byte USB_REQ_SET_COMM_FEATURE = 0x02
No documentation found
var volatile byte cdc_line_coding_parity at cdc_line_coding[5]
0=None, 1=Odd, 2=Even, 3=Mark, 4=Space
var volatile byte cdc_line_coding_stop_bits at cdc_line_coding[4]
0=1 stop bit, 1=1.5 stop bits, 2=2 stop bits
const byte USB_REQ_CLEAR_COMM_FEATURE = 0x04
No documentation found
var volatile byte cdc_line_coding[7]
No documentation found
var bit last_packet_is_full = false
No documentation found
var volatile byte cdc_line_coding_data_bits at cdc_line_coding[6]
5,6,7,8 or 16 bits
const byte USB_REQ_SEND_ENCAPSULATED_COMMAND = 0x00
No documentation found
const byte USB_REQ_SET_CONTROL_LINE_STATE = 0x22
No documentation found
usb_handle_class_request_callback()
No documentation found
usb_handle_class_ctrl_read_callback()
No documentation found
usb_ep_data_out_callback(byte in end_point, word in buffer_addr, byte in byte_count)
No documentation found
usb_cdc_putc(byte in c)
This usb_cdc_putc will transmit the specified character. Under normal conditions the character to be transmitted is placed into the fifo, so the call will be non blocking. This implies that buffer overruns can occur when the transmit FIFO is full. Therefore it is adviced to check the transmit FIFO state before calling this procedure to avoid buffer overruns. These buffer overrun issues have been addressed in the usb_serial library, therefore it is highly recommended to use this library instead of calling this low level procedure
usb_cdc_handle_tx()
This procedure will handle the transmission of the (bulk) data. The procedure check if there are pending characters in the tranmit FIFO. These character(s) are send in chunk(s), the chunk size is dependent on the conifguration of the bulk interface endpoint
usb_ep_data_in_callback(byte in end_point, word in buffer_addr, byte in byte_count)
This function is called when data can be transmitted via the bulk interface
usb_handle_class_ctrl_write_callback()
No documentation found
usb_sof_callback()
No documentation found
usb_cdc_setup()
This procedure will intialize the line status of the communicatin device class
usb_cdc_rx_avail() return bit
This function returns there has been a character received, function will return true if there is at least one pending receive character, false otherwise
does_sie_owns_tx_buffer() return bit
This function returns the status of the SIE tx buffer. Either the SIE can own the transmit buffer (tranmit is pending) or it can be owned by the CPU. This function return true if the SIE owns the buffer, otherwise false is returned
usb_cdc_line_status() return byte
This function returns the line status. If on the host side the COM port has not been opened, the return status will be 0x00, otherwise it will be != 0
usb_cdc_getc() return byte
This usb_cdc_getc function wait (blocking) until a character has been received. The byte value of the received character is returned by this function
usb_cdc_tx_empty() return byte
This function returns the empty status of the transmit FIFO, it will return true if transmit FIFO is empty, false otherwise