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

📄 ac48drhi.c

📁 this for the ac founction in voip.
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************************************/
/*           *   AudioCodes Ltd.   *   Copyright (c) 1998   *           */
/************************************************************************/
/* File Name:       Ac48DrHi.c                                          */
/************************************************************************/
/* DRIVERS PACKET VERSION:     481(1.30) / 480(1.60) / 483(1.00)        */
/************************************************************************/
/* 4804 OPERATION SOFTWARE VERSION SUPPORT:                             */
/*                       V 1.60 (December 1999) and above	            */
/************************************************************************/
/* 481xx OPERATION SOFTWARE VERSION SUPPORT:                            */
/*                       V 1.30 (October 1999) and above                */
/************************************************************************/
/* 4830x OPERATION SOFTWARE VERSION SUPPORT:                            */
/*                       V 1.00 (March 2000) and above                  */
/************************************************************************/
/* PURPOSE  :   This source file contains the High Level Driver.        */
/*              The High Level Drivers include routines that manage     */
/*              all the required communication with the AC48 by         */
/*              sending/receiving the appropriate commands and          */
/*              information.                                            */
/*                                                                      */
/* DATE     :	May 1998												*/
/* UPDATE       REASON TO UPDATE                                        */
/* ======       ================                                        */
/* 11/8/98      Adding 'Version' functions                              */
/* 18/9/98      Adding 'receive wrong packet'                           */
/* 19/10/98     Disable "Ac48xxSetHPIByteOrder()" from Setup device.    */
/*                                                                      */
/* 28/10/98     Update Ac48xxVersion function.                          */
/* 29/10/98     Correct the 'Ac48xxReceivePacket' in polling mode.      */     
/* 1/11/98      In "Ac48xxReceivePacket()" :                            */
/*                  (1) correct the  ILLEGAL_PACKET value .             */
/*                  (2) The 'sequence number' added to returned value   */
/*                      in case of "SNE".                               */
/* 26/1/99      Comment for Ac48xxReceivePacket function:               */
/*                  "PacketSize not include footer size, in eny case"   */
/* 27/1/99      Voice Attributes, Command additions...                  */
/* 4/1/99       Add "ILLEGAL_PACKET" error to Ac48xxTransmitPacket()    */
/* 15/6/99      'ROR' Flag Added insted of.., In Ac48xxReceivePacket()  */
/* 17/1/00      Add Ac48xxBootCompletely() and                          */
/*              Ac48xxBootCompletelyForDebugging() Functions            */
/************************************************************************/

#include "../include/drv_def.h"
#include "../include/app_drv.h"

#include "acdefine.h"

#include "Ac48DrDf.h"
#include "Ac48DrHw.h"
#include "Ac48DrHi.h"
#include "Ac48DrLo.h"

/*======================================================================*/
/* Name    :        Ac48xxActiveCommand                                 */
/*======================================================================*/
/* Purpose :    This function transfers a specific channel to an active */
/*              mode, by sending the AC48 ACTIVE command.               */
/*                                                                      */
/* Inputs  :    int DeviceIndex:                                        */
/*                  An integer, performing the device index.            */
/*              int ChannelIndex: 	                                    */
/*                  An integer, performing the channel index.           */
/*              TDebugMode DebugMode	                                */
/*                  Debug mode, to use (see: AC48xxDebugCommand).       */
/*              TWaitMode WaitMode:                                     */
/*               	Wait / don't wait for the AC48 to be                */
/*                  ready to deal with a new Command,                   */
/*                  which uses the 'AC48xxTransmitPacket'               */
/*                  function.                                           */
/*                                                                      */
/* Output  :    int:                                                    */
/*                  ( 0) "AC_OK" for successful operation.              */
/*                  (-1) "PACKET-FULL" detection in                     */
/*                          "DONT_WAIT_PACKET_EMPTY" mode.              */
/*                          AC48 is not ready to transmit a new packet  */
/*                          (suitable mode for polling).                */
/*                  ( 2) "STATUS_ERROR" detected by the AC48.           */
/*======================================================================*/
int Ac48xxActiveCommand(int DeviceIndex, int ChannelIndex, 
						TDebugingData DebugingData, TWaitMode WaitMode)
{
    int Status;
    TActiveCommand ActiveCommand;

    ActiveCommand.Header.ConstAA=0xAA;
    ActiveCommand.Header.Id=ChannelIndex;
    ActiveCommand.Header.Const_0_0_10=0;
    ActiveCommand.Header.IdleCommandOpCode = ACTIVE_COMMAND_OP_CODE;
    ActiveCommand.Header.IdleCommandLength=0x04;
    Status = Ac48xxTransmitPacket(DeviceIndex, (char*)&ActiveCommand, 
    											DebugingData, WaitMode);
//    Ac48xxClearSequenceArrays(DeviceIndex, ChannelIndex);
    return Status;
}

/*======================================================================*/
/* Name    :        Ac48xxCasPortPresetCommand                          */
/*======================================================================*/
/* Purpose :    This function preset the A,B,C,D CAS signals to their   */
/*              init values.                                            */
/*                                                                      */
/* Inputs  :    int DeviceIndex:                                        */
/*                  An integer, performing the device index.            */
/*              int ChannelIndex: 	                                    */
/*                  An integer, performing the channel index.           */
/*              int SignalA                                             */
/*              int SignalB                                             */
/*              int SignalC                                             */
/*              int SignalD                                             */
/*              TDebugMode DebugMode	                                */
/*                  Debug mode, to use (see: AC48xxDebugCommand).       */
/*              TWaitMode WaitMode:                                     */
/*               	Wait / don't wait for the AC48 to be                */
/*                  ready to deal with a new Command,                   */
/*                  which uses the 'AC48xxTransmitPacket'               */
/*                  function.                                           */
/*                                                                      */
/* Output  :    int:                                                    */
/*                  ( 0) "AC_OK" for successful operation.              */
/*                  (-1) "PACKET-FULL" detection in                     */
/*                          "DONT_WAIT_PACKET_EMPTY" mode.              */
/*                          AC48 is not ready to transmit a new packet  */
/*                          (suitable mode for polling).                */
/*                  ( 2) "STATUS_ERROR" detected by the AC48.           */
/*======================================================================*/
int  Ac48xxCasPortPresetCommand(int DeviceIndex, int ChannelIndex, 
                         int SignalA, int SignalB, int SignalC, int SignalD, 
						TDebugingData DebugingData, TWaitMode WaitMode)
{
    TCasPortPresetCommand CasPortPresetCommand;

    CasPortPresetCommand.Header.ConstAA = 0xAA;
    CasPortPresetCommand.Header.Id = ChannelIndex;
    CasPortPresetCommand.Header.Const_0_0_10 = 0;
    CasPortPresetCommand.Header.IdleCommandOpCode = CAS_PORT_PRESET_COMMAND_OP_CODE;
    CasPortPresetCommand.Header.IdleCommandLength = 0x06;
    CasPortPresetCommand.SignalA = SignalA;
    CasPortPresetCommand.SignalB = SignalB;
    CasPortPresetCommand.SignalC = SignalC;
    CasPortPresetCommand.SignalD = SignalD;
    CasPortPresetCommand.Const_0_2_4 = 0;
    CasPortPresetCommand.Const_0_2_8 = 0;
    return Ac48xxTransmitPacket(DeviceIndex, (char*)&CasPortPresetCommand, 
    											DebugingData, WaitMode);
}

/*======================================================================*/
/* Name    :        Ac48xxCheckHInt                                     */
/*======================================================================*/
/* Purpose :    This function check if an interrupt had been sent by    */
/*              AC48 to the host. This function suiteble for polling.   */
/*                                                                      */
/* Inputs  :    int DeviceIndex:                                        */
/*                  An integer, performing the device index.            */
/*                                                                      */
/* Output  :    int:                                                    */
/*                  (0)       No interrupt had been sent.               */
/*                  otherwise HINT had been sent by AC48.               */
/*======================================================================*/
int Ac48xxCheckHInt(int DeviceIndex)
{
    char Status;

    Status=Ac48xxHostRead(DeviceIndex, HPIC, First);
    Ac48xxHostRead(DeviceIndex, HPIC, Second);
    return (int)(Status & CHECK_HINT);
}

/*======================================================================*/
/* Name    :        Ac48xxClearHInt                                     */
/*======================================================================*/
/* Purpose :    This function Clear the interrupt, if had been sent by  */
/*              AC48 to the host.                                       */
/*                                                                      */
/* Inputs  :    int DeviceIndex:                                        */
/*                  An integer, performing the device index.            */
/*======================================================================*/
void Ac48xxClearHInt(int DeviceIndex)
{
    char Status;

    Status=Ac48xxHostRead(DeviceIndex, HPIC, First);
    Ac48xxHostRead(DeviceIndex, HPIC, Second);
    Ac48xxHostWrite((Status | CLEAR_HINT), DeviceIndex, HPIC, First);
    Ac48xxHostWrite((Status | CLEAR_HINT), DeviceIndex, HPIC, Second);
}


/*======================================================================*/
/* Name    :        Ac48xxSetHPIByteOrder                               */
/*======================================================================*/
/* Purpose :    This function defines the order, AC48 will read and     */
/*              write bytes.                                            */
/*                                                                      */
/* Inputs  :    int DeviceIndex:                                        */
/*                  An integer, performing the device index.            */
/*              TOrder Order                                            */
/*                  Order: MSB_FIRST=0 / LSB_FIRST=1                    */
/*======================================================================*/
void Ac48xxSetHPIByteOrder(int DeviceIndex, TOrder Order)
{     			
    Ac48xxHostWrite(Order, DeviceIndex, HPIC, First);
    Ac48xxHostWrite(Order, DeviceIndex, HPIC, Second);
}
/*======================================================================*/
/* Name    :        Ac48xxVersion                                       */
/*======================================================================*/
/* Purpose :   return sowtware version packed in a structure.           */
/*                                                                      */
/*======================================================================*/
TVersion Ac48xxVersion(const char *DownloadBlock, char *Name) /*Neme[13]*/
{
    TVersion Version;
    int i;
    char String[5];
    String[4]=0; /* end of String */

    String[2] = DownloadBlock[0]+'0';
    String[3] = DownloadBlock[1]+'0';
    Version.Version = atoi(&String[2]);

    String[2] = DownloadBlock[2]+'0';
    String[3] = DownloadBlock[3]+'0';
    Version.SubVersion = atoi(&String[2]);

    String[2] = DownloadBlock[4]+'0';
    String[3] = DownloadBlock[5]+'0';
    Version.Month = atoi(&String[2]);

    String[2] = DownloadBlock[6]+'0';
    String[3] = DownloadBlock[7]+'0';
    Version.Day = atoi(&String[2]);

    String[0] = DownloadBlock[8]+'0';
    String[1] = DownloadBlock[9]+'0';
    String[2] = DownloadBlock[10]+'0';
    String[3] = DownloadBlock[11]+'0';
    Version.Year = atoi(String);

    strcpy(Name, "Ac48");
    for(i=0; i<6; i++)
    {
        Name[4+i] = DownloadBlock[12+i];
    }
    Name[4+i] = '\0';

⌨️ 快捷键说明

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