ad50.c
上传用户:dahaojd
上传日期:2008-01-29
资源大小:14357k
文件大小:2k
- /*
- * Copyright 2003 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.
- *
- */
- /* "@(#) DDK 1.11.00.00 11-04-03 (ddk-b13)" */
- /*
- * ======== ad50.c ========
- */
- #include <std.h>
- #include <csl.h>
- #include <csl_mcbsp.h>
- #include <ad50.h>
- static Void spWrite(MCBSP_Handle hMcbsp, Uns dataVal);
- static Void codecControlWrite(MCBSP_Handle hMcbsp, Uns regVal, Uns dataVal);
- /*
- * ======== AD50_init ========
- */
- #pragma CODE_SECTION(AD50_init, ".text:init")
- Void AD50_init( Void )
- {
- }
- /*
- * ======== AD50_setParams ========
- */
- Void AD50_setParams(MCBSP_Handle hMcbsp, AD50_Params *params)
- {
- codecControlWrite(hMcbsp, 1, params->control1);
- codecControlWrite(hMcbsp, 2, params->control2);
- codecControlWrite(hMcbsp, 3, params->control3);
- codecControlWrite(hMcbsp, 4, params->control4);
- }
- /*
- * ======== codecControlWrite ========
- * The 16-bit word in each control register is composed of:
- * b15-b8 -> register address to talk to 1 of 5 control registers
- * b7-b0 -> data.
- */
- static Void codecControlWrite(MCBSP_Handle hMcbsp, Uns regVal, Uns dataVal)
- {
- Uns temp;
-
- temp = (regVal << 8) | (dataVal & 0x00ff);
- /* write '1' to put codec into command mode */
- spWrite(hMcbsp, 1);
- /* write the command */
- spWrite(hMcbsp, temp);
- }
- /*
- * ======== spWrite ========
- * WARNING! Unbounded while loop!
- * spWrite() should only be called during init time.
- */
- static Void spWrite(MCBSP_Handle hMcbsp, Uns dataVal)
- {
- while(!MCBSP_xrdy(hMcbsp)) {
- /* wait for TX ready */
- }
- MCBSP_write(hMcbsp, dataVal);
- }