Author: jaguarondi
Date: 2008-08-04 12:09:02 +0200 (Mon, 04 Aug 2008)
New Revision: 1448
Modified:
firmware/tuxaudio/branches/new_rf/init.c
firmware/tuxaudio/branches/new_rf/main.c
firmware/tuxaudio/branches/new_rf/varis.c
firmware/tuxaudio/branches/new_rf/varis.h
Log:
* Added a timer (2) for sending the sensors status instead of the audio
timer.
Modified: firmware/tuxaudio/branches/new_rf/init.c
===================================================================
--- firmware/tuxaudio/branches/new_rf/init.c 2008-08-03 14:25:41 UTC (rev
1447)
+++ firmware/tuxaudio/branches/new_rf/init.c 2008-08-04 10:09:02 UTC (rev
1448)
@@ -101,25 +101,18 @@
OCR1BH = 0x00;
OCR1BL = 0x00;
- // Timer/Counter 2 initialization
- // Clock source: System Clock
- // Clock value: Timer 2 Stopped
- // Mode: Normal top=FFh
- // OC2A output: Disconnected
- // OC2B output: Disconnected
- ASSR = 0x00;
+ /* Timer/Counter 2 initialization
+ * Clock source: System Clock/1024
+ * Mode: Normal (top=FFh) */
TCCR2A = 0x00;
- TCCR2B = 0x00;
- TCNT2 = 0x00;
- OCR2A = 0x00;
- OCR2B = 0x00;
+ TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20);
// Timer/Counter 0 Interrupt(s) initialization
TIMSK0 = 0x01;
// Timer/Counter 1 Interrupt(s) initialization
TIMSK1 = 0x00;
// Timer/Counter 2 Interrupt(s) initialization
- TIMSK2 = 0x00;
+ TIMSK2 = _BV(TOIE2);
// Analog Comparator initialization
// Analog Comparator: Off
Modified: firmware/tuxaudio/branches/new_rf/main.c
===================================================================
--- firmware/tuxaudio/branches/new_rf/main.c 2008-08-03 14:25:41 UTC (rev
1447)
+++ firmware/tuxaudio/branches/new_rf/main.c 2008-08-04 10:09:02 UTC (rev
1448)
@@ -81,6 +81,8 @@
/* Set when sleep should be entered */
static uint8_t pre_sleep_delay = 0;
+/* When sensor values should be sent to the computer */
+static bool send_sensors_flag;
ISR(SIG_PIN_CHANGE1)
{
@@ -222,9 +224,9 @@
/*sleep();*/
/*}*/
- if (sendSensorsFlag)
+ if (send_sensors_flag)
{
- sendSensorsFlag = 0;
+ send_sensors_flag = false;
if (pre_sleep_delay > 1)
/* There's a delay before the sleep function is actually called
* otherwise other commands on the stack can't be executed */
@@ -265,6 +267,14 @@
}
}
+/* Timer 2 interrupt, used as main tick for sending sensor values.
+ * clk = 8MHz/1024,
+ * ISR each 256*1024/8e6 = 33ms */
+ISR(SIG_OVERFLOW2)
+{
+ send_sensors_flag = true;
+}
+
//static inline void audio_sampling(void) __attribute__ ( ( always_inline ) );
//void audio_sampling(void) __attribute__ ( ( signal ) );
//void audio_sampling(void)
@@ -322,7 +332,7 @@
/* send status to the behavioural CPU, 8KHz divided by 256 lead to a
* status sent each 32ms */
//if (--sendSensorsCmpt == 0)
- //sendSensorsFlag = 1;
+ //send_sensors_flag = 1;
////asm volatile (
////"pop r25 \n"
////"pop r23 \n"
@@ -342,8 +352,6 @@
/* Microphone at 8kHz */
FifoPut_inl(ADCFifo, ADCH);
ADCSRA |= 0x40;
- if (--sendSensorsCmpt == 0)
- sendSensorsFlag = 1;
}
// XXX DEBUG: used to generate a saw waveform
@@ -363,7 +371,7 @@
* Timer 0 overflow interrupt service routine (PWM)
* 32KHz timer so the ISR is called each 31.25us
*/
-#if 0
+#if 1
ISR(SIG_OVERFLOW0)
{
/* timer 0 is clocked at 32KHz so we divide it by 4 to get 8KHz */
@@ -375,7 +383,7 @@
}
#endif
-#if 1
+#if 0
ISR(SIG_OVERFLOW0) __attribute__((naked));
ISR(SIG_OVERFLOW0)
{
Modified: firmware/tuxaudio/branches/new_rf/varis.c
===================================================================
--- firmware/tuxaudio/branches/new_rf/varis.c 2008-08-03 14:25:41 UTC (rev
1447)
+++ firmware/tuxaudio/branches/new_rf/varis.c 2008-08-04 10:09:02 UTC (rev
1448)
@@ -61,7 +61,6 @@
volatile unsigned char audioLevel;
uint8_t soundToPlay;
-unsigned char sendSensorsCmpt, sendSensorsFlag;
unsigned char audio_level, battery_level;
uint8_t power_on_reset_delay = 20;
Modified: firmware/tuxaudio/branches/new_rf/varis.h
===================================================================
--- firmware/tuxaudio/branches/new_rf/varis.h 2008-08-03 14:25:41 UTC (rev
1447)
+++ firmware/tuxaudio/branches/new_rf/varis.h 2008-08-04 10:09:02 UTC (rev
1448)
@@ -70,7 +70,6 @@
extern volatile unsigned char audioLevel;
extern uint8_t soundToPlay;
-extern unsigned char sendSensorsCmpt, sendSensorsFlag;
extern unsigned char audio_level, battery_level;
extern uint8_t power_on_reset_delay;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn