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

📄 tda1315.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的设备库的源码
💻 C
字号:
/*
 * Copyright (c) 1995,1996,1997 by TriMedia Technologies. 
 *
 * +------------------------------------------------------------------+
 * | This software is furnished under a license and may only be used  |
 * | and copied in accordance with the terms and conditions of  such  |
 * | a license and with the inclusion of this copyright notice. This  |
 * | software or any other copies of this software may not be provided|
 * | or otherwise made available to any other person.  The ownership  |
 * | and title of this software is not transferred.                   |
 * |                                                                  |
 * | The information in this software is subject  to change without   |
 * | any  prior notice and should not be construed as a commitment by |
 * | TriMedia Technologies.                                           |
 * |                                                                  |
 * | this code and information is provided "as is" without any        |
 * | warranty of any kind, either expressed or implied, including but |
 * | not limited to the implied warranties of merchantability and/or  |
 * | fitness for any particular purpose.                              |
 * +------------------------------------------------------------------+
 *
 *  Module name              : tda1315.c    1.6
 *
 *  Last update              : 18:43:47 - 00/11/09
 *
 *  Description              :
 *
 *  Initialize and control routines for TM1 SPDIF 8 channel audio.
 *  Designed to be called from TM Device Library's board support package
 *
 *  Revision                 :
 *      Built for the TCS 1.1z release
 *
 *
 */


#include <stdio.h>
#include <tm1/tmIIC.h>
#include <tm1/tmProcessor.h>
#include <tm1/tmInterrupts.h>
#include <tm1/mmio.h>
#include <tm1/tmLibdevErr.h>
#include <tm1/tmAOmmio.h>
#include <ops/custom_defs.h>
#include <tmlib/tmtypes.h>
#include <math.h>
#include <stdio.h>

#include <tm1/tmAssert.h>
#include <tmlib/dprintf.h>      /* for debugging with DP(()) */

#include "tda1315.h"
#include "l3.h"

/* declaration of privat functions */
static tmLibdevErr_t tda1315WriteStrobe(pl3Param_t l3Params);

static tmLibdevErr_t tda1315WriteStrobe(pl3Param_t l3Params)
{
    UInt          iicd;
    UInt          iicAddress = l3Params->address;
    UInt8         strobeMask = l3Params->usrPin0;
    tmLibdevErr_t err;

    iicReadReg(iicAddress, -1, &iicd);
    iicd |= strobeMask;
    iicWriteReg(iicAddress, -1, iicd);   

    microsleep(360);

    iicReadReg(iicAddress, -1, &iicd);
    iicd &= ~strobeMask;
    err = iicWriteReg(iicAddress, -1, iicd);
    return err;
}



extern tmLibdevErr_t tda1315AccessL3(pl3Param_t l3Params, tda1315Register_t mode)

/*  Various modes are supported to read and write the L3 bus       */
/*  READ_CHANNEL_STATUS_REGISTERS   = Read the channel status      */
/*  WRITE_CHANNEL_STATUS_REGISTER   = Write the channel status     */
/*  Channel Status Register of L3 bus 
   BYTE1
   0,1:  Clock Accuracy
   2,3:  Sample frequency       00 = 44.1kHz, 01 = 48 kHz, 11 = 32 kHz
   4  :  Pre-emphasis
   5  :  copyright              0 = copyright, 1 = no copyright 
   6  :  audio/data             0 = PCM, 1 = no PCM (e.g. AC-3)
   7  :  consumer/professional  0 = consumer use
   Default value = 0xXX [xxxxxxxx]
   BYTE2
   0  :  category code
   1  :  category code
   2  :  category code
   3  :  category code
   4  :  category code
   5  :  category code
   6  :  category code
   7  :  category code
   Default value = 0xXX [xxxxxxxx]
*/  
/*  READ_USER_DATA_REGISTER     = Read the user data register                                         */
/*  READ_STATUS_REGISTER        = Read the status register                                            */
/*  WRITE_USER_DATA_REGISTER        = Write the user data register                                    */
/*  WRITE_CONTROL_REGISTER      = Write the control register                                          */
/* Control Register of L3 bus 
   BYTE1
   0  :  Transmit/receive mode:     1=transmit  0=receive
   1  :  Decode subcode Q-channel:  0=enable    1=disable
   2,3:  Number of bits to transfer:00=16bit    01=18bit    10=20bit  11=24bit
   4  :  Clear user data buffer:    0=clear     1=leave as is
   5  :  reserved
   6  :  reserved
   7  :  reserved
   Default value = 0xE2 [xxx00010]
   BYTE2
   0  :  Audio mute:                0=enabled   1=disabled
   1  :  IEC output enable:         0=enabled   1=disabled
   2  :  Select IEC input:          0=TTL level 1=high sensitivity
   3  :  IIS output enable:         0=enabled   1=disabled
   4  :  Select IIS bus source:     0=SDAUX     1=SD
   5  :  Select clock frequency:    0=384fs     1=256fs
   6  :  reserved
   7  :  reserved
   Default value = 0xF7 [xxxx0111]
*/  

{
    tmLibdevErr_t err = TMLIBDEV_OK;
    
    switch (mode)
    {
    case READ_CHANNEL_STATUS_REGISTER:
        l3Params->l3Address = l3Params->l3Address << 2 | 0x00;
        err = l3Read(l3Params);
        break;
    case READ_USER_DATA_REGISTER:
        l3Params->l3Address = l3Params->l3Address << 2 | 0x01;
        err = l3Read(l3Params);
    case READ_STATUS_REGISTER:
        l3Params->l3Address = l3Params->l3Address << 2 | 0x03;
        err = l3Read(l3Params);
        break;
    case WRITE_CHANNEL_STATUS_REGISTER:
        l3Params->l3Address = l3Params->l3Address << 2 | 0x00;
        err = l3Write(l3Params);
        break;
    case WRITE_USER_DATA_REGISTER:
        l3Params->l3Address = l3Params->l3Address << 2 | 0x01;
        err = l3Write(l3Params);
        break;
    case WRITE_CONTROL_REGISTER:
        l3Params->l3Address = l3Params->l3Address << 2 | 0x02;
        err = l3Write(l3Params);
        if (err)
            return err;
        err = tda1315WriteStrobe(l3Params);
        break;
    default:
        tmAssert(0, __LINE__);
    }
    return err;
}

/* fucntion to initialize the TDA1315 for output */
extern tmLibdevErr_t tda1315InitOutput(pl3Param_t l3Params, boardAOParam_t * param)
{
    Int  rval;
   
    /* Control Register of L3 bus 
    BYTE1
    0  :  Transmit/receive mode:     0=receive	 1=transmit
    1  :  Decode subcode Q-channel:  0=enable    1=disable
    2,3:  Number of bits to transfer:00=16bit    01=18bit    10=20bit  11=24bit
    4  :  Clear user data buffer:    0=clear     1=leave as is
    5  :  reserved
    6  :  reserved
    7  :  reserved
    Default value = 0xE1 [xxx00001]

    BYTE2
    0  :  Audio mute:                0=enabled   1=disabled
    1  :  IEC output enable:         0=enabled   1=disabled
    2  :  Select IEC input:          0=TTL level 1=high sensitivity
    3  :  IIS output enable:         0=enabled   1=disabled
    4  :  Select IIS bus source:     0=SDAUX     1=SD
    5  :  Select clock frequency:    0=384fs     1=256fs
    6  :  reserved
    7  :  reserved
    Default value = 0xFD [xx111101]
    */

    l3Params->data[0] = 0xe1;
    l3Params->data[1] = 0xfd;
    rval = tda1315AccessL3(l3Params, WRITE_CONTROL_REGISTER);
    
    /* set the channel status register */
    switch (param->audioSubtypeFormat)
    {
        default:
            break;
    }
    return (rval);   
}



extern tmLibdevErr_t tda1315InitInput(pl3Param_t l3Params, boardAIParam_t * param)
{
    Int          rval;

    /* Control Register of L3 bus 
    BYTE1
    0  :  Transmit/receive mode:     1=transmit  0=receive
    1  :  Decode subcode Q-channel:  0=enable    1=disable
    2,3:  Number of bits to transfer:00=16bit    01=18bit    10=20bit  11=24bit
    4  :  Clear user data buffer:    0=clear     1=leave as is
    5  :  reserved
    6  :  reserved
    7  :  reserved
    value = 0xE2 [xxx00010]
    BYTE2
    0  :  Audio mute:                0=enabled   1=disabled
    1  :  IEC output enable:         0=enabled   1=disabled
    2  :  Select IEC input:          0=TTL level 1=high sensitivity
    3  :  IIS output enable:         0=enabled   1=disabled
    4  :  Select IIS bus source:     0=SDAUX     1=SD
    5  :  Select clock frequency:    0=384fs     1=256fs
    6  :  reserved
    7  :  reserved
    value = 0xF7 [xx110111]
    */  

    l3Params->data[0] = 0xe2;
    l3Params->data[1] = 0xf7;
    rval = tda1315AccessL3(l3Params, WRITE_CONTROL_REGISTER);
    return rval;
}

⌨️ 快捷键说明

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