teleterra: audio amp is enabled by bringing audio_en (P2_4) high
authorKeith Packard <keithp@keithp.com>
Mon, 1 Nov 2010 05:51:48 +0000 (22:51 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 1 Nov 2010 05:51:48 +0000 (22:51 -0700)
The external audio amplifier is placed in 'suspend' mode most of the
time to save power. When audio is being sent, turn it on.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao_audio.c
src/ao_pins.h

index 0d521973f78cc3b43c4c52939cace53407fb3f60..5d8fdfb5caf357ff253d8d76922a7e5bf13b658c 100644 (file)
@@ -584,6 +584,12 @@ ao_audio_send(__xdata uint8_t *samples, uint16_t nsamples) __reentrant
 {
        ao_mutex_get(&ao_audio_mutex);
 
+#if AUDIO_STANDBY_ON_P2_4
+       /*
+        * Turn on the audio amp
+        */
+       P2_4 = 1;
+#endif
        /*
         * Turn on timer 4. Free running from 0 to 0xff, with P2_0
         * 'on' interval controlled by the value in T4CC0. Run this
@@ -641,6 +647,12 @@ ao_audio_send(__xdata uint8_t *samples, uint16_t nsamples) __reentrant
        P2_0 = 0;
        P2SEL = (P2SEL & ~P2SEL_SELP2_0_MASK) | P2SEL_SELP2_0_GPIO;
 
+#if AUDIO_STANDBY_ON_P2_4
+       /*
+        * Turn off the audio amp
+        */
+       P2_4 = 0;
+#endif
        ao_mutex_put(&ao_audio_mutex);
 }
 
@@ -665,6 +677,12 @@ ao_audio_init(void)
        P2SEL = (P2SEL & ~P2SEL_SELP2_0_MASK) | P2SEL_SELP2_0_GPIO;
        PERCFG = (PERCFG & ~PERCFG_T4CFG_ALT_MASK) | PERCFG_T4CFG_ALT_2;
 
+#if AUDIO_STANDBY_ON_P2_4
+       P2_4 = 0;
+       P2SEL &= ~P2SEL_SELP2_4_PERIPHERAL;
+       P2DIR |= (1 << 4);
+#endif
+
        /* Timer 3 is used to clock the DMA transfers from the audio data buffer
         * to the timer 4
         */
index 7836d95a77fb7f275effbf5192206164599a94cf..9849dfe4766265cbdfb52634aed08d6d7bcb096c 100644 (file)
@@ -31,6 +31,7 @@
        #define AO_LED_RED              1
        #define LEDS_AVAILABLE          (AO_LED_RED)
        #define HAS_EXTERNAL_TEMP       0
+        #define AUDIO_STANDBY_ON_P2_4  0
 #endif
 
 #if defined(TELEDONGLE_V_0_2)
@@ -45,6 +46,7 @@
        #define AO_LED_RED              1
        #define AO_LED_GREEN            2
        #define LEDS_AVAILABLE          (AO_LED_RED|AO_LED_GREEN)
+        #define AUDIO_STANDBY_ON_P2_4  0
 #endif
 
 #if defined(TELEMETRUM_V_0_1)
@@ -60,6 +62,7 @@
        #define AO_LED_GREEN            1
        #define LEDS_AVAILABLE          (AO_LED_RED|AO_LED_GREEN)
        #define HAS_EXTERNAL_TEMP       1
+        #define AUDIO_STANDBY_ON_P2_4  0
 #endif
 
 #if defined(TELEDONGLE_V_0_1)
@@ -74,6 +77,7 @@
        #define AO_LED_RED              2
        #define AO_LED_GREEN            1
        #define LEDS_AVAILABLE          (AO_LED_RED|AO_LED_GREEN)
+        #define AUDIO_STANDBY_ON_P2_4  0
 #endif
 
 #if defined(TELETERRA_V_0_1)
@@ -88,6 +92,7 @@
        #define AO_LED_RED              1
        #define AO_LED_GREEN            2
        #define LEDS_AVAILABLE          (AO_LED_RED|AO_LED_GREEN)
+        #define AUDIO_STANDBY_ON_P2_4  1
 #endif
 
 #if defined(TIDONGLE)
        #define PACKET_HAS_SLAVE        0
        #define AO_LED_RED              2
        #define LEDS_AVAILABLE          (AO_LED_RED)
+        #define AUDIO_STANDBY_ON_P2_4  0
 #endif
 
 #if DBG_ON_P1
 #error Please define PACKET_HAS_SLAVE
 #endif
 
+
+#ifndef AUDIO_STANDBY_ON_P2_4
+#error Please define AUDIO_STANDBY_ON_P2_4
+#endif
+
 #endif /* _AO_PINS_H_ */