14 #include <util/atomic.h> 20 volatile unsigned char usb_stored_control = 0;
21 volatile unsigned char usb_notify_state = EP_NOTE_IDLE;
29 CDC_LineEncoding_t LineEncoding =
36 unsigned int usb_handle_ring_rx (
void *pt,
unsigned int );
37 unsigned int usb_handle_ring_tx (
void *pt,
unsigned int );
38 unsigned int usb_handle_ring_note (
void *pt,
unsigned int );
50 void usb_cdc_dcd_on (
void )
55 void usb_cdc_dcd_off (
void )
63 void usb_init (
void )
73 #ifdef USB_DEF_CONFIG_CLK 77 EP_DEF_init_buffer( ep_in );
78 EP_DEF_init_buffer( ep_out );
79 EP_DEF_init_buffer( ep_note );
83 USB.INTCTRLA = USB_BUSEVIE_bm | USB_INTLVL_HI_gc;
84 USB.INTCTRLB = USB_TRNIE_bm | USB_SETUPIE_bm;
88 #ifdef USB_DEF_CONFIG_IRQ 89 PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm;
106 unsigned int usb_handle_ring_rx (
void *pt,
unsigned int le )
111 memcpy ( cdc_rxb.data, (
unsigned char *) pt, le );
125 unsigned int usb_handle_ring_tx (
void *pt,
unsigned int le )
127 unsigned int num = 0;
130 memcpy ( (
unsigned char *) pt, cdc_txb.data, cdc_txb.len );
140 unsigned int usb_handle_ring_note (
void *pt,
unsigned int le )
144 if ( usb_notify_state )
147 if ( usb_notify_state < EP_NOTE_SEND )
155 usb_notify_state |= EP_NOTE_SEND;
158 if ( usb_notify_state == (EP_NOTE_SET_DCD | EP_NOTE_SEND) )
165 *(
unsigned int *) pt = 0;
167 usb_notify_state = EP_NOTE_IDLE;
193 EP_DEF_init( ep_in );
194 EP_DEF_init( ep_out );
195 EP_DEF_init( ep_note );
225 switch (usb_stored_control)
229 memcpy ( &LineEncoding, data,
sizeof(CDC_LineEncoding_t) );
242 USB_EP_t* e = &pair->ep[1];
243 USB_EP_t* b = &pair->ep[1];
250 == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE) )
254 memcpy ( ep0_buf_in, (
char *) &LineEncoding,
255 sizeof(CDC_LineEncoding_t) );
257 b->DATAPTR = (unsigned) ep0_buf_in;
258 b->CNT =
sizeof(CDC_LineEncoding_t);
260 USB_EP_BUSNACK0_bm | USB_EP_TRNCOMPL0_bm );
267 == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE) )
272 b->DATAPTR = (unsigned) ep0_buf_in;
275 USB_EP_BUSNACK0_bm | USB_EP_TRNCOMPL0_bm );
282 == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE) )
285 b->DATAPTR = (unsigned) ep0_buf_in;
288 USB_EP_BUSNACK0_bm | USB_EP_TRNCOMPL0_bm );
296 == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE) )
300 b->DATAPTR = (unsigned) ep0_buf_in;
303 USB_EP_BUSNACK0_bm | USB_EP_TRNCOMPL0_bm );
void EVENT_USB_Device_WakeUp(void)
Bibliothek zur USB-Kommunikation von Jürgen W.
bool EVENT_USB_Device_SetInterface(uint8_t interface, uint8_t altsetting)
void EVENT_USB_Device_ControlOUT(uint8_t *data, uint8_t len)
bool EVENT_USB_Device_ControlRequest(USB_Request_Header_t *req)
void EVENT_USB_Device_Reset(void)
Bibliothek zur USB-Kommunikation von Jürgen W.
#define CDC_CONTROL_LINE_IN_DCD
void EVENT_USB_Device_Suspend(void)
#define LACR16(addr, msk)
From Atmel: Macros for XMEGA instructions not yet supported by the toolchain.
#define CDC_CONTROL_LINE_IN_DSR
#define CDC_NOTIFICATION_EPADDR
Bibliothek zur USB-Kommunikation von Jürgen W.
void EVENT_USB_Device_ConfigurationChanged(uint8_t config)