示例#1
0
HRESULT i2cInitialize(void)
{
	HRESULT hResult = NO_ERROR;

	//enabel trace to debug the startup.
	//sysTraceStart(0);

	MPTR(IC_INTR_MASK) = 0; //disable all i2c interrupt
	MPTR(IC_RX_TL) = 0; //rx threshhold to 1, to correct error in the databook
	hResult = TCSemaphoreOpenIRQ(&i2cBufSemId, 1);
	if (hResult != NO_ERROR) 
		return hResult;

	hResult = TCSemaphoreOpenIRQ(&i2cCompleteSemId, 0);
	if (hResult != NO_ERROR) 
		return hResult;

	TCInterruptInstallHandler(CYGNUM_HAL_INTERRUPT_I2C, NULL, i2cIntDsr);

	i2cSetup(I2C_7_BIT_ADDR, I2C_STANDARD_SPEED);
#ifdef _CLI
	hResult += i2cInstallCLITools();
#endif

	return hResult;
}
示例#2
0
/*********************************************************
	Create semaphores for this module
*/
HRESULT avsIntCreateSemaphores(void)
{
	HRESULT hResult = NO_ERROR;

	// transmit request packet done
	hResult = TCSemaphoreOpenIRQ(&avsIntSemID, 0);
	if (hResult != NO_ERROR) return hResult;

	return hResult;
}