view src/cs/drivers/drv_app/buzzer/buzzer.c @ 273:5caa86ee2cfa

enable L1_NEW_AEC in l1_confg.h (bold change) The AEC function implemented in DSP ROM 3606 on the Calypso silicon we work with is the one that corresponds to L1_NEW_AEC; the same holds for DSP 34 and even for DSP 33 with more recent patch versions. However, TI shipped their TCS211 reference fw with L1_NEW_AEC set to 0, thus driving AEC the old way if anyone tried to enable it, either via AT%Nxxxx or via the audio mode facility. As a result, the fw would try to control features which no longer exist in the DSP (long vs short echo and the old echo suppression level bits), while providing no way to tune the 8 new parameter words added to the DSP's NDB page. The only sensible solution is to bite the bullet and enable L1_NEW_AEC in L1 config, with fallout propagating into RiViera Audio Service T_AUDIO_AEC_CFG structure and into /aud/*.cfg binary file format. The latter fallout will be addressed in further code changes.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 29 Jul 2021 18:32:40 +0000
parents edd8482a6576
children
line wrap: on
line source

/*
 * BUZZER.C
 *
 * Buzzer driver
 *
 * Target : ARM
 *
 * Copyright (c) Texas Instruments 2000
 *
 */


#include "main/sys_types.h"
#include "memif/mem.h"
#include "armio/armio.h"
#include "buzzer.h"
#include "timer/timer.h"

#include "board.cfg"
#include "fc-target.h"

/*
 * Initialize buzzer
 *
 */
void BZ_Init(void)
{
}

/*
 * BZ_Enable / BZ_Disable
 *
 * Enable / disable buzzer
 *
 * The buzzer uses timer 1
 */
void BZ_Enable(void)
{
  *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) |= BZ_ON;
}

void BZ_Disable(void)
{
  *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) &= ~BZ_ON;
}

/*
 * BZ_Tone
 *
 * Changes the timer count to set the tone frequency in Hz
 *
 * 58 ticks= 1 ms, which give a frequency of 500 Hz
 *
 *
 */
void BZ_Tone(int f)
{
  #ifdef CONFIG_TARGET_PIRELLI
    f = 0;	/* vibrator instead of buzzer */
  #else
    if (f > 255)
    {
        f = 255;
    }
  #endif
  *((volatile SYS_UWORD16 *) ARMIO_LOAD_TIM) = f;
}

/*
 * BZ_Volume
 *
 * Changes the buzzer volume
 *
 */
void BZ_Volume(int v)
{
  // the level range is 0 up to 63
    if (v > 63)
    {
        v = 63;
    }
  *((volatile SYS_UWORD16 *) BZ_LEVEL) = v;
}

/*
 * BZ_KeyBeep_ON
 *
 * Audio feedback to user after keybeep
 *
 */
void BZ_KeyBeep_ON(void)
{
  volatile int i;

  BZ_Init ();
  BZ_Volume (255);
  BZ_Tone (50);
  BZ_Enable ();

  for (i = 0; i < 17000; i++)
    ;

  BZ_Disable ();
}



/*
 * BZ_KeyBeep_OFF
 *
 * Audio feedback to user after keybeep
 *
 */
void BZ_KeyBeep_OFF(void)
{
  volatile int i;

  BZ_Init ();
  BZ_Volume (255);
  BZ_Tone (100);
  BZ_Enable ();

  for (i = 0; i < 17000; i++)
    ;

  BZ_Disable ();
}



/*
 * LT_Enable / LT_Disable
 *
 * Enable / disable LCD lighting
 *
 */
void LT_Enable(void)
{
#if (BOARD == 7 || BOARD == 8 || BOARD == 9)
   *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) |= LT_ON;
#endif
}
void LT_Disable(void)
{
#if (BOARD == 7 || BOARD == 8 || BOARD == 9)
   *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) &= ~LT_ON;
#endif
}


/*
 * LT_Level
 *
 * Set LCD display level
 */
void LT_Level(SYS_WORD8 level)
{
#if (BOARD == 7 || BOARD == 8 || BOARD == 9)
   if (level > 63) level=63;

   // the level range is 0 up to 63
   *((volatile SYS_UWORD16 *) LT_LEVEL) = level;
#endif
}


/*
 * LT_Status
 *
 * Return lighting status for sleep manager
 *
 */
SYS_BOOL LT_Status(void)
{
#if (BOARD == 7 || BOARD == 8 || BOARD == 9)
   if (*((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) & LT_ON)
      return(1);		 // the light is on
   else
      return(0);
#else
   return(0);
#endif
}