Beispiel #1
0
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
	
}	
Beispiel #2
0
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
	
}	
Beispiel #3
0
extern uint8 targetGetSw (void)
{
	if (!cpldSupported) return initialSwitchSetting;
	
	if (isChipDiceJR())
	{
		return pTargetCpld[CPLD_SW_REG] & 0x0f;
	}
	else
	{
		return (uint8)targetReadCPLDSPIWord (CPLD_SPI_RD_CMD(CPLD_SW_REG,0)) & 0x0f;
	}
}