#include "iarcompat.h"#include <avr/io.h>#include <avr/pgmspace.h>#include "usbdrv.h"#include "oddebug.h"Go to the source code of this file.
| #define GET_DESCRIPTOR | ( | cfgProp, | |||
| staticName | ) |
Value:
if(cfgProp){ \ if((cfgProp) & USB_PROP_IS_RAM) \ flags &= ~USB_FLG_MSGPTR_IS_ROM; \ if((cfgProp) & USB_PROP_IS_DYNAMIC){ \ replyLen = usbFunctionDescriptor(rq); \ }else{ \ replyData = (uchar *)(staticName); \ SET_REPLY_LEN((cfgProp) & 0xff); \ } \ }
| #define SET_REPLY_LEN | ( | len | ) | replyLen = (len); usbMsgPtr = replyData |
| #define USB_CFG_DESCR_PROPS_CONFIGURATION sizeof(usbDescriptorConfiguration) |
| #define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice) |
| #define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0) |
| #define USB_CFG_DESCR_PROPS_STRING_PRODUCT sizeof(usbDescriptorStringDevice) |
| #define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor) |
| USB_PUBLIC void usbInit | ( | void | ) |
Definition at line 566 of file usbdrv.c.
Referenced by main().
00567 { 00568 #if USB_INTR_CFG_SET != 0 00569 USB_INTR_CFG |= USB_INTR_CFG_SET; 00570 #endif 00571 #if USB_INTR_CFG_CLR != 0 00572 USB_INTR_CFG &= ~(USB_INTR_CFG_CLR); 00573 #endif 00574 USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT); 00575 usbResetDataToggling(); 00576 }
| USB_PUBLIC void usbPoll | ( | void | ) |
Definition at line 526 of file usbdrv.c.
Referenced by main().
00527 { 00528 schar len; 00529 uchar i; 00530 00531 if((len = usbRxLen) > 0){ 00532 /* We could check CRC16 here -- but ACK has already been sent anyway. If you 00533 * need data integrity checks with this driver, check the CRC in your app 00534 * code and report errors back to the host. Since the ACK was already sent, 00535 * retries must be handled on application level. 00536 * unsigned crc = usbCrc16(buffer + 1, usbRxLen - 3); 00537 */ 00538 usbProcessRx(usbRxBuf + USB_BUFSIZE + 1 - usbInputBufOffset, len - 3); 00539 #if USB_CFG_HAVE_FLOWCONTROL 00540 if(usbRxLen > 0) /* only mark as available if not inactivated */ 00541 usbRxLen = 0; 00542 #else 00543 usbRxLen = 0; /* mark rx buffer as available */ 00544 #endif 00545 } 00546 if(usbTxLen & 0x10){ /* transmit system idle */ 00547 if(usbMsgLen != 0xff){ /* transmit data pending? */ 00548 usbBuildTxBlock(); 00549 } 00550 } 00551 for(i = 10; i > 0; i--){ 00552 if(isNotSE0()) 00553 break; 00554 } 00555 if(i == 0){ /* RESET condition, called multiple times during reset */ 00556 usbNewDeviceAddr = 0; 00557 usbDeviceAddr = 0; 00558 usbResetStall(); 00559 DBG1(0xff, 0, 0); 00560 } 00561 usbHandleResetHook(i); 00562 }
| USB_PUBLIC void usbSetInterrupt | ( | uchar * | data, | |
| uchar | len | |||
| ) |
Definition at line 229 of file usbdrv.c.
Referenced by main().
00230 { 00231 uchar *p, i; 00232 00233 #if USB_CFG_IMPLEMENT_HALT 00234 if(usbTxLen1 == USBPID_STALL) 00235 return; 00236 #endif 00237 #if 0 /* No runtime checks! Caller is responsible for valid data! */ 00238 if(len > 8) /* interrupt transfers are limited to 8 bytes */ 00239 len = 8; 00240 #endif 00241 if(usbTxLen1 & 0x10){ /* packet buffer was empty */ 00242 usbTxBuf1[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* toggle token */ 00243 }else{ 00244 usbTxLen1 = USBPID_NAK; /* avoid sending outdated (overwritten) interrupt data */ 00245 } 00246 p = usbTxBuf1 + 1; 00247 for(i=len;i--;) 00248 *p++ = *data++; 00249 usbCrc16Append(&usbTxBuf1[1], len); 00250 usbTxLen1 = len + 4; /* len must be given including sync byte */ 00251 DBG2(0x21, usbTxBuf1, len + 3); 00252 }
| uchar usbConfiguration |
| uchar usbCurrentTok |
| PROGMEM char usbDescriptorDevice[] |
Initial value:
{
18,
USBDESCR_DEVICE,
0x10, 0x01,
USB_CFG_DEVICE_CLASS,
USB_CFG_DEVICE_SUBCLASS,
0,
8,
(char)USB_CFG_VENDOR_ID,
(char)USB_CFG_DEVICE_ID,
USB_CFG_DEVICE_VERSION,
USB_CFG_DESCR_PROPS_STRING_VENDOR != 0 ? 1 : 0,
USB_CFG_DESCR_PROPS_STRING_PRODUCT != 0 ? 2 : 0,
USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER != 0 ? 3 : 0,
1,
}
| PROGMEM char usbDescriptorString0[] |
Initial value:
Initial value:
| uchar usbDeviceAddr |
| uchar usbInputBufOffset |
| uchar* usbMsgPtr |
| uchar usbNewDeviceAddr |
| uchar usbRxToken |
| uchar usbTxBuf1[USB_BUFSIZE] |
| volatile uchar usbTxLen = USBPID_NAK |
| volatile uchar usbTxLen1 = USBPID_NAK |
1.5.8