From a1a11ed4888bfd84f2215321489b25944404b6ab Mon Sep 17 00:00:00 2001 From: cpldcpu Date: Sun, 5 Jan 2014 12:09:34 +0100 Subject: firmware: first working version with polled usb --- firmware/main.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 6 deletions(-) (limited to 'firmware/main.c') diff --git a/firmware/main.c b/firmware/main.c index 1fdda03..a09bb4c 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -125,19 +125,21 @@ static void writeWordToPageBuffer(uint16_t data) { vectorTemp[0] = data; data = 0xC000 + (BOOTLOADER_ADDRESS/2) - 1; } - +/* if (currentAddress.w == USBPLUS_VECTOR_OFFSET * 2) { vectorTemp[1] = data; data = 0xC000 + (BOOTLOADER_ADDRESS/2) - 1; } - + */ // at end of page just before bootloader, write in tinyVector table // see http://embedded-creations.com/projects/attiny85-usb-bootloader-overview/avr-jtag-programmer/ // for info on how the tiny vector table works if (currentAddress.w == BOOTLOADER_ADDRESS - TINYVECTOR_RESET_OFFSET) { data = vectorTemp[0] + ((FLASHEND + 1) - BOOTLOADER_ADDRESS)/2 + 2 + RESET_VECTOR_OFFSET; +/* } else if (currentAddress.w == BOOTLOADER_ADDRESS - TINYVECTOR_USBPLUS_OFFSET) { data = vectorTemp[1] + ((FLASHEND + 1) - BOOTLOADER_ADDRESS)/2 + 1 + USBPLUS_VECTOR_OFFSET; +*/ #if (!OSCCAL_RESTORE) && OSCCAL_16_5MHz } else if (currentAddress.w == BOOTLOADER_ADDRESS - TINYVECTOR_OSCCAL_OFFSET) { data = OSCCAL; @@ -286,7 +288,7 @@ static void wait_usb_interrupt( void ) USB_INTR_VECTOR(); // Wait a little while longer in case another one comes - uchar n = 250; // about 90us timeout + uchar n = 50; // about 90us timeout do { if ( !--n ) goto handled; @@ -302,6 +304,8 @@ int main(void) { bootLoaderInit(); + DDRB|=3; + if (bootLoaderStartCondition()||(pgm_read_byte(BOOTLOADER_ADDRESS - TINYVECTOR_RESET_OFFSET + 1)==0xff)) { initHardware(); @@ -314,7 +318,9 @@ int main(void) { } do { - +// USB_INTR_PENDING = 1<