bootloader_firmware/usbdrv/usbdrv.h File Reference
#include "usbconfig.h"
#include "iarcompat.h"
Go to the source code of this file.
Define Documentation
#define schar signed char |
#define uchar unsigned char |
#define USB_BUFFER_SECTION ".bss" |
#define USB_INTR_CFG MCUCR |
#define USB_INTR_CFG_CLR 0 |
#define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) |
#define USB_INTR_ENABLE GICR |
#define USB_INTR_ENABLE_BIT INT0 |
#define USB_INTR_PENDING GIFR |
#define USB_INTR_PENDING_BIT INTF0 |
#define USB_PULLUP_DDR (*(&USB_CFG_PULLUP_IOPORT - 1)) |
#define USB_PULLUP_OUT USB_CFG_PULLUP_IOPORT |
#define USB_STRING_DESCRIPTOR_HEADER |
( |
stringLength |
|
) |
((2*(stringLength)+2) | (3<<8)) |
#define USBATTR_BUSPOWER 0x80 |
#define USBATTR_REMOTEWAKE 0x20 |
#define USBATTR_SELFPOWER 0x40 |
#define USBDDR (*(&USB_CFG_IOPORT - 1)) |
#define USBDESCR_CONFIG 2 |
#define USBDESCR_DEVICE 1 |
#define USBDESCR_ENDPOINT 5 |
#define USBDESCR_HID 0x21 |
#define USBDESCR_HID_PHYS 0x23 |
#define USBDESCR_HID_REPORT 0x22 |
#define USBDESCR_INTERFACE 4 |
#define USBDESCR_STRING 3 |
#define USBDRV_VERSION 20060314 |
#define USBIN (*(&USB_CFG_IOPORT - 2)) |
#define usbInterruptIsReady |
( |
|
) |
(usbTxLen1 == -1) |
#define USBMASK ((1<<USB_CFG_DPLUS_BIT) | 1) |
#define USBOUT USB_CFG_IOPORT |
#define USBPID_DATA0 0xc3 |
#define USBPID_DATA1 0x4b |
#define USBPID_SETUP 0x2d |
#define USBPID_STALL 0x1e |
#define USBRQ_CLEAR_FEATURE 1 |
#define USBRQ_DIR_DEVICE_TO_HOST (1<<7) |
#define USBRQ_DIR_HOST_TO_DEVICE (0<<7) |
#define USBRQ_DIR_MASK 0x80 |
#define USBRQ_GET_CONFIGURATION 8 |
#define USBRQ_GET_DESCRIPTOR 6 |
#define USBRQ_GET_INTERFACE 10 |
#define USBRQ_GET_STATUS 0 |
#define USBRQ_HID_GET_IDLE 0x02 |
#define USBRQ_HID_GET_PROTOCOL 0x03 |
#define USBRQ_HID_GET_REPORT 0x01 |
#define USBRQ_HID_SET_IDLE 0x0a |
#define USBRQ_HID_SET_PROTOCOL 0x0b |
#define USBRQ_HID_SET_REPORT 0x09 |
#define USBRQ_RCPT_DEVICE 0 |
#define USBRQ_RCPT_ENDPOINT 2 |
#define USBRQ_RCPT_INTERFACE 1 |
#define USBRQ_RCPT_MASK 0x1f |
#define USBRQ_SET_ADDRESS 5 |
#define USBRQ_SET_CONFIGURATION 9 |
#define USBRQ_SET_DESCRIPTOR 7 |
#define USBRQ_SET_FEATURE 3 |
#define USBRQ_SET_INTERFACE 11 |
#define USBRQ_SYNCH_FRAME 12 |
#define USBRQ_TYPE_CLASS (1<<5) |
#define USBRQ_TYPE_MASK 0x60 |
#define USBRQ_TYPE_STANDARD (0<<5) |
#define USBRQ_TYPE_VENDOR (2<<5) |
Typedef Documentation
Function Documentation
unsigned usbCrc16 |
( |
uchar * |
data, |
|
|
uchar |
len | |
|
) |
| | |
unsigned usbCrc16Append |
( |
unsigned char * |
data, |
|
|
unsigned char |
len | |
|
) |
| | |
uchar usbFunctionSetup |
( |
uchar |
data[8] |
) |
|
Definition at line 55 of file main.c.
00056 {
00057 uchar len = 0;
00058
00059 if (data[1] == USBBOOT_FUNC_LEAVE_BOOT) {
00060 leaveBootloader();
00061 } else if (data[1] == USBBOOT_FUNC_WRITE_PAGE) {
00062
00063 state = STATE_WRITE_PAGE;
00064
00065 page_address = (data[3] << 8) | data[2];
00066 page_offset = 0;
00067
00068 eeprom_busy_wait();
00069 cli();
00070 boot_page_erase(page_address);
00071 sei();
00072 boot_spm_busy_wait();
00073
00074 len = 0xff;
00075
00076 } else if (data[1] == USBBOOT_FUNC_GET_PAGESIZE) {
00077
00078 replyBuffer[0] = SPM_PAGESIZE >> 8;
00079 replyBuffer[1] = SPM_PAGESIZE & 0xff;
00080 len = 2;
00081
00082 }
00083
00084 usbMsgPtr = replyBuffer;
00085
00086 return len;
00087 }
Definition at line 452 of file usbdrv.c.
00453 {
00454 uchar len;
00455
00456 if((len = usbRxLen) > 0){
00457
00458
00459
00460
00461
00462
00463 len -= 3;
00464 if(len < 128){
00465 converter_t appBuf;
00466 appBuf.ptr = (uchar *)usbRxBuf;
00467 appBuf.bytes[0] = usbAppBuf;
00468 appBuf.bytes[0]++;
00469 usbProcessRx(appBuf.ptr, len);
00470 }
00471 usbRxLen = 0;
00472 }
00473 if(usbMsgLen != 0xff){
00474 if(usbTxLen < 0)
00475 usbBuildTxBlock();
00476 }
00477 if(isNotSE0()){
00478 usbIsReset = 0;
00479 }else{
00480
00481 if(!usbIsReset){
00482 uchar i;
00483 for(i=100;i;i--){
00484 if(isNotSE0())
00485 goto notUsbReset;
00486 }
00487 usbIsReset = 1;
00488 usbNewDeviceAddr = 0;
00489 usbDeviceAddr = 0;
00490 #if USB_CFG_IMPLEMENT_HALT
00491 usbHalted1 = 0;
00492 #endif
00493 DBG1(0xff, 0, 0);
00494 notUsbReset:;
00495 }
00496 }
00497 }
void usbSetInterrupt |
( |
uchar * |
data, |
|
|
uchar |
len | |
|
) |
| | |
Variable Documentation