?? init8416viaspi.asm
字號(hào):
#include <def21262.h>
#include "CS8416.h"
#include <SRU.h>
.global _init8416viaSPI;
.global _read_8416_register;
//===============================================================
.section/pm seg_pmco;
_init8416viaSPI:
call _set8416_SPI_Params;
r11=SPDIF_CTRL1;
r12=0x00;
call _write_8416_register;
r11=SPDIF_CTRL2;
r12=(GPO_NON_AUDIO);
call _write_8416_register;
r11=SPDIF_CTRL3;
r12=(0xC0);
call _write_8416_register;
r11=SPDIF_CTRL4;
r12=(0x81);
call _write_8416_register;
r11=SPDIF_DATA_FORMAT;
r12=(FRMT_I2S);
call _write_8416_register;
r11=SPDIF_RX_ERR_MASK;
r12=0x00;
call _write_8416_register;
r11=SPDIF_INT_MASK;
r12=0x00;
call _write_8416_register;
r11=SPDIF_INT_MODE_MSB;
r12=0x00;
call _write_8416_register;
r11=SPDIF_INT_MODE_LSB;
r12=0x00;
call _write_8416_register;
// call _flush_SPI_FIFO;
rts;
_init8416viaSPI.end:
//----------------------------------------------------------------------------
_set8416_SPI_Params:
//---------------------------------------------------------
// Writing TXFLSH and RXFLSH bits in SPICTL clear the SPI
// transmit and receive FIFOs, respectively.
r0 = (TXFLSH | RXFLSH );
dm(SPICTL)=r0;
//----------------------------
// Set the baud rate to 1 MHz
r0 = 100;
dm(SPIBAUD) = r0;
//--------------------------------------------
// Set the SPIFLG register to zero because the flag
// pins are not used as the device select
r0 = 0;
dm(SPIFLG) = r0;
//------------------------------------------------------
// Now set the SPI control register
r0 = (SPIEN | // enable the port
SPIMS | // set SHARC as SPI master
MSBF | // send MSB first
TIMOD1); // Initialize SPI port to begin
// transmitting when DMA is enabled
dm(SPICTL) = r0;
rts;
_set8416_SPI_Params.end:
//----------------------------------------------------------------------------
_flush_SPI_FIFO:
// Clear the SPI receive and transmit shift registers
r0 = (TXFLSH | RXFLSH );
dm(SPICTL)=r0;
rts;
_flush_SPI_FIFO.end:
//----------------------------------------------------------------------------
_SPI_xfer_8416:
// Word to transmit is passed in r8
// Word send back from 8416 is returned in r8
dm(TXSPI)=r8;
// Wait until "SPI transfer complete" status bit
// in SPISTAT (SPIF) indicates that we can send more
do checkIfXferisDone until TF;
ustat3 = dm(SPISTAT);
BIT TST ustat3 SPIF;
checkIfXferisDone:
nop;
// Wait an extra 100 cycles to gate the clock down
lcntr = 100, do pauseFor1835_xfer until lce;
pauseFor1835_xfer:
nop;
word_sent:
nop;
r8=dm(RXSPI);
call _flush_SPI_FIFO;
rts;
_SPI_xfer_8416.end:
//----------------------------------------------------------------------------
_read_8416_register:
// Pass the address to read in r10, and the value is returned in r10
// Initialize the SPI port
call _set8416_SPI_Params;
SRU(LOW,DAI_PB15_I);
// Send the CS8416 ID indicating a write
r0=SPDIF_WRITE_REG;
call _SPI_xfer_8416;
// Write the register address to the MAP
r0=r10;
call _SPI_xfer_8416;
// Ignore the MAP's return value by gating the device select
SRU(HIGH,DAI_PB15_I);
lcntr = 100, do pauseFor1835_read until lce;
pauseFor1835_read:
nop;
SRU(LOW,DAI_PB15_I);
// Send the CS8416 ID indicating a read
r0=SPDIF_READ_REG;
call _SPI_xfer_8416;
// Send a dummy value to clock the output
r0=0;
SRU(HIGH,DAI_PB15_I);
// call _flush_SPI_FIFO;
r10=dm(RXSPI);
rts;
_read_8416_register.end:
//----------------------------------------------------------------------------
_write_8416_register:
// Pass the address to write in r11 and the value to write in r12
SRU(LOW,DAI_PB15_I);
r0=SPDIF_WRITE_REG;
call _SPI_xfer_8416;
r0=r11;
call _SPI_xfer_8416;
r0=r12;
call _SPI_xfer_8416;
SRU(HIGH,DAI_PB15_I);
rts;
_write_8416_register.end:
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -