/* * This code is based on seveal VUSB-Examples the * HID was taken from the CapsLocker code from macetech * http://macetech.com/blog/?q=node/46 * */ #include "main.h" #define SECRET {'J', 'e', 'f', 'e'}; #define SECLEN 20 #define MSG "what do ya want for nothing?" #include #include #include #include #include #include #include #include "usbdrv.h" uint8_t reportBuffer[2]; /* buffer for HID reports */ uint8_t idleRate; void buildReport(uint8_t mod, uint8_t key){ reportBuffer[0] = mod; reportBuffer[1] = key; } int main(void){ #ifdef CALIB uint8_t calibrationValue; #endif uint8_t *p; uint16_t siz; uint8_t sec[SECLEN]=SECRET; InitializeMemory(); initUSART(); tx('+'); sendunum( get_otp_from_cnt(777,8,sec,SECLEN) ); #ifdef CALIB /* oszillator calibration */ calibrationValue = eeprom_read_byte(0); /* calibration value from last time */ if(calibrationValue != 0xff){ OSCCAL = calibrationValue; } #endif //CALLIB //odDebugInit(); usbDeviceDisconnect(); _delay_ms(300); /* mustn't be that exact */ usbDeviceConnect(); usbInit(); sei(); for(;;){ /* main event loop */ usbPoll(); /* we can send another key */ if(usbInterruptIsReady()){ buildReport(0x00, 'A'); usbSetInterrupt(reportBuffer, sizeof(reportBuffer)); } AnalyzeMemory(&p,&siz); sendunum(siz); _delay_ms(2000); } return 0; }