22 #include "USBDescriptor.h" 23 #include "USBDevice_Types.h" 25 #include "USBDevice.h" 26 #include "OperationList.h" 36 #define CDC_MAX_PACKET_SIZE 64 53 USBCDC(
bool connect_blocking =
true, uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001);
71 USBCDC(
USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
102 bool send(uint8_t *buffer, uint32_t size);
112 void send_nb(uint8_t *buffer, uint32_t size, uint32_t *actual,
bool now =
true);
126 bool receive(uint8_t *buffer, uint32_t size, uint32_t *actual = NULL);
135 void receive_nb(uint8_t *buffer, uint32_t size, uint32_t *actual);
143 virtual const uint8_t *device_desc();
150 virtual const uint8_t *string_iproduct_desc();
157 virtual const uint8_t *string_iinterface_desc();
165 virtual const uint8_t *configuration_desc(uint8_t index);
176 virtual void line_coding_changed(
int baud,
int bits,
int parity,
int stop) {};
181 virtual void data_rx() {}
186 virtual void data_tx() {}
198 virtual void callback_set_configuration(uint8_t configuration);
199 virtual void callback_set_interface(uint16_t interface, uint8_t alternate);
203 void _change_terminal_connected(
bool connected);
205 void _send_isr_start();
208 void _receive_isr_start();
215 uint8_t _cdc_line_coding[7];
216 uint8_t _cdc_new_line_coding[7];
217 uint8_t _config_descriptor[75];
220 bool _terminal_connected;
223 bool _tx_in_progress;
224 uint8_t _tx_buffer[CDC_MAX_PACKET_SIZE];
229 bool _rx_in_progress;
230 uint8_t _rx_buffer[CDC_MAX_PACKET_SIZE];
virtual ~USBCDC()
Destroy this object.
void receive_nb(uint8_t *buffer, uint32_t size, uint32_t *actual)
Read from the receive buffer.
Abstract interface to physical USB hardware.
virtual void callback_request(const setup_packet_t *setup)
Called by USBDevice on Endpoint0 request.
bool ready()
Check if this class is ready.
virtual void callback_state_change(DeviceState new_state)
Called when USB changes state.
virtual void callback_reset()
Called by USBDevice layer on bus reset.
void send_nb(uint8_t *buffer, uint32_t size, uint32_t *actual, bool now=true)
Send what there is room for.
USBCDC(bool connect_blocking=true, uint16_t vendor_id=0x1f00, uint16_t product_id=0x2012, uint16_t product_release=0x0001)
Basic constructor.
virtual void callback_request_xfer_done(const setup_packet_t *setup, bool aborted)
Called by USBDevice on data stage completion.
void wait_ready()
Block until the terminal is connected.