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

📄 appio.c

📁 g.726编解码源程序
💻 C
字号:
/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) RF3_UART_G726 1.00.00 07-18-02 (swat-c03)" */
/*
 *  ======== appIO.c ========
 *
 *  Apllication IO initialization and priming
 *
 *  Application IO consists of streaming IO (which is handled by the LIO 
 *  -- low-level IO -- driver), and every other application-specific IO. 
 *  LIO driver is further interfaced with PLIO (PIP LIO) adapter for 
 *  simplicity of use with pipes. PLIO connects the low-level driver to
 *  pipes, so once initialized, the incoming data is simply retrieved
 *  from pipes, and the outgoing data is simply put to pipes. PLIO and LIO
 *  ensure that the data is streamed to the proper physical device.
 *
 *  We initialize the streaming IO here, and prime it, by placing zeroes
 *  at the output (transmit pipe), so those zeroes will be transferred
 *  while waiting for the first input frames and processing them.
 */

#include <std.h>
#include <string.h>

#include <lio.h>                /* LIO interface definition */
#include <dsk5402_dma_ad50.h>   /* driver for DSK5402 AD50 codec, using DMA */
#include <dsk5402_uart.h>       /* driver for DSK5402 UART */
#include <plio.h>               /* PLIO adapter decls. */
#include <utl.h>                /* debug/diagnostics utility functions */
#include <pip.h>
#include <swi.h>

#include "appResources.h"       /* application-wide common info (and CDB) */
#include "appIO.h"              /* application IO initialization and priming */

/* 
 *  Declaration of PLIO objects for receive and transmit:
 *  plioRxCodec is in charge of transferring data from codec to pipRxCodec,
 *  plioTxCodec is in charge of transferring data from pipTxCodec to codec,
 *  plioRxUart is in charge of transferring data from Uart to pipRxUart,
 *  plioTxUart is in charge of transferring data from pipTxUart to UART.
 */
PLIO_Obj plioRxCodec, plioTxCodec;
PLIO_Obj plioRxUart, plioTxUart;

/*
 *  ======== appIOInit ========
 *  Initialize LIO and other (non-streaming) IO components, if any
 */
Void appIOInit() 
{
    /* 
     *  Initialization of the LIO/PLIO Codec driver 
     *  DSK5402_DMA_AD50_init() initializes the codec, McBSP, and the DMA;
     *  PLIO_new initializes a PLIO object with the following arguments:
     *  1. address of the PLIO object
     *  2. handle of the associated pipe (pipRx for input and pipTx for output)
     *  3. mode: input or output
     *  4. address of the function table for the low-level driver
     *  5. optional generic arguments
     */
    DSK5402_DMA_AD50_init();
    
    /*  
     *  Initialize the codec with default parameters; if we were to change
     *  some of the default parameters, we would say
     *     DSK5402_DMA_AD50_Setup mySetup = DSK5402_DMA_AD50_SETUP;
     *     mySetup.control3 = ...
     *     DSK5402_DMA_AD50_setup( &mySetup );
     *  By passing NULL the driver will use whatever is in the default
     *  global DSK5402_DMA_AD50_SETUP for setup parameters.
     */
    DSK5402_DMA_AD50_setup( NULL );
    
    /* Initialize the PLIO driver for the codec*/
    PLIO_new( &plioRxCodec, &pipRxCodec, LIO_INPUT,  &DSK5402_DMA_AD50_ILIO, NULL );
    PLIO_new( &plioTxCodec, &pipTxCodec, LIO_OUTPUT, &DSK5402_DMA_AD50_ILIO, NULL );

    /* 
     *  Initialization of the UART LIO/PLIO driver 
     */
    DSK5402_UART_init();

    /*  
     *  Initialize the UART with default parameters; if we were to change
     *  some of the default parameters, we would say
     *     DSK5402_UART_Setup myUartSetup = DSK5402_UART_SETUP;
     *     myUartSetup.control3 = ...
     *     DSK5402_UART_setup( &myUartSetup );
     *  By passing NULL the driver will use whatever is in the default
     *  global DSK5402_UART_SETUP for setup parameters.
     */
    DSK5402_UART_setup( NULL );

    /* Initialize the PLIO driver for the codec*/
    PLIO_new( &plioRxUart, &pipRxUart, LIO_INPUT,  &DSK5402_UART_ILIO, NULL );
    PLIO_new( &plioTxUart, &pipTxUart, LIO_OUTPUT, &DSK5402_UART_ILIO, NULL );
}

/*
 *  ======== appIOPrime ========
 *  Prime the input/output data stream pipes and start the transfer
 */
Void appIOPrime()
{
    /* Prime the receive side with empty buffers to be filled. */
    PLIO_rxStart( &plioRxCodec, PIP_getWriterNumFrames( &pipRxCodec ) );

    /*
     *  allocate a frame of the UART output pipe and clear it,
     *  so the first execution of swiEncode can start by putting
     *  this empty frame. This will synchronise the UART output with
     *  the beginning of swiEncode (i.e. with the next buffer received
     *  by the codec.
     */
    PIP_alloc(&pipTxUart);
    memset(PIP_getWriterAddr(&pipTxUart),0,20);
    
    /*
     *  When returning from the main, DSP/BIOS calls the notify writer
     *  functions of each pipe, since we allocate a pipe from pipTxUart,
     *  its notify writer function won't be called automatically. So we
     *  manually execute it by clearing the swiEncode mailbox 2nd bit.
     */
    SWI_andn(&swiEncode,0x2);
}

⌨️ 快捷键说明

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