[tuxdroid-svn] r307 - in firmware: tuxaudio/trunk tuxcore/trunk tuxdefs
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-05-10 16:37:53
|
Author: jaguarondi Date: 2007-05-10 18:37:21 +0200 (Thu, 10 May 2007) New Revision: 307 Modified: firmware/tuxaudio/trunk/main.c firmware/tuxcore/trunk/global.c firmware/tuxcore/trunk/global.h firmware/tuxcore/trunk/main.c firmware/tuxcore/trunk/parser.c firmware/tuxdefs/commands.h Log: - ADD: sleep and sleep acknowledge commands are added, the sleep command goes from the computer to tuxcore, is forwarded to tuxaudio and is then changed into the sleep_ack command, sent to tuxrf which sends it back to the computer. To check this, tuxaudio plays a sound when the command is received. No sleep function implemented yet, only the command goes around. Modified: firmware/tuxaudio/trunk/main.c =================================================================== --- firmware/tuxaudio/trunk/main.c 2007-05-10 16:23:16 UTC (rev 306) +++ firmware/tuxaudio/trunk/main.c 2007-05-10 16:37:21 UTC (rev 307) @@ -49,6 +49,7 @@ { VERSION_CMD, CPU_VER_JOIN(CPU_NUMBER, VER_MAJOR), VER_MINOR, VER_UPDATE}; uint8_t info_flg = 0; /* indicates if version information should be sent */ +uint8_t sleep_flg = 0; /* set when sleep should be entered */ void send_info(void) { @@ -72,6 +73,15 @@ info_flg = 0; } +void sleep(void) +{ + if (isFifoEmpty(statusFifo)) /* waits for all status to be sent before going to sleep */ + { + sleep_flg = 0; + playingAudio(1); /* XXX debug */ + } +} + /* * Debug and test flags */ @@ -124,6 +134,16 @@ { test_mode = audioBuf[2]; /* audio test mode is the second parameter */ } + else if (audioBuf[0] == SLEEP_CMD) + { + sleep_flg = 1; /* handle sleep in its own function */ + audioBuf[0] |= SLEEP_ACK_CMD; /* go to sleep mode and acknowledge it */ + audioBuf[2] |= SLEEP_ACK_MK; /* go to sleep mode and acknowledge it */ + /* Forwards the command to the rf CPU */ + cli(); + i2cSlaveReceiveService(4, audioBuf); + sei(); + } audioBufIdx = 0; /* clear buffer; this buffer can only hold one command so should be simply reset here */ } @@ -293,6 +313,7 @@ } } sendCommands(); /* Send commands on I2C */ + if (audioBufIdx) audioIntParser(); @@ -382,6 +403,8 @@ if (info_flg) send_info(); /* send information to the computer */ + if (sleep_flg) + sleep(); /* send information to the computer */ } } Modified: firmware/tuxcore/trunk/global.c =================================================================== --- firmware/tuxcore/trunk/global.c 2007-05-10 16:23:16 UTC (rev 306) +++ firmware/tuxcore/trunk/global.c 2007-05-10 16:37:21 UTC (rev 307) @@ -41,9 +41,11 @@ /* * Condition flags + * + * Initialization */ -struct condition_table cond_flags = { 1 }; /* Set startup flag */ +struct condition_table cond_flags = { .startup=1 }; /* Set startup flag */ /* * Version number Modified: firmware/tuxcore/trunk/global.h =================================================================== --- firmware/tuxcore/trunk/global.h 2007-05-10 16:23:16 UTC (rev 306) +++ firmware/tuxcore/trunk/global.h 2007-05-10 16:37:21 UTC (rev 307) @@ -333,9 +333,11 @@ /* * Condition flags + * + * TODO merge flags by categories in bitfields or bytes and masks */ -#define COND_RESET_NBR 8 /* number of flags that should be reset, change this according to the table below */ +#define COND_RESET_NBR 9 /* number of flags that should be reset, change this according to the table below */ struct condition_table { /* flags reset by the COND_RESET_CMD */ @@ -347,6 +349,7 @@ uint8_t unplug; uint8_t tux_recog_cnt; uint8_t tux_recog; + uint8_t sleep; /* flags not reset by the COND_RESET_CMD */ uint8_t eyes_closed; uint8_t rf_conn; Modified: firmware/tuxcore/trunk/main.c =================================================================== --- firmware/tuxcore/trunk/main.c 2007-05-10 16:23:16 UTC (rev 306) +++ firmware/tuxcore/trunk/main.c 2007-05-10 16:37:21 UTC (rev 307) @@ -63,7 +63,7 @@ * Stack Overflow detection * * Fill the ram with a value (0x5F) before the first initialization in order to - * detect any stack overflow just by looking to the memory at any breakpoint + * detect any stack overflow just by looking into the memory at any breakpoint */ void init_ram(void) __attribute__ ((naked)) __attribute__ ((section(".init1"))); void init_ram(void) Modified: firmware/tuxcore/trunk/parser.c =================================================================== --- firmware/tuxcore/trunk/parser.c 2007-05-10 16:23:16 UTC (rev 306) +++ firmware/tuxcore/trunk/parser.c 2007-05-10 16:37:21 UTC (rev 307) @@ -156,14 +156,14 @@ /* Sound */ else if (command[0] == PLAY_SOUND_CMD) { - for (i = 0; i < 3; i++) /* forwards the command to the audio CPU too */ + for (i = 0; i < 3; i++) /* forwards the command to the audio CPU */ audioIntBuf[i] = command[i]; audioIntBufIdx = 3; return; } else if (command[0] == MUTE_CMD) { - for (i = 0; i < 3; i++) /* forwards the command to the audio CPU too */ + for (i = 0; i < 3; i++) /* forwards the command to the audio CPU */ audioIntBuf[i] = command[i]; audioIntBufIdx = 3; return; @@ -172,9 +172,11 @@ /* Sleep mode */ else if (command[0] == SLEEP_CMD) { - for (i = 0; i < 3; i++) /* forwards the command to the audio CPU too */ + command[1] |= SLEEP_ACK_MK; /* ack the command */ + for (i = 0; i < 3; i++) /* forward the command to the audio CPU */ audioIntBuf[i] = command[i]; audioIntBufIdx = 3; + cond_flags.sleep = 1; return; } @@ -183,7 +185,7 @@ { if (!audioIntBufIdx) { - for (i = 0; i < 3; i++) /* forwards the command to the audio CPU too */ + for (i = 0; i < 3; i++) /* forwards the command to the audio CPU */ audioIntBuf[i] = command[i]; audioIntBufIdx = 3; } Modified: firmware/tuxdefs/commands.h =================================================================== --- firmware/tuxdefs/commands.h 2007-05-10 16:23:16 UTC (rev 306) +++ firmware/tuxdefs/commands.h 2007-05-10 16:37:21 UTC (rev 307) @@ -222,15 +222,16 @@ /* * Sleep commands */ -#define SLEEP_CMD 0x93 /* set the CPU in sleep mode */ -/* 1st parameter: XXX undefined yet */ -/* 2nd parameter: XXX undefined yet */ +#define SLEEP_CMD 0xB7 /* set the CPU in sleep mode */ +/* 1st parameter: type of sleep mode */ +/* 2nd parameter: reserved */ +#define SLEEP_ACK_CMD 0xF7 /* acknowledge of the sleep mode command */ +/* 1st parameter: acknowledge of tuxcore */ +/* 2nd parameter: acknowledge of tuxaudio */ +/* 3rd parameter: acknowledge of tuxrf */ +#define SLEEP_ACK_MK 0x01 /* - * I2C commands - */ - -/* * Status commands */ #define STATUS_PORTS_CMD 0xC0 /* send core CPU's ports */ |