Some more code size optimizations.

This commit is contained in:
Kai Lauterbach 2011-12-09 23:15:06 +01:00
parent 9aca5cf6f9
commit beb8d0c4e2
4 changed files with 25 additions and 47 deletions

View file

@ -1,8 +1,14 @@
/* CTHN.de MiniLEDCube
*
* Kai Lauterbach (klaute at web dot de)
*
* License: General Public License (GPL v3)
*
*/
#define F_CPU 12000000UL #define F_CPU 12000000UL
// Bitshifting // Bitshifting
#define set_bit(var, bit) ((var) |= (1 << (bit))) #define set_bit(var, bit) ((var) |= (1 << (bit)))
#define clear_bit(var, bit) ((var) &= (unsigned)~(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"::); }

View file

@ -1,10 +1,11 @@
/* /* CTHN.de MiniLEDCube
* Based on the code of the Mini-LED-Cube 1.0
* *
* Copyright (C) 2009 Paul Wilhelm <paul@mosfetkiller.de> * Kai Lauterbach (klaute at web dot de)
* http: *mosfetkiller.de/?s=miniledcube *
* 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" #include "main.h"
@ -16,41 +17,12 @@ int main(void)
init(); init();
init_usb(); init_usb();
//uint8_t anim = 0;
// Hauptschleife // Hauptschleife
//while (1)
for (;;) for (;;)
{ {
//wdt_reset(); // we are alive, so don't reset the µC //wdt_reset(); // we are alive, so don't reset the µC
usbPoll(); // keep connected 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 // Interruptvektor von TIMER1
//SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise
ISR (TIMER1_COMPA_vect) ISR (TIMER1_COMPA_vect)
{ {

View file

@ -1,11 +1,12 @@
// Mini-LED-Cube 1.0 /* CTHN.de MiniLEDCube
// *
// Copyright (C) 2009 Paul Wilhelm <paul@mosfetkiller.de> * Kai Lauterbach (klaute at web dot de)
// http://mosfetkiller.de/?s=miniledcube *
// * Based on http://mosfetkiller.de/?s=miniledcube
// Changed by Kai Lauterbach (klaute at web dot de) *
// * License: General Public License (GPL v3)
// Externes Quarz, CKDIV8 Disabled *
*/
#ifndef __main_h__ #ifndef __main_h__
#define __main_h__ #define __main_h__

View file

@ -30,8 +30,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
cube = (cube & (uint32_t)0xffff0000) | cube = (cube & (uint32_t)0xffff0000) |
rq->wValue.bytes[0] + rq->wValue.bytes[0] +
(rq->wValue.bytes[1] << 8); (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) | cube = (cube & (uint32_t)0x0000ffff) |
((uint32_t)(rq->wValue.bytes[0] + ((uint32_t)(rq->wValue.bytes[0] +
(rq->wValue.bytes[1] << 8)) << 16); (rq->wValue.bytes[1] << 8)) << 16);