Exemple #1
0
static HRESULT i2cOp(uint16 target, uint8 type, uint8 *buf, uint8 length)
{
	TCSemaphoreWait(i2cBufSemId);
	if(tempTran.status != 0)  {//busy
		TCSemaphoreSignal(i2cBufSemId);
		return E_I2C_TRY_AGAIN; //some error
	}
	addI2cTrans(&tempTran, type, target, buf, length);
	TCSemaphoreSignal(i2cBufSemId);
	
	startI2cTran();
	if(TCTaskStarted())
		TCSemaphoreWait(i2cCompleteSemId);
	else
		TCTaskWait(10);
	//SYS_TRACE3(SYSDEBUG_TRACE_I2C, target, type, length);
	
	if(i2cErrorOccur()) {
		SYS_DEBUG(SYSDEBUG_TRACE_I2C, "error = %d \n", i2cErrorCounter());
		return E_FAIL;
	}
	else {
		return NO_ERROR;
	}
}
Exemple #2
0
HRESULT briWaitTimeSinceResetPreCompletion(uint32 msec)
{
	HRESULT		hResult = NO_ERROR;
	uint32		elapsedTime = 0;
	uint32		waitTime = 0;

	DO_FOREVER
	{
		// wait until msec has elapsed since the bus reset completion, or since another reset completion occurs
		hResult = briElapsedTimeSinceResetPreCompletion(&elapsedTime);
		if (hResult != NO_ERROR)
		{
			if (hResult == E_BRI_NEW_BUS_RESET)
			{
				BOOL	bResetDetected;
				briWaitOnResetPreCompletion (&bResetDetected);
				continue; // in a bus reset process
			}
			break;
		}

		if (elapsedTime < msec)
		{
			waitTime = msec - elapsedTime;
			TCTaskWait(waitTime);
			continue; // check if another reset completion has occured in between
		}
		break;
	}

	return hResult;
}
Exemple #3
0
HRESULT i2cWriteBuf(uint16 target, uint8 *buf, uint8 length)
{
	HRESULT hResult;
	while((hResult = i2cOp(target, 1, buf, length)) == E_I2C_TRY_AGAIN)
		TCTaskWait(1);
	return hResult;
}
Exemple #4
0
// This thread drives the GUI statemachine
static void myAppThread(void *dummy)
{	
	updateUI ();
	DO_FOREVER
	{	
		TCTaskWait(30);	
		uiFSMdo();	
	}
}
Exemple #5
0
// This function is called by the system when it needs to perform a
// soft reset. If you need to reset any specific hardware do it here
void targetBoardPrepareReset(void)
{
	//this function will assure that the board is ready for reset
  targetSetMinConfigROM();
  lhlSetIRMEnabled(FALSE);
  lhlBriForceBusReset();

  TCTaskWait(1200);  //enough for computer to determine the device has gone with new LLC fix.
}			
Exemple #6
0
HRESULT StartBoot(void)
{
	// S/W Reset Power manager
	targetBoardPrepareReset();
	*((volatile uint32 *) PWRMGRBASE) = 0xF;
	
	TCTaskWait(500); // Reset 0.5 sec.

	return E_FAIL;
}
Exemple #7
0
void avsIntPollHandlers(void)
{
#if 1 //LM???
	if (TCInterruptPollAVS0())
	{
		avsIntEventHandler0();
	}
	if (TCInterruptPollAVS1())
	{
		avsIntEventHandler1();
	}
	if (TCInterruptPollAVS2())
	{
		avsIntEventHandler2();
	}
	TCTaskWait(10);
#else
	TCTaskWait(10000);
#endif
}
Exemple #8
0
void avrDrdHandlerThread(void *dummy)
{
//	HRESULT				hResult = NO_ERROR;	

	UNUSED_ARG(dummy);

	DO_FOREVER
	{
		TCTaskWait(10000);
	}
}
Exemple #9
0
// This thread handles the MIDI indicate LED's
// It also makes sure that the codec gets initialized.
static void myMidiIndicateThread(void *dummy)
{	
	//make sure update codec get's called if we already have lock
	DAL_STATUS		dalStatus;
	dalGetCurrentStatus  (eDAL_INTERFACE_1, &dalStatus);
	updateCodec(&dalStatus);

	DO_FOREVER
	{	
		TCTaskWait(200); //every 200ms
		uint8 act = uart1_activity ();
		amDisplayLed (AM_LED_MIDI_IN,act&UART_RX_ACTIVITY);
		amDisplayLed (AM_LED_MIDI_OUT,act&UART_TX_ACTIVITY);
	}
}
Exemple #10
0
// updateCodec is called whenever DAL tells us that things have changed.
// The function checks if any important stuff changed such as the rateMode
// or the locked state.
// We also handle some appliction specific LED stuff here.
static void updateCodec(DAL_STATUS * pStatus)
{	
	uint16 w;
	
	if (((pStatus->state == eDAL_STATE_LOCKED) && !isLocked) || ((pStatus->state == eDAL_STATE_LOCKED) && (pStatus->lockedRateMode != lastLockedMode)))
	{
		//So either we became locked, or we slid into a new rate mode, in all cases
		//the codec/ADC/DAC should be told.
		
		if (firstInit)
		{
			//we got clocks, bring the device out of RESET
			amCtrlSetBit(LED_CODEC_NRST);
			TCTaskWait(10); //needs a little time??
			firstInit=FALSE;	
		}
		//Call the codec function for the selected mode
		targetWriteCodecSPIWord (0xa100); //reset
		switch (pStatus->lockedRateMode)
		{
			default:
			case eDAL_RATE_MODE_LOW:
				w=0xa264;
				break;				
			case eDAL_RATE_MODE_MID:
				w=0xa265;
				break;				
			case eDAL_RATE_MODE_HIGH:
				w=0xa266;
				break;
		}
		targetWriteCodecSPIWord (w); 		
		targetWriteCodecSPIWord (0xa600 | DAC_GAIN);
  	targetWriteCodecSPIWord (0xa700 | DAC_GAIN);			
		targetWriteCodecSPIWord (0xa103); //un-reset	

		isLocked = true;
		lastLockedMode = pStatus->lockedRateMode;
	}
	else if ((pStatus->state != eDAL_STATE_LOCKED) && isLocked)
	{
		//we just lost lock
		//Call the codec function for the selected mode
		targetWriteCodecSPIWord (0xa100); //reset AKM codec, this will also mute
		isLocked = false;
	}
}
Exemple #11
0
void myAppThread(void *dummy)
{
    uint32 prevTime = TCTimeGet();

    DO_FOREVER
    {
        TCTaskWait(100);
        //just wake up every 100ms and do the following

        if ((TCTimeGet() - prevTime) > 1000)
        {

        }
#ifdef _AXM20
        AXM20Update();
#endif //_AXM20
    }
}
Exemple #12
0
HRESULT lmHandleListElementWait(LM_CONTEXT* list, BOOL bIndexed, uint32 index, LM_HANDLE_INDEX_ELEMENT_CB callback, void **data, uint32 *arg1, uint32 *arg2)
{
	HRESULT		hResult = NO_ERROR;
	uint32		count = 0;
	
	DO_FOREVER
	{
		hResult = lmHandleListElement(list, bIndexed, index, callback, data, arg1, arg2);
		if (hResult != E_LM_ELEMENT_LOCKED) break;
		count++;
		if (count == 50)
		{
			TCTaskWait(1);
			count = 0;
		}
	}
	
	return hResult;
}
Exemple #13
0
/*********************************************************
	gray interrupt handler thread
*/
void grayIntThread(void *dummy)
{
	UNUSED_ARG(dummy);

	DO_FOREVER
	{
		if (TCInterruptPollGray())
		{
#ifdef _GRAYINT_DEFERRED
			// put gray event to gray event handler threads messageQueue
			grayEventHandlerDeferredPolling();
#else //_GRAYINT_DEFERRED
			// call gray event handler directly
			grayEventHandlerDirectPolling();
#endif //_GRAYINT_DEFERRED
		}
		TCTaskWait(50);
	}
}
Exemple #14
0
// This function is called by the system when it needs to perform a
// soft reset. As we are using CS6 which becomes A21 during boot we would
// actually chip select the CPLD when trying to boot from the Flash and that
// would make the system crash.
// To avoid this we disable the CPLD parallel mode before resetting.
void targetBoardPrepareReset(void)
{
	//this function will assure that the board is ready for reset
	if (cpldSupported) 
	{
			//we do not want the CPLD to respond to parallel requests at this point
			spiOpBlock(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);
			//disable the CS6
			*((volatile uint32 *) MEM_SMSKR6) = 0x00000020;//SRAM, off, set 0

	}
	targetSetMinConfigROM();
	lhlSetIRMEnabled(FALSE);
  	lhlBriForceBusReset();

  	TCTaskWait(1200);  //enough for computer to determine the device has gone with new LLC fix.
}			
Exemple #15
0
HRESULT briWaitTimeSinceResetIndication(uint32 msec)
{
	HRESULT		hResult = NO_ERROR;
	uint32		elapsedTime = 0;
	uint32		waitTime = 0;

	DO_FOREVER
	{
		// wait until msec has elapsed since the bus reset indication, or since another reset indication occurs
		hResult = briElapsedTimeSinceResetIndication(&elapsedTime);
		if (hResult != NO_ERROR) break;

		if (elapsedTime < msec)
		{
			waitTime = msec - elapsedTime;
			TCTaskWait(waitTime);
			continue; // check if another reset indication has occured in between
		}
		break;
	}

	return hResult;
}
Exemple #16
0
void fis_flash_erase_cb(void)
{
	TCTaskWait(10);
}
Exemple #17
0
/*****************************************************************************

	nciReadNodeGeneralROMFormat

******************************************************************************/
HRESULT	nciReadNodeGeneralROMFormat (uint32 nodeNum, uint32 busId, BIB_DATA *pCurBib)
{
	HRESULT		hResult = NO_ERROR;
	int32		quadNum = 0;	// current bus info quadlet index
	OFFSET_1394	destOffset;
	uint32		i;
	uint32		maxRetry = 3;	//LM???
	QUADLET		busInfoBlock[BIB_QUAD_ITEMS];
	destOffset.High = 0xffff;

	for (quadNum = 0; (quadNum < BIB_QUAD_ITEMS) && (hResult == NO_ERROR); quadNum++)
	{
#ifdef _SYSDEBUG
		if (sysDebugIsEnabled(SYSDEBUG_TRACE_BUSRESET))
		{
			sysDebugPrintf("read quad %d for node %d\n\r", quadNum+1, nodeNum);
		}
#endif //_SYSDEBUG

		destOffset.Low = BUS_INFO_BLOCK_ADDR + (quadNum * 4);

		for (i = 0; i < maxRetry; i++)
		{
			hResult = lhlReadNodeTimeout((uint32) (nodeNum | busId), destOffset, 4, &busInfoBlock[quadNum], LHL_QUEUE_PRIORITY, LHL_TX_REQ_SHORT_TIMEOUT_MSECS);
			if (hResult == NO_ERROR)
			{
				break;
			}
#if 1 //LM???
			if (lhlBriNewBusResetDetected(FALSE))
			{
				return E_BRI_NEW_BUS_RESET;
			}
#endif

#ifdef _SYSDEBUG
			if (sysDebugIsEnabled(SYSDEBUG_TRACE_BUSRESET))
			{
				sysDebugPrintf("failed read quad %d for node %d\n\r", quadNum+1, nodeNum);
			}
#endif //_SYSDEBUG

#if 1 //LM???
			TCTaskWait(10);
#endif
		}
	}	

	if (hResult == NO_ERROR)
	{
		for (quadNum = 0; quadNum < BIB_QUAD_ITEMS; quadNum++)
		{
			pCurBib->busInfoBlock[quadNum] = busInfoBlock[quadNum];
		}
#ifdef _SIMULATE
		pCurBib->busInfoBlock[BIB_WWUIDLO_QUAD] += nodeNum;
#endif //_SIMULATE
	}

	return hResult;
}
Exemple #18
0
HRESULT	nciUpdateBusInfoBlocks (uint32 numNodes, BIB_DATA *bibs, BOOL bClear)
{
	HRESULT		hResult = NO_ERROR;
	uint32		nodeNum = 0;	// current node, index into bifs
	UQUAD		romHeader;		// 1st quadlet in rom
	BIB_DATA	*pCurBib;		// I.E. bib[nodeNum]
	uint16		busId = 0;
	OFFSET_1394	destOffset;
	uint32		i;
// bk:	uint32		maxRetry = 5;	//LM???		3,..,5?
//  retries are blocking fcp outgoing traffic, reducing them to 1 is a temporary fix.
//	AV/C should be reworked to use nodeID-based API's then defer bib reads to the
//  application level. A bib should only be read whenever a handle is required for
//	a specific node
	uint32		maxRetry = 1;
	BOOL		bRetry = FALSE;

#ifdef _SYSDEBUG
	if (sysDebugIsEnabled(SYSDEBUG_TRACE_BUSRESET))
	{
		sysDebugPrintf("Getting bibs for %d nodes\n\r", numNodes);
	}
#endif //_SYSDEBUG

	hResult = briGetBusID(&busId);
	if (hResult != NO_ERROR) return hResult;

	if (bClear) for (nodeNum = 0; nodeNum < numNodes; ++nodeNum)
	{
		// all devices may be accessed by (bus_id | node_id). Insert this
		// here in case the node does not implement general ROM format or
		// does not respond to bus info block reads.
		pCurBib = &bibs[nodeNum]; 
		memset(pCurBib, 0, sizeof(BIB_DATA));
		pCurBib->bibDataRetry = TRUE; //LM??? retry reading bibData
		pCurBib->busInfoBlock[BIB_WWUIDLO_QUAD] = (busId | nodeNum);
	}

	destOffset.High = 0xffff;

	for (i = 0; i < maxRetry; i++)
	{
		bRetry = FALSE;
		for (nodeNum = 0; nodeNum < numNodes; ++nodeNum)
		{
			pCurBib = &bibs[nodeNum]; 

			if (pCurBib->bibDataRetry == TRUE)
			{
				// bail if this bus reset was interrupted
				if (briNewBusReset() == TRUE)
				{
					hResult = E_BRI_NEW_BUS_RESET;
					sysLogError(hResult, __LINE__, moduleName); //LM???
					return hResult; // new bus reset detected elsewhere
				}

#if 1
				if (nciIsNodeLinkActive (nodeNum) == TRUE)
#endif
				{
					// read the first quadlet in config rom for the length byte.
					// If length = 1, the ROM format is minimal and there is no bus info block.
					// If length > 1 (general ROM format), read the 4 quadlets of the bus info block. (see 1394-1995, Section 8.2.3.5)
#ifdef _SYSDEBUG
					if (sysDebugIsEnabled(SYSDEBUG_TRACE_BUSRESET))
					{
						sysDebugPrintf("read ROM base for node %d\n\r", nodeNum);
					}
#endif //_SYSDEBUG

					destOffset.Low = CONFIG_ROM_BASE_ADDR;
					hResult = lhlReadNodeTimeout(nodeNum | busId, destOffset, 4, (QUADLET*)&romHeader, LHL_QUEUE_PRIORITY, LHL_TX_REQ_SHORT_TIMEOUT_MSECS);

					if (hResult != NO_ERROR)
					{
#ifdef _SYSDEBUG
						if (sysDebugIsEnabled(SYSDEBUG_TRACE_BUSRESET))
						{
							sysDebugPrintf("failed read ROM base for node %d\n\r", nodeNum);
						}
#endif //_SYSDEBUG
						// retry but be aware that non-compliant devices will have errors 
						// - this is normal - just skip those devices
						bRetry = TRUE;
					}
					else if (romHeader.b.msb == 0)				// examine length
					{
						hResult = E_NCI_ZERO_INFO_LENGTH;		// 0 is not a valid value	
						sysLogError(hResult, __LINE__, moduleName);
						pCurBib->bibDataRetry = FALSE;
					}
					else if (romHeader.b.msb == 1)
					{
						// minimal format
						pCurBib->bibDataRetry = FALSE;
					}
					else // length > 1, general rom format
					{
						hResult = nciReadNodeGeneralROMFormat (nodeNum, busId, pCurBib);
						if (hResult == NO_ERROR)
						{
							pCurBib->bibDataRetry = FALSE;
							bRetry = TRUE;
						}
					}
				}
#if 1
				else
				{
					pCurBib->bibDataRetry = FALSE;
				}
#endif
			}
		}

		if (bRetry == FALSE)
		{
			break;
		}

		TCTaskWait((i*2+1)*(i*2+1)*10);
	}

#ifdef _SYSDEBUG
	if (sysDebugIsEnabled(SYSDEBUG_TRACE_BUSRESET))
	{
		sysDebugPrintf("nodeinfos done\n\r");
	}
#endif //_SYSDEBUG

	return hResult;
}
Exemple #19
0
void fis_flash_program_cb(void)
{
	TCTaskWait(10);
}