From beb8d0c4e29b3d223fd7d1edeb4e72b4752feba8 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Fri, 9 Dec 2011 23:15:06 +0100 Subject: [PATCH] Some more code size optimizations. --- firmware/globals.h | 10 ++++++++-- firmware/main.c | 41 ++++++----------------------------------- firmware/main.h | 17 +++++++++-------- firmware/usb.c | 4 ++-- 4 files changed, 25 insertions(+), 47 deletions(-) diff --git a/firmware/globals.h b/firmware/globals.h index cddcba7..80d9227 100644 --- a/firmware/globals.h +++ b/firmware/globals.h @@ -1,8 +1,14 @@ +/* CTHN.de MiniLEDCube + * + * Kai Lauterbach (klaute at web dot de) + * + * License: General Public License (GPL v3) + * + */ + #define F_CPU 12000000UL // Bitshifting #define set_bit(var, bit) ((var) |= (1 << (bit))) #define clear_bit(var, bit) ((var) &= (unsigned)~(1 << (bit))) -#define sleep_nop(cnt) for (uint8_t i = 0; i < cnt; i++) { asm volatile("nop"::); } - diff --git a/firmware/main.c b/firmware/main.c index 83d85e5..9e7e30f 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -1,10 +1,11 @@ -/* - * Based on the code of the Mini-LED-Cube 1.0 +/* CTHN.de MiniLEDCube * - * Copyright (C) 2009 Paul Wilhelm - * http: *mosfetkiller.de/?s=miniledcube + * Kai Lauterbach (klaute at web dot de) + * + * Based on http://mosfetkiller.de/?s=miniledcube + * + * License: General Public License (GPL v3) * - * Changed by Kai Lauterbach (klaute at web dot de) */ #include "main.h" @@ -16,41 +17,12 @@ int main(void) init(); init_usb(); - //uint8_t anim = 0; - // Hauptschleife - //while (1) for (;;) { //wdt_reset(); // we are alive, so don't reset the µC usbPoll(); // keep connected - // hier pause einfügen - //_delay_ms(1); // beispielsweise 50 ms => muss angepasst werden an usb kommunikation - - /*anim++; - - if (anim >= 0) - { - if (cube == 0xffffffff) - cube = 0x07007007; - else if (cube == 0x07007007) - cube = 0x00000000; - else if (cube == 0x00000000) - cube = 0xffffffff; - - anim = 0; - }*/ - /*if (anim >= 40) - { - cube += 1; - - if (cube > 0x07ffffff) - cube = 0; - - anim = 0; - }*/ - } } @@ -86,7 +58,6 @@ void init() } // Interruptvektor von TIMER1 -//SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise ISR (TIMER1_COMPA_vect) { diff --git a/firmware/main.h b/firmware/main.h index 4453228..09f21a9 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -1,11 +1,12 @@ -// Mini-LED-Cube 1.0 -// -// Copyright (C) 2009 Paul Wilhelm -// http://mosfetkiller.de/?s=miniledcube -// -// Changed by Kai Lauterbach (klaute at web dot de) -// -// Externes Quarz, CKDIV8 Disabled +/* CTHN.de MiniLEDCube + * + * Kai Lauterbach (klaute at web dot de) + * + * Based on http://mosfetkiller.de/?s=miniledcube + * + * License: General Public License (GPL v3) + * + */ #ifndef __main_h__ #define __main_h__ diff --git a/firmware/usb.c b/firmware/usb.c index e638eb2..03d11f9 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -30,8 +30,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) cube = (cube & (uint32_t)0xffff0000) | rq->wValue.bytes[0] + (rq->wValue.bytes[1] << 8); - } else if ( rq->wIndex.bytes[0] == 1 ) - { + //} else if ( rq->wIndex.bytes[0] == 1 ) + } else { cube = (cube & (uint32_t)0x0000ffff) | ((uint32_t)(rq->wValue.bytes[0] + (rq->wValue.bytes[1] << 8)) << 16);