[tuxdroid-svn] r4752 - firmware/tuxaudio/branches/demo
Status: Beta
Brought to you by:
ks156
|
From: ks156 <c2m...@c2...> - 2009-06-08 06:47:07
|
Author: ks156
Date: 2009-06-08 08:46:57 +0200 (Mon, 08 Jun 2009)
New Revision: 4752
Modified:
firmware/tuxaudio/branches/demo/Makefile
firmware/tuxaudio/branches/demo/flash.c
firmware/tuxaudio/branches/demo/flash.h
firmware/tuxaudio/branches/demo/main.c
Log:
* Now start the embedded attitune by pushing the head button.
By default, the firmware will be compiled to starts the attitune
periodically. To allow the startup with the head button, the firmware must be
compiled with 'CUSTOMER=yes'
Modified: firmware/tuxaudio/branches/demo/Makefile
===================================================================
--- firmware/tuxaudio/branches/demo/Makefile 2009-06-05 11:45:53 UTC (rev 4751)
+++ firmware/tuxaudio/branches/demo/Makefile 2009-06-08 06:46:57 UTC (rev 4752)
@@ -47,7 +47,11 @@
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS = $(COMMON) $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
+ifneq (,$(findstring yes, $(CUSTOMER)))
+ CDEFS += -DCUSTOMER_INTERACT
+endif
+
## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += -x assembler-with-cpp -Wa,-gstabs
@@ -187,7 +191,7 @@
# Programming
prog: $(PROJECT).hex
- tuxup -kr $(PROJECT).hex $(PROJECT).eep
+ tuxup $(PROJECT).hex $(PROJECT).eep
progisp: $(PROJECT).hex $(PROJECT).eep
$(AVRDUDE) -p $(MCU) -c jtag2isp -P usb -B 10 -e -U flash:w:$(PROJECT).hex -U eeprom:w:$(PROJECT).eep
Modified: firmware/tuxaudio/branches/demo/flash.c
===================================================================
--- firmware/tuxaudio/branches/demo/flash.c 2009-06-05 11:45:53 UTC (rev 4751)
+++ firmware/tuxaudio/branches/demo/flash.c 2009-06-08 06:46:57 UTC (rev 4752)
@@ -164,8 +164,11 @@
\ingroup flash
\brief Plays the sequence recorded in flash.
*/
-
+#ifdef CUSTOMER_INTERACT
+bool playSound(void)
+#else
void playSound(void)
+#endif
{
uint8_t cmd[CMD_SIZE];
@@ -185,6 +188,9 @@
}
bool exit = false;
+#ifdef CUSTOMER_INTERACT
+ bool end_of_cycle = false;
+#endif
while (!exit && !spi_start && !FifoFull(PWMFifo))
{
uint8_t data;
@@ -201,6 +207,9 @@
{
first_read = true;
exit = true;
+#ifdef CUSTOMER_INTERACT
+ end_of_cycle = true;
+#endif
}
else if (cmd[0] == WAIT_CMD)
{
@@ -217,6 +226,9 @@
FifoPut(PWMFifo, data);
}
}
+#ifdef CUSTOMER_INTERACT
+ return end_of_cycle;
+#endif
}
/**
Modified: firmware/tuxaudio/branches/demo/flash.h
===================================================================
--- firmware/tuxaudio/branches/demo/flash.h 2009-06-05 11:45:53 UTC (rev 4751)
+++ firmware/tuxaudio/branches/demo/flash.h 2009-06-08 06:46:57 UTC (rev 4752)
@@ -70,7 +70,11 @@
extern void init_programming(void);
extern void programming(void);
+#ifdef CUSTOMER_INTERACT
+extern bool playSound(void);
+#else
extern void playSound(void);
+#endif
extern void erase(void);
extern uint8_t checkFlashState(void);
extern uint8_t readLastBlock(uint8_t num);
Modified: firmware/tuxaudio/branches/demo/main.c
===================================================================
--- firmware/tuxaudio/branches/demo/main.c 2009-06-05 11:45:53 UTC (rev 4751)
+++ firmware/tuxaudio/branches/demo/main.c 2009-06-08 06:46:57 UTC (rev 4752)
@@ -38,6 +38,12 @@
#include "config.h"
#include "PC_communication.h"
+
+#ifdef CUSTOMER_INTERACT
+ /* Standalone mode : This flag indicate the end of a cycle */
+ volatile bool stopped = true;
+#endif
+
/*
* Debug and test flags
*/
@@ -70,6 +76,13 @@
/* XXX This ISR is declared as I think any interrupt which doesn't have an
* interrupt vector initialized will do a reset or infinite loop, this
* needs to be checked */
+
+ // Standalone code
+ //
+#ifdef CUSTOMER_INTERACT
+ /* Start a new cycle by pushing the HEAD button */
+ stopped = false;
+#endif
}
void sleep(void)
@@ -138,6 +151,13 @@
flashPlay = checkFlashState();
communication_init(); /* I2C initialization */
+#ifdef CUSTOMER_INTERACT
+ /* Set the Pin Change interrupt with PC3 */
+ PCMSK1 = 0x08;
+ PCIFR = _BV(PCIE1);
+ PCICR |= _BV(PCIE1);
+#endif
+
sei(); /* Init global interrupt */
@@ -168,13 +188,26 @@
erase();
else if (programmingFlash)
programming();
+
+#ifdef CUSTOMER_INTERACT
+ /* Don't read the flash memory if the cycle is over */
+ else if (!stopped)
+#else
+ /* Always read the flash memory */
else
+#endif
{
/* Send commands to I2C, otherwise get new status from tuxcore */
communication_task();
if (flashPlay && !silence)
+ {
+#ifdef CUSTOMER_INTERACT
+ stopped = playSound();
+#else
playSound();
+#endif
+ }
}
/*else if (sleep_f)*/
|