From f2f385c6d0b939d1afeb2f7fb62951044df0b095 Mon Sep 17 00:00:00 2001 From: Paul Goeser Date: Fri, 13 Jan 2012 23:32:38 +0100 Subject: [PATCH] small fixes --- Makefile | 2 +- gg.c | 5 +++-- gg.h | 2 +- ringbuf_small.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ac49a35..d736360 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CFLAGS += -Wall -Os -I. -mmcu=attiny26 -std=c99 DEFINES += -DF_CPU=16e6 -OBJECTS = gg.o mmc.o ringbuf_small.o +OBJECTS = gg.o mmc.o #ringbuf_small.o # further optimization: # this removes dead code and does global linker optimization diff --git a/gg.c b/gg.c index 140133b..c0f0ac3 100644 --- a/gg.c +++ b/gg.c @@ -3,6 +3,7 @@ #include #include "ringbuf_small.h" +#include "ringbuf_small.c" #include "mmc.h" #include "gg.h" @@ -31,6 +32,7 @@ uint32_t mmc_position;/* current reading position on mmc */ uint8_t overflows = 1;/* remaining counter overflows until next sample */ #define SAMPLE_BITS 11 +ringbuf_t rb; #define BUFFER_SIZE 32 uint16_t buffer[BUFFER_SIZE];/* buffer for mmc data */ @@ -57,7 +59,7 @@ ISR(TIMER1_OVF1_vect){ uint16_t next; if(--cnt_to_next){ - next = ringbuf_get(ringbuf); + ringbuf_get(&rb, &next); OCR1A = next>>8; cnt_to_ocr_incr = 7-(next & 0x7); cnt_to_next = 7; @@ -75,7 +77,6 @@ ISR(TIMER1_OVF1_vect){ int main(void) __attribute__((noreturn)); int main(void) { - ringbuf_t rb; ringbuf_init(&rb, buffer, BUFFER_SIZE); if(mmc_init() != 0) {/* mmc fail */;} diff --git a/gg.h b/gg.h index 0873956..e97ca8c 100644 --- a/gg.h +++ b/gg.h @@ -11,4 +11,4 @@ register uint8_t next_cnt_to_incr __asm__("r6"); register uint8_t cnt_to_next __asm__("r7"); register uint8_t needs_new_data_flag __asm__("r8"); -ringbuf_t ringbuf; +extern ringbuf_t rb; diff --git a/ringbuf_small.h b/ringbuf_small.h index 9c3bf5e..8683c2c 100644 --- a/ringbuf_small.h +++ b/ringbuf_small.h @@ -13,6 +13,6 @@ typedef struct { void ringbuf_init(ringbuf_t* rb, uint16_t *buf, uint8_t size); uint8_t ringbuf_put(ringbuf_t *rb, uint16_t value); -uint8_t ringbuf_get(ringbuf_t *rb, uint16_t *data); +uint8_t ringbuf_get(ringbuf_t *rb, uint16_t *data) __attribute__((always_inline)); #endif