/********************************************************* Create semaphores for this module */ HRESULT briCreateSemaphores(void) { HRESULT hResult = NO_ERROR; // bus reset indication check semaphore hResult = TCSemaphoreOpen(&briIndicationSemID, 0); if (hResult != NO_ERROR) return hResult; // exclusive exclusive access for briIndicationWaitingTasks (mutex) hResult = TCMutexOpen(&briIndicationMutexSemID); if (hResult != NO_ERROR) return hResult; // bus reset completion check semaphore hResult = TCSemaphoreOpen(&briCompletionSemID, 0); if (hResult != NO_ERROR) return hResult; // exclusive exclusive access for briCompletionWaitingTasks (mutex) hResult = TCMutexOpen(&briCompletionMutexSemID); if (hResult != NO_ERROR) return hResult; #ifdef _BRI_PRE_COMPLETION // bus reset pre completion check semaphore hResult = TCSemaphoreOpen(&briPreCompletionSemID, 0); if (hResult != NO_ERROR) return hResult; // exclusive exclusive access for briPreCompletionWaitingTasks (mutex) hResult = TCMutexOpen(&briPreCompletionMutexSemID); if (hResult != NO_ERROR) return hResult; #endif //_BRI_PRE_COMPLETION return hResult; }
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 }
/********************************************************* Create semaphores for this module */ HRESULT lhlStatusQueueCreateSemaphores(void) { HRESULT hResult = NO_ERROR; uint32 index; for (index = 0; index < STATUS_INFO_ITEMS; index++) { // status info synchronization semaphore // handling multiple... requests/responses read, write, lock, error hResult = TCSemaphoreOpen(&statusInfoQueue.statusInfo[index].semID, 0); if (hResult != NO_ERROR) return hResult; } // exclusive access for the statusInfoQueue (mutex) hResult = TCMutexOpen(&lhlStatusQueueMutexSemID); if (hResult != NO_ERROR) return hResult; return hResult; }
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); }