15 #include <util/atomic.h> 19 uint8_t ep0_buf_in[USB_DEF_EP0_SIZE];
20 uint8_t ep0_buf_out[USB_DEF_EP0_SIZE];
26 void ep_def_init_buffer (
EP_data *p )
28 if ( p->ep & USB_EP_PP )
30 endpoints[p->ep & 0x0f].in.DATAPTR = (
unsigned int) p->buf;
31 endpoints[p->ep & 0x0f].out.DATAPTR = ((
unsigned int) p->buf) + p->len;
35 if ( p->ep & ENDPOINT_DIR_MASK )
37 endpoints[p->ep & 0x0f].in.DATAPTR = (
unsigned int) p->buf;
41 endpoints[p->ep & 0x0f].out.DATAPTR = (
unsigned int) p->buf;
50 ep_def_init_buffer ( p );
53 c = &endpoints[p->ep & 0x0f].in;
54 b = &endpoints[p->ep & 0x0f].out;
56 if ( p->ep & USB_EP_PP )
58 if ( p->ep & ENDPOINT_DIR_MASK )
62 c->STATUS = USB_EP_BUSNACK0_bm | USB_EP_BUSNACK1_bm;
64 p->type | USB_EP_size_to_gc( p->len ) | USB_EP_PINGPONG_bm;
67 b->STATUS = USB_EP_BUSNACK0_bm;
75 p->type | USB_EP_size_to_gc( p->len ) | USB_EP_PINGPONG_bm;
83 if ( p->ep & ENDPOINT_DIR_MASK )
87 c->STATUS = USB_EP_BUSNACK0_bm | USB_EP_BUSNACK1_bm;
88 c->CTRL = p->type | USB_EP_size_to_gc( p->len );
95 b->CTRL = p->type | USB_EP_size_to_gc( p->len );
107 c = &endpoints[ad].out;
108 if ( p->ep & USB_EP_PP )
115 b = &endpoints[ad].out;
116 if ( c->STATUS & (USB_EP_TRNCOMPL0_bm) )
118 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
120 if ( p->handler ( (
unsigned char *) b->DATAPTR, b->CNT ) )
124 USB_EP_BUSNACK0_bm | USB_EP_TRNCOMPL0_bm | USB_EP_OVF_bm );
135 b = &endpoints[ad].in;
136 if ( c->STATUS & (USB_EP_TRNCOMPL1_bm) )
138 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
140 if ( p->handler ( (
unsigned char *) b->DATAPTR, b->CNT ) )
144 USB_EP_BUSNACK1_bm | USB_EP_TRNCOMPL1_bm | USB_EP_OVF_bm );
155 if ( c->STATUS & (USB_EP_TRNCOMPL0_bm) )
157 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
159 if ( p->handler ( (
unsigned char *) b->DATAPTR, b->CNT ) )
163 USB_EP_BUSNACK0_bm | USB_EP_TRNCOMPL0_bm | USB_EP_OVF_bm );
179 c = &endpoints[ad].in;
181 if ( p->ep & USB_EP_PP )
188 b = &endpoints[ad].out;
189 if ( c->STATUS & (USB_EP_BUSNACK1_bm) )
191 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
193 le = p->handler ( (
unsigned char *) b->DATAPTR,
199 USB_EP_BUSNACK1_bm | USB_EP_TRNCOMPL1_bm );
210 b = &endpoints[ad].in;
211 if ( c->STATUS & (USB_EP_BUSNACK0_bm) )
213 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
215 le = p->handler ( (
unsigned char *) b->DATAPTR,
221 USB_EP_BUSNACK0_bm | USB_EP_TRNCOMPL0_bm );
232 if ( c->STATUS & (USB_EP_BUSNACK0_bm) )
234 ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
236 le = p->handler ( (
unsigned char *) b->DATAPTR, p->len );
241 USB_EP_BUSNACK0_bm | USB_EP_TRNCOMPL0_bm );
Bibliothek zur USB-Kommunikation von Jürgen W.
#define LACR16(addr, msk)
From Atmel: Macros for XMEGA instructions not yet supported by the toolchain.