void targetSpiInit(void) { //Initialize the DICE II SPI module to use the following GPIO //MOSI = GPIO11 //MISO = GPIO12 //CLK = GPIO8 spiInitialize(11, 12, 8); //Create the two slave devices spiGetSlaveDevice(&cpldSSId); spiGetSlaveDevice(&codecSSId); //Configure each of the devices and the slave select call back. spiConfigure(0, SPI_SET_SS_ROUTINE, spi_slave_select); spiConfigure(codecSSId, SPI_RATE, (void *)SPI_SPEED); spiConfigure(codecSSId, SPI_WSIZE, (void *)SPI_WSIZE_16); spiConfigure(cpldSSId, SPI_RATE, (void *)SPI_SPEED); spiConfigure(cpldSSId, SPI_WSIZE, (void *)SPI_WSIZE_16); //at init time, let's talk to CPLD and initialize //read the CPLD version spiOpBlock(cpldSSId, CPLD_SPI_RD_CMD(CPLD_VER_REG,0), &cpldVer); if (cpldVer>=255) cpldVer = 0; cpldSupported = ((cpldVer >= 12) && (cpldVer < 128)); if (cpldSupported) { //Enable parallel mode and passthrough of SPI to both Codecs spiOpBlock(cpldSSId, CPLD_SPI_WR_CMD(CPLD_CTRL_REG, CPLD_CTRL_PAR_EN | CPLD_CTRL_CODEC_EN | CPLD_CTRL_SPI1_EN | CPLD_CTRL_SPI2_EN | CPLD_CTRL_USER_EN), NULL); //read the initial switches spiOpBlock(cpldSSId, CPLD_SPI_RD_CMD(CPLD_SW_REG,0), &initialSwitchSetting); } else initialSwitchSetting = 0x1; //Flash mode }
void targetSpiInit(void) { //Create the SPI slaves spiGetSlaveDevice(&codecSSId); spiGetSlaveDevice(&ledSSId); spiGetSlaveDevice(&dispSSId); spiGetSlaveDevice(&dspSSId); //Create semaphore for receiving devices TCSemaphoreOpen (&dspSem,0); //this is common for all devices so we only need to set it for one spiConfigure(codecSSId, SPI_SET_SS_ROUTINE, spi_slave_select); //word size for the devices spiConfigure(codecSSId, SPI_WSIZE, (void *)SPI_WSIZE_16); spiConfigure(ledSSId, SPI_WSIZE, (void *)SPI_WSIZE_16); spiConfigure(dispSSId, SPI_WSIZE, (void *)SPI_WSIZE_16); spiConfigure(dspSSId, SPI_WSIZE, (void *)SPI_WSIZE_24); //speed for the devices spiConfigure(codecSSId, SPI_RATE, (void *)SPI_SPEED); spiConfigure(ledSSId, SPI_RATE, (void *)SPI_SPEED); spiConfigure(dispSSId, SPI_RATE, (void *)SPI_SPEED); spiConfigure(dspSSId, SPI_RATE, (void *)SPI_SPEED); //Only the DSP device is read from so it needs the complete function spiConfigure(dspSSId, SPI_COMPLETE_CB, spi_slave_complete_sb); //Get the PHY powered up and turn off all LED's spiOpBlockNoTask(ledSSId, LED_MASK(LED_PHY_NRST) | LED_ALL_LED_MASK,NULL); //Turn off all 7 Seg display spiOpBlockNoTask(dispSSId, 0xffff,NULL); }
void targetSpiInit(void) { spiGetSlaveDevice(&cpldSSId); spiGetSlaveDevice(&codecSSId); spiConfigure(codecSSId, SPI_SET_SS_ROUTINE, spi_slave_select); spiConfigure(codecSSId, SPI_COMPLETE_CB, spi_slave_complete_sb); spiConfigure(codecSSId, SPI_RATE, (void *)SPI_SPEED); spiConfigure(codecSSId, SPI_WSIZE, (void *)SPI_WSIZE_16); spiConfigure(cpldSSId, SPI_COMPLETE_CB, spi_slave_complete_sb); spiConfigure(cpldSSId, SPI_RATE, (void *)SPI_SPEED); spiConfigure(cpldSSId, SPI_WSIZE, (void *)SPI_WSIZE_16); TCSemaphoreOpen (&codecSem,0); TCSemaphoreOpen (&cpldSem,0); //at init time, let's talk to CPLD and initialize //read the CPLD version spiOpBlockNoTask(cpldSSId, CPLD_SPI_RD_CMD(CPLD_VER_REG,0), &cpldVer); if (cpldVer>=255) cpldVer = 0; cpldSupported = ((cpldVer >= 12) && (cpldVer < 128)); if (cpldSupported) { if (isChipDiceJR()) spiOpBlockNoTask(cpldSSId, CPLD_SPI_WR_CMD(CPLD_CTRL_REG,CPLD_CTRL_PAR_EN | CPLD_CTRL_CODEC_EN | CPLD_CTRL_SPI1_EN | CPLD_CTRL_SPI2_EN | CPLD_CTRL_USER_EN), NULL); else spiOpBlockNoTask(cpldSSId, CPLD_SPI_WR_CMD(CPLD_CTRL_REG,CPLD_CTRL_CODEC_EN | CPLD_CTRL_SPI1_EN | CPLD_CTRL_SPI2_EN | CPLD_CTRL_USER_EN), NULL); //read the switches spiOpBlockNoTask(cpldSSId, CPLD_SPI_RD_CMD(CPLD_SW_REG,0), &initialSwitchSetting); } else initialSwitchSetting = 0x0; //mode 0, not Meter mode }