From 0ac038179c386ff30a541b9c54ff9ba244eb04f3 Mon Sep 17 00:00:00 2001 From: bigalex Date: Tue, 14 Aug 2012 19:10:33 +0200 Subject: [PATCH] some synth --- sync --- firmware/main.c | 7 +- firmware/synth.c | 6 +- firmware/synth.h | 3 +- hardware/pentabug_1layer.brd | 181 ++++++++++++++++------------------- 4 files changed, 93 insertions(+), 104 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index 6208a71..4ea679f 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -96,7 +96,7 @@ static void init_motor(void) int main(void) { /* hardware initialisation: */ - init_leds(); + //init_leds(); USART0_Init(); // init_motor(); init_pwm(); @@ -107,7 +107,9 @@ int main(void) /* here the show begins:*/ sei(); - + DDRC = 0b00000011; + PORTC = 0b00000001; + PORTC = 0b00000000; for(;;) /* ever */ { //do something @@ -118,6 +120,7 @@ int main(void) USART0_crlf(); //last_darkval=darkval; }; + synth_poll(); //USART0_put_uint16(0xA09F); //USART0_crlf(); }; diff --git a/firmware/synth.c b/firmware/synth.c index 97182a2..a421780 100644 --- a/firmware/synth.c +++ b/firmware/synth.c @@ -298,14 +298,16 @@ void synth_poll(void) { void enqueue_timeslot(uint16_t synthval) { timeslots[timeslots_write] = synthval; timeslots_write++; - if (timeslots_write >= SYNTH_BUFSIZE) - timeslots_write = 0; + timeslots_write &= SYNTH_BUFMASK; + } uint16_t dequeue_timeslot() { uint16_t t = timeslots[timeslots_read]; + PORTC = (timeslots_read != timeslots_write) ? 0b00000001 : 0b00000000; timeslots_read++; if (timeslots_read >= SYNTH_BUFSIZE) timeslots_read =0; + return t; } diff --git a/firmware/synth.h b/firmware/synth.h index efd4e27..920d419 100644 --- a/firmware/synth.h +++ b/firmware/synth.h @@ -1,7 +1,8 @@ #ifndef SYNTH_H #define SYNTH_H -#define SYNTH_BUFSIZE 2 +#define SYNTH_BUFSIZE (16) +#define SYNTH_BUFMASK (0b00001111) enum { WAVE_OFF, WAVE_PULSE, WAVE_SAW, WAVE_NOISE }; diff --git a/hardware/pentabug_1layer.brd b/hardware/pentabug_1layer.brd index 419c8b1..91824d6 100644 --- a/hardware/pentabug_1layer.brd +++ b/hardware/pentabug_1layer.brd @@ -111,16 +111,6 @@ - - - - - - - - - - @@ -657,7 +647,7 @@ design rules under a new name. - + @@ -667,11 +657,11 @@ design rules under a new name. - - - - - + + + + + @@ -702,31 +692,36 @@ design rules under a new name. - - - - - + + + - - + + - - + + + + + + + + + + - - + - - + + @@ -767,18 +762,33 @@ design rules under a new name. - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -797,40 +807,27 @@ design rules under a new name. - - - - - - - - - + + + - + - - - - - - + - - - - + + - - + + @@ -872,18 +869,14 @@ design rules under a new name. - - - - - - + + - - + + @@ -900,14 +893,13 @@ design rules under a new name. - - + - - - + + + @@ -915,16 +907,17 @@ design rules under a new name. - - - - + - - + + + + + + - + @@ -950,17 +943,10 @@ design rules under a new name. - - - - - - - - - - + + + @@ -1006,21 +992,18 @@ design rules under a new name. - - - - - - - - + - - + + + + + +