X-Git-Url: https://git.cryptolib.org/?p=labortage2013badge.git;a=blobdiff_plain;f=firmware%2Fmain.c;h=6f756dee5225d5b3cd689ebd6f3b7cd688d39192;hp=10183973c8b8b5a5552b3fa5df41f095339eaebf;hb=d6003d9a8f792c6e7198039e43693c36bf5f4550;hpb=1a21d767bb3ed3f60bc0adcad521e3f8a91a458f diff --git a/firmware/main.c b/firmware/main.c index 1018397..6f756de 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -34,7 +34,6 @@ different port or bit, change the macros below: #include "usbdrv.h" #include "oddebug.h" /* This is also an example for using debug macros */ #include "requests.h" /* The custom request numbers we use */ -#include "special_functions.h" #include "hotp.h" #if !SIMPLE_COUNTER #include "percnt2.h" @@ -261,20 +260,6 @@ int8_t button_get_debounced(volatile uint8_t debounce_count) { return v ? 0 : 1; } -static -void init_temperature_sensor(void){ - ADMUX = 0x8F; - ADCSRA = 0x87; -} - -static -uint16_t read_temperture_sensor(void){ - ADCSRA |= 0x40; - while(ADCSRA & 0x40) - ; - return ADC; -} - usbMsgLen_t usbFunctionSetup(uchar data[8]) { usbRequest_t *rq = (usbRequest_t *)data; @@ -364,20 +349,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) usbMsgPtr = dbg_buffer; return len; } - case CUSTOM_RQ_READ_MEM: - usbMsgPtr = (uchar*)rq->wValue.word; - return rq->wLength.word; - case CUSTOM_RQ_WRITE_MEM: - case CUSTOM_RQ_EXEC_SPM: -/* uni_buffer_fill = 4; - uni_buffer.w16[0] = rq->wValue.word; - uni_buffer.w16[1] = rq->wLength.word; - return USB_NO_MSG; -*/ case CUSTOM_RQ_READ_FLASH: - uni_buffer.w16[0] = rq->wValue.word; - uni_buffer.w16[1] = rq->wLength.word; - uni_buffer_fill = 4; - return USB_NO_MSG; case CUSTOM_RQ_RESET: soft_reset((uint8_t)(rq->wValue.word)); break; @@ -385,10 +356,6 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) uni_buffer.w8[0] = button_get_debounced(25); usbMsgPtr = uni_buffer.w8; return 1; - case CUSTOM_RQ_READ_TMPSENS: - uni_buffer.w16[0] = read_temperture_sensor(); - usbMsgPtr = uni_buffer.w8; - return 2; } } @@ -422,46 +389,12 @@ uchar usbFunctionWrite(uchar *data, uchar len) } memcpy(dbg_buffer, data, len); return 1; - case CUSTOM_RQ_WRITE_MEM: - memcpy(uni_buffer.ptr[0], data, len); - uni_buffer.w16[0] += len; - return !(uni_buffer.w16[1] -= len); - case CUSTOM_RQ_EXEC_SPM: - if(uni_buffer_fill < 8){ - uint8_t l = 8 - uni_buffer_fill; - if(len 8) { - memcpy(uni_buffer.ptr[0], data, len); - uni_buffer.w16[0] += len; - return 0; - } else { - memcpy(&(uni_buffer.w8[uni_buffer_fill]), data, len); - exec_spm(uni_buffer.w16[2], uni_buffer.w16[3], uni_buffer.ptr[0], data, len); - return 1; - } default: return 1; } return 0; } uchar usbFunctionRead(uchar *data, uchar len){ - uchar ret = len; - switch(current_command){ - case CUSTOM_RQ_READ_FLASH: - while(len--){ - *data++ = pgm_read_byte((uni_buffer.w16[0])++); - } - return ret; - default: - break; - } return 0; } @@ -523,7 +456,6 @@ int main(void) DDRB &= ~_BV(BUTTON_PIN); /* make button pin input */ PORTB |= _BV(BUTTON_PIN); /* turn on pull-up resistor */ - init_temperature_sensor(); counter_init(); usbInit(); usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */