⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 audio.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 4 页
字号:

static const T_DESCR ct_dtmf_7 []  = /* command 1     command 2      length     */
                      {    F_852,        F_1209,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };

static const T_DESCR ct_dtmf_8 []  = /* command 1     command 2      length     */
                      {    F_852,        F_1336,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };

static const T_DESCR ct_dtmf_9 []  = /* command 1     command 2      length     */
                      {    F_852,        F_1477,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };

static const T_DESCR ct_dtmf_a []  = /* command 1     command 2      length     */
                      {    F_697,        F_1633,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };

static const T_DESCR ct_dtmf_b []  = /* command 1     command 2      length     */
                      {    F_770,        F_1633,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };
static const T_DESCR ct_dtmf_c []  = /* command 1     command 2      length     */
                      {    F_852,        F_1633,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };

static const T_DESCR ct_dtmf_d []  = /* command 1     command 2      length     */
                      {    F_941,        F_1633,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };

static const T_DESCR ct_dtmf_s []  = /* command 1     command 2      length     */
                      {    F_941,        F_1209,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };

static const T_DESCR ct_dtmf_h []  = /* command 1     command 2      length     */
                      {    F_941,        F_1477,        TDMA_23,
                           0xFFFF,       0xFFFF,        0
                      };

/* keybeep not used at the moment */
static const T_DESCR ct_keybeep []  = /* command 1     command 2      length     */
                      {    F_697,        F_697,         TDMA_43,
                           0xFFFF,       0xFFFF,        0
                      };

static const T_DESCR ct_ringing []  =   /* command 1     command 2      length     */
                      {    F_425,        0,             TDMA_216,
                           0,            0,             TDMA_866,
                           0xFFFF,       0xFFFF,        0
                      };
                      
/*
 * Tone Type Table
 */
static const UBYTE  TONE_TYPE [] = {  BUZZER,     /* ringing tone 0             */
                         BUZZER,     /* ringing tone 1             */
                         BUZZER,     /* ringing tone 2             */
                         BUZZER,     /* ringing tone 3             */
                         BUZZER,     /* ringing tone 4             */
                         BUZZER,     /* ringing tone 5             */
                         BUZZER,     /* ringing tone 6             */
                         BUZZER,     /* ringing tone 7             */
                         BUZZER,     /* ringing tone 8             */
                         BUZZER,     /* ringing tone 9             */
                         BUZZER,     /* ringing tone 10            */
                         BUZZER,     /* ringing tone 11            */
                         BUZZER,     /* ringing tone 12            */
                         BUZZER,     /* ringing tone 13            */
                         BUZZER,     /* ringing tone 14            */
                         BUZZER,     /* ringing tone 15            */
                         BUZZER,     /* error/special information  */
                         AUDIO,      /* subscriber busy            */
                         BUZZER,     /* congestion                 */
                         BUZZER,     /* call dropped               */
                         BUZZER,     /* radio acknowledge          */
                         AUDIO,      /* call waiting               */
                         AUDIO,      /* DTMF digit 0               */
                         AUDIO,      /* DTMF digit 1               */
                         AUDIO,      /* DTMF digit 2               */
                         AUDIO,      /* DTMF digit 3               */
                         AUDIO,      /* DTMF digit 4               */
                         AUDIO,      /* DTMF digit 5               */
                         AUDIO,      /* DTMF digit 6               */
                         AUDIO,      /* DTMF digit 7               */
                         AUDIO,      /* DTMF digit 8               */
                         AUDIO,      /* DTMF digit 9               */
                         AUDIO,      /* DTMF digit A               */
                         AUDIO,      /* DTMF digit B               */
                         AUDIO,      /* DTMF digit C               */
                         AUDIO,      /* DTMF digit D               */
                         AUDIO,      /* DTMF digit *               */
                         AUDIO,      /* DTMF digit #               */
                         AUDIO,      /* keybeep                    */
                         AUDIO       /* ringing tone if NOIBT      */
                      };

/*
 * Tone Description Table
 */

static const T_DESCR * TONE_DESCR [] =
                       { ct_ring,    /* ringing tone 0             */
                         ct_ring,    /* ringing tone 1             */
                         ct_ring,    /* ringing tone 2             */
                         ct_ring,    /* ringing tone 3             */
                         ct_ring,    /* ringing tone 4             */
                         ct_ring,    /* ringing tone 5             */
                         ct_ring,    /* ringing tone 6             */
                         ct_ring,    /* ringing tone 7             */
                         ct_ring,    /* ringing tone 8             */
                         ct_ring,    /* ringing tone 9             */
                         ct_ring,    /* ringing tone 10            */
                         ct_ring,    /* ringing tone 11            */
                         ct_ring,    /* ringing tone 12            */
                         ct_ring,    /* ringing tone 13            */
                         ct_ring,    /* ringing tone 14            */
                         ct_ring,    /* ringing tone 15            */
                         ct_auth_num,/* error/special information  */
                         ct_busy,    /* subscriber busy            */
                         ct_congest, /* congestion                 */
                         ct_dropped, /* call dropped               */
                         ct_ack,     /* radio acknowledge          */
                         ct_cw,      /* call waiting               */
                         ct_dtmf_0,  /* DTMF digit 0               */
                         ct_dtmf_1,  /* DTMF digit 1               */
                         ct_dtmf_2,  /* DTMF digit 2               */
                         ct_dtmf_3,  /* DTMF digit 3               */
                         ct_dtmf_4,  /* DTMF digit 4               */
                         ct_dtmf_5,  /* DTMF digit 5               */
                         ct_dtmf_6,  /* DTMF digit 6               */
                         ct_dtmf_7,  /* DTMF digit 7               */
                         ct_dtmf_8,  /* DTMF digit 8               */
                         ct_dtmf_9,  /* DTMF digit 9               */
                         ct_dtmf_a,  /* DTMF digit A               */
                         ct_dtmf_b,  /* DTMF digit B               */
                         ct_dtmf_c,  /* DTMF digit C               */
                         ct_dtmf_d,  /* DTMF digit D               */
                         ct_dtmf_s,  /* DTMF digit *               */
                         ct_dtmf_h,  /* DTMF digit #               */
                         ct_keybeep, /* dummy for keybeep          */
                         ct_ringing  /* ringing tone if NIBT       */
                      };

/*==== CONSTANTS ==================================================*/
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_AUDIO                  |
| STATE   : code                ROUTINE : audio_Init                 |
+--------------------------------------------------------------------+

  PURPOSE : The function initializes the driver磗 internal data.
            The function returns DRV_OK in case of a successful
            completition. The function returns DRV_INITIALIZED if
            the driver has already been initialized and is ready to
            be used or is already in use. In case of an initialization
            failure, which means the that the driver cannot be used,
            the function returns DRV_INITFAILURE.

*/

GLOBAL UBYTE audio_Init (drv_SignalCB_Type in_SignalCBPtr)
{
  audio_signal_callback   = in_SignalCBPtr;     /* store call-back function */

#if !defined (NEW_FRAME)
  audio_handle = vsi_t_open (VSI_CALLER "AUDIO");

  if (audio_handle < VSI_OK)
    return DRV_INITFAILURE;
#endif

  BZ_Init ();             /* initialize buzzer */

  audio_SetMute  ( AUDIO_SPEAKER,    AUDIO_MUTING_OFF );
  audio_SetMute  ( AUDIO_MICROPHONE, AUDIO_MUTING_OFF );

  audio_SetAmplf ( AUDIO_SPEAKER,    175 );
  audio_SetAmplf ( AUDIO_MICROPHONE, 75  );
  audio_SetAmplf ( AUDIO_BUZZER,     175 );

  return DRV_OK;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_AUDIO                  |
| STATE   : code                ROUTINE : audio_Exit                 |
+--------------------------------------------------------------------+

  PURPOSE : The function is called when the driver functionality is
            not longer required.
*/

GLOBAL void audio_Exit (void)
{
  audio_signal_callback = NULL;
#if !defined (NEW_FRAME)
  vsi_t_close (VSI_CALLER audio_handle);
  audio_handle = VSI_ERROR;
#endif

  BZ_Disable ();
  act_tone.status = NO_TONE;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_AUDIO                  |
| STATE   : code                ROUTINE : audio_SetMute              |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to enable or disable muting for
            the device identified by the parameter in_Device. If the
            mode for the specified device could be changed, the
            function returns DRV_OK. If the specified device is
            unknown or the device does not support muting, the function
            returns DRV_INVALID_PARAMS.

*/

GLOBAL UBYTE audio_SetMute (UBYTE in_DeviceID, UBYTE in_Mode)
{
  if (in_DeviceID EQ AUDIO_SPEAKER)
  {
    if (in_Mode AND audio_is_free)
    {
      TRACE_EVENT ("No speaker muting");
#ifdef ALR
      ABB_DlMute (0);
#else
      VG_DlMute (0);
#endif
      act_speakerMute = AUDIO_MUTING_OFF;
    }
    else
    {
      TRACE_EVENT ("Speaker muting");
#ifdef ALR
      ABB_DlMute (1);
#else
      VG_DlMute (1);
#endif
      act_speakerMute = AUDIO_MUTING_ON;
    }
  }
  else if (in_DeviceID EQ AUDIO_MICROPHONE)
  {
    if (in_Mode AND audio_is_free)
    {
      TRACE_EVENT ("No microphone muting");
      audio_UlMute (0);
      act_micMute = AUDIO_MUTING_OFF;
    }
    else
    {
      TRACE_EVENT ("Microphone muting");
      audio_UlMute (1);
      act_micMute = AUDIO_MUTING_ON;
    }
  }
  else
  {
    return DRV_INVALID_PARAMS;
  }

  return DRV_OK;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_AUDIO                  |
| STATE   : code                ROUTINE : audio_GetMute              |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to get the status whether muting
            is enabled or disabled for the device identified by the
            parameter in_Device. If the specified device is unknown
            or the device does not support muting, the function
            returns DRV_INVALID_PARAMS.

*/

GLOBAL UBYTE audio_GetMute (UBYTE in_DeviceID, UBYTE* out_Mode)
{
  if (in_DeviceID EQ AUDIO_SPEAKER)
  {
    *out_Mode = act_speakerMute;
  }
  else if (in_DeviceID EQ AUDIO_MICROPHONE)
  {
    *out_Mode = act_micMute;
  }
  else
  {
    return DRV_INVALID_PARAMS;
  }

  return DRV_OK;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_AUDIO                  |
| STATE   : code                ROUTINE : audio_GetStatus            |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to retrieve the status of the driver.
            In case of a successful completion the driver returns
            DRV_OK and the current status of the driver in the buffer
            out_StatusPtr points to.
            In case the driver is not configured yet, it returns
            DRV_NOTCONFIGURED. In this case the contents of the
            buffer out_StatusPtr is invalid.
            In case out_StatusPtr equals NULL or device is unknown
            the driver returns DRV_INVALID_PARAMS.

*/

GLOBAL UBYTE audio_GetStatus (UBYTE               in_DeviceID,
                              audio_Status_Type * out_StatusPtr)
{
  if ( out_StatusPtr EQ NULL )
  {
    return DRV_INVALID_PARAMS;
  }
  else
  {
    if (in_DeviceID EQ AUDIO_SPEAKER)
    {
      out_StatusPtr -> min_volume = AUDIO_MIN_VOLUME;
      out_StatusPtr -> max_volume = AUDIO_MAX_VOLUME;
    }
    else if (in_DeviceID EQ AUDIO_BUZZER)
    {
      out_StatusPtr -> min_volume = AUDIO_MIN_BUZ_VOLUME;
      out_StatusPtr -> max_volume = AUDIO_MAX_BUZ_VOLUME;
    }
    else if (in_DeviceID EQ AUDIO_MICROPHONE)
    {
      out_StatusPtr -> min_volume = AUDIO_MIN_MIC_VOLUME;
      out_StatusPtr -> max_volume = AUDIO_MAX_MIC_VOLUME;
    }
    else
    {
      return DRV_INVALID_PARAMS;
    }
  }

  return DRV_OK;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_AUDIO                  |
| STATE   : code                ROUTINE : audio_GetSoundImage        |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to copy the image of a driver
            internal sound image into an application specific sound
            image buffer. The application may modify the sound.
            In case of a successful completion the function returns
            DRV_OK. In case the size of the buffer where the sound image
            shall be copied to is too small the driver returns
            DRV_INVALID_PARAMS. In case a specific driver implementation
            does not support this functionality the driver returns
            DRV_FCT_NOTSUPPORTED.

*/

GLOBAL UBYTE audio_GetSoundImage (UBYTE   in_SoundID,
                                  void  * out_SoundImagePtr)
{
  return AUDIO_FCT_NOTSUPPORTED;
}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6103)       MODULE  : DRV_AUDIO                  |
| STATE   : code                ROUTINE : audio_SetAmplf             |
+--------------------------------------------------------------------+

  PURPOSE : This function is used to set the amplification for the
            device identified by the parameter in_DeviceID.
            In the case of a speaker this is the volume, for a
            microphone - the pre-amplifier that regulates the
            sensitivity of the microphone. The valid range depends on
            the hardware used. If the amplification could be changed
            for the specified device, the function returns DRV_OK. If
            the amplification value (in_Amplf) is out of range or the
            specified device is unknown or the specified device does
            not support the amplification setting, the function
            returns DRV_INVALID_PARAMS.

*/

GLOBAL UBYTE audio_SetAmplf (UBYTE in_DeviceID, UBYTE in_Amplf)
{
  if (in_DeviceID EQ AUDIO_MICROPHONE)
  {
    act_micVolume = 75;         /* voice quality is best at this microphone volume */
#ifdef ALR
#else
    VG_UlVolume (act_micVolume);
#endif
  }
  else if (in_DeviceID EQ AUDIO_SPEAKER)
  {
    TRACE_EVENT_P1("VOLUME=%d", in_Amplf);

#ifdef ALR
    ABB_DlVolume (in_Amplf);   /* output volume */
    ABB_SideTone (175);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -