CODEC__spi.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002                            C   M O D U L E   F I L E
00003 
00004     Copyright (c) 2003 Neuros Audio LLC, All rights reserved.
00005 
00006 ******************************************************************************/
00007 
00016 
00017 /*-- HEADER FILE INCLUDES ---------------------------------------------------*/
00018 #include "../SYSTEM/sys_hardware.h"
00019 #include "codec.h"
00020 
00021 /*-- LOCAL DEFINITIONS ------------------------------------------------------*/
00022 
00023 /*-- STATIC DATA ------------------------------------------------------------*/
00024 
00025 /*-- GLOBAL DATA ------------------------------------------------------------*/
00026 
00027 /*-- FUNCTIONS --------------------------------------------------------------*/
00028 #pragma CODE_SECTION(CODEC__spiWrite, ".sram0_resident")
00035 void CODEC__spiWrite(unsigned short cmd)
00036 {
00037     unsigned short i;
00038     unsigned short iTmp;
00039 
00040     SPI_lock(SYS_FOREVER);
00041         
00042     // clear the clock.  All data is latched in on the rising edge.
00043     iTmp = SPI_CLK;      
00044     
00045     // clear tuner data line to set to input.
00046     //iTmp = TUNER_DAT; 
00047     
00048     // clear the CODEC enable to enable.    
00049     iTmp = CODEC_EN;
00050     SYS_delayMicrosecond(1);
00051     for (i = 0; i < 16; i++)
00052     {
00053         iTmp = SPI_CLK;                 
00054         
00055         if (cmd & 0x8000) SPI_DATA = 0x0;
00056         else iTmp = SPI_DATA;
00057         
00058         SYS_delayMicrosecond(1);
00059         SPI_CLK = 0x0;
00060         SYS_delayMicrosecond(1);
00061         cmd = cmd<<1;
00062     }
00063     
00064     // disable the EEPROM;
00065     //  asm (" ssbx XF");       
00066         
00067     // clear SPI clock 
00068     iTmp = SPI_CLK;         
00069         
00070     // clear the DATA line, set to input.
00071     iTmp = SPI_DATA;
00072         
00073     // clear the DATA line on the tuner to set to input
00074     //iTmp = TUNER_DAT;     
00075         
00076     // set codec enable to disable
00077     CODEC_EN = 0x0; 
00078         
00079     // put tuner in read mode.
00080     //iTmp = TUNER_WR;
00081     
00082     SPI_unlock();
00083 }
00084 
00085 
00086 /*****************************************************************************
00087                 Neuros Audio LLC. Confidential Proprietary
00088  *****************************************************************************/

Generated on Wed Jan 19 01:12:37 2005 for neuros-firmware by  doxygen 1.3.9.1