From da8ad17c0242e69a1beb907b30c3ca9d53620aba Mon Sep 17 00:00:00 2001 From: dak664 Date: Sun, 21 Nov 2010 17:56:36 +0000 Subject: [PATCH] Save 256 bytes of RAM by excluding floating point routine --- platform/avr-ravenusb/rng.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/avr-ravenusb/rng.c b/platform/avr-ravenusb/rng.c index a68f5c7d0..83ce3e5b8 100644 --- a/platform/avr-ravenusb/rng.c +++ b/platform/avr-ravenusb/rng.c @@ -15,8 +15,10 @@ #define RNG_CONF_USE_RADIO_CLOCK ((!RNG_CONF_USE_ADC) && RF230BB) #endif - -#define TEMPORAL_AGITATION() do { static uint8_t agitator; agitator*=97; agitator+=101; _delay_us(agitator>>1); } while (0); +/* delay_us uses floating point which includes (in some avr-gcc's) a 256 byte __clz_tab in the RAM through the .data section. */ +/* _delay_loop_1 avoids this, it is 3 CPU cycles per loop, 375ns @ 8MHz */ +//#define TEMPORAL_AGITATION() do { static uint8_t agitator; agitator*=97; agitator+=101; _delay_us(agitator>>1); } while (0); +#define TEMPORAL_AGITATION() do { static uint8_t agitator; agitator*=97; agitator+=101; _delay_loop_1(agitator>>1); } while (0); // -------------------------------------------------------------------------