You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.6 KiB
77 lines
1.6 KiB
/*
|
|
* 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 <avr/io.h>
|
|
#include <avr/wdt.h>
|
|
#include <avr/eeprom.h>
|
|
#include <avr/interrupt.h>
|
|
#include <avr/pgmspace.h>
|
|
#include <util/delay.h>
|
|
#include <stdlib.h>
|
|
|
|
#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;
|
|
}
|
|
|
|
|