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

📄 dss_dsk6211.c

📁 DSP6000,bios APPLICATIONS 源码程序
💻 C
字号:
/*
 *  Copyright 2000 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.
 *  U.S. Patent Nos. 5,283,900  5,392,448
 */
/* "@(#) DSP/BIOS 4.00 03-27-00 (barracuda-e08)" */
/*
 *  ======== dss_dsk6211.c ========
 */

#include <std.h>
#include <log.h>

#include <c6x.h>
#include "c6211dsk.h"

#define MCSP_RXINT_BIT 0x0800      /* define McBSP interrupt */

/* function prototypes ... */
Void codec_init(void);
Void codec_error(Int id);
Void mcbsp0_init(void);
Uns mcbsp0_read(void);
Void mcbsp0_write(Uns out_data);

/*
 * ======== DSS_init ========
 */
Void DSS_init(void)
{
    mcbsp0_init();

    codec_init();

    /* Enable McBSP interrupt */
    IER |= MCSP_RXINT_BIT;
}

/*
 * ======== mcbsp0_init ========
 */ 
Void mcbsp0_init(void)
{
    /* set up McBSP0 */
    *(volatile Uns *)McBSP0_SPCR = 0x0; /*  reset serial port */
    *(volatile Uns *)McBSP0_PCR = 0x0;  /*  set pin control reg. */

    /* set RX and TX control registers to 16 bit data/frame */
    *(volatile Uns *)McBSP0_RCR = 0x10040;
    *(volatile Uns *)McBSP0_XCR = 0x10040;

    /* setup SP control register */ 
    *(volatile Uns *)McBSP0_SPCR = 0x00010001;
}

/*
 * ======== mcbsp0_write ========
 */
Void mcbsp0_write(Uns out_data)
{
    volatile Uns temp;

    temp = *(volatile Uns *)McBSP0_SPCR & 0x20000;
    while (temp == 0) {
        temp = *(volatile Uns *)McBSP0_SPCR & 0x20000;
    }

    *(volatile Uns *)McBSP0_DXR = out_data;
}

/*
 * ======== mcbsp0_read ========
 */
Uns mcbsp0_read(void)
{
    volatile Uns temp;

    temp = *(volatile Uns *)McBSP0_SPCR & 0x2;
    while (temp == 0) {
        temp = *(volatile Uns *)McBSP0_SPCR & 0x2;
    }

    temp = *(volatile Uns *)McBSP0_DRR;

    return (temp);
}
 
/* 
 * ======== codec_init ========
 */
Void codec_init(void)
{
    volatile Uns temp;   
  
    /* For more details on the setup for the TLC320AD535 Analog Interface, 
       refer to Appendix A of SLAS202a.pdf. To use Code Composer Studio Help: 
       Help->General Help, then in Contents tab double click TMS320C6211 DSK,
       double click Hardware, double click Analog Interface, then
       double click 'C6211 DSK Analog Interface Configuration, at the bottom
       is a link to the data manual.
     */

    /* set up control register 3 for S/W reset */
    mcbsp0_read();
    mcbsp0_write(0); 
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(1);
    mcbsp0_read();
    mcbsp0_write(0x0386);
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();
     
    /* set up control register 3 for mic input */
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(1);
    mcbsp0_read();
    mcbsp0_write(0x0306);
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();

    /* read control register 3 to verify mic input */
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(1);
    mcbsp0_read();
    mcbsp0_write(0x2330);
    temp = mcbsp0_read();
    mcbsp0_write(0x0);
    mcbsp0_read();
    mcbsp0_write(0x0);
    mcbsp0_read();
    if((temp & 0xff) != 0x06) {
        codec_error(3);
    }

    /* set up control register 4 to select Voice Channel Input 0db gain */
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(1);
    mcbsp0_read();
    mcbsp0_write(0x0400);
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();
  
    /* read and verify control register 4 */
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(1);
    mcbsp0_read();
    mcbsp0_write(0x2430);
    temp = mcbsp0_read();
    mcbsp0_write(0x0);
    mcbsp0_read();
    mcbsp0_write(0x0);
    mcbsp0_read();
    if((temp & 0xff) != 0x00) {
        codec_error(4);
    }
   
    /* set up control register 5 to select Voice Channel Output 0db gain */
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(1);
    mcbsp0_read();
    mcbsp0_write(0x0502);
    mcbsp0_read();
    mcbsp0_write(0);
    mcbsp0_read();
  
    /* read and verify control register 5 */
    mcbsp0_write(0);
    mcbsp0_read();
    mcbsp0_write(1);
    mcbsp0_read();
    mcbsp0_write(0x2530);
    temp = mcbsp0_read();
    mcbsp0_write(0x0);
    mcbsp0_read();
    mcbsp0_write(0x0);
    mcbsp0_read();
    if((temp & 0xfe) != 0x2) {
        codec_error(5);
    } 
}

/*
 * ======== codec_error ========
 */
Void codec_error(id)
{
    LOG_error("Error setting up register %d", id);

    for (;;) {
        /* loop forever */
    }
}

⌨️ 快捷键说明

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