Ejemplo n.º 1
0
Archivo: rf.c Proyecto: 40Grit/rfTest
/*XmitPacket: send a data byte/block to the rf module*/
BYTE XmitPacket(BYTE *data, BYTE length)
{
	RF_CE = 0;

	//early return if packet length is too long
	if (length > 32)
		return 1;
	
	//Clear Interrupts
	WriteRegister(STATUS, (STATUS_TX_DS | STATUS_RX_DR | STATUS_MAX_RT));

	//load tx fifo
	WriteTxPayload(data, length);

	//send packet
	PulseCe();

	//block until acknowledge or timeout
	while (1)
	{
		if (CheckInterrupt(STATUS_MAX_RT))
		{
			OutCommand(FLUSH_TX);
			return 2;
		}
		if (CheckInterrupt(STATUS_TX_DS))
			return 0;
	}

	/*FIXME:implement state?*/
	//set state
}
Ejemplo n.º 2
0
    bool Object::VerifyMemberFields(TADDR pMT, TADDR obj, WORD &numInstanceFields)
    {
        DacpMethodTableData vMethTable;
        if (FAILED(vMethTable.Request(g_sos, pMT)))
            return false;

        // Recursively verify the parent (this updates numInstanceFields)
        if (vMethTable.ParentMethodTable)
        {
            if (!VerifyMemberFields(TO_TADDR(vMethTable.ParentMethodTable), obj, numInstanceFields))
                return false;
        }

        DacpMethodTableFieldData vMethodTableFields;

        // Verify all fields on the object.
        CLRDATA_ADDRESS dwAddr = vMethodTableFields.FirstField;
        DacpFieldDescData vFieldDesc;
        
        while (numInstanceFields < vMethodTableFields.wNumInstanceFields)
        {
            CheckInterrupt();
            
            if (FAILED(vFieldDesc.Request(g_sos, dwAddr)))
                return false;

            if (vFieldDesc.Type >= ELEMENT_TYPE_MAX)
                return false;

            dwAddr = vFieldDesc.NextField;
                
            if (!vFieldDesc.bIsStatic)
            {
                numInstanceFields++;            
                TADDR dwTmp = TO_TADDR(obj + vFieldDesc.dwOffset + sizeof(BaseObject));
                if (vFieldDesc.Type == ELEMENT_TYPE_CLASS)
                {
                    // Is it a valid object?  
                    if (FAILED(MOVE(dwTmp, dwTmp)))
                        return false;

                    if (dwTmp != NULL)
                    {
                        DacpObjectData objData;
                        if (FAILED(objData.Request(g_sos, TO_CDADDR(dwTmp))))
                            return false;
                    }
                }
            }        
        }
        
        return true;
    }
Ejemplo n.º 3
0
Archivo: rf.c Proyecto: 40Grit/rfTest
/*RecvPacket: check/receive a packet from the rf module*/
BYTE RecvPacket(BYTE *payload, BYTE length)
{
	/* make sure data is present */
	if (!CheckInterrupt(STATUS_RX_DR))
		return (1);
	
	RF_CE = 0;//Disable radio
	/* read RX payload, which is blah bytes long*/
	ReadRxPayload(payload, length);

	/* Flush RX FIFO */
	OutCommand(FLUSH_RX);

	/* reset interrupt */
	WriteRegister(STATUS, STATUS_RX_DR);
	RF_CE = 1;//Re-enable radio
	return (0);
}
Ejemplo n.º 4
0
STATESTATUS CMagicState::Update(uint32 tick)
{
	if(CState::Update(tick) == STATESTATUS_ERROR || !CheckValidTarget(m_PTarget))
	{
		return STATESTATUS_ERROR;
	}

	if(m_startTime == 0) m_startTime = tick;

	if(tick - m_startTime >= m_castTime)
	{
		if(CheckInterrupt())
		{
			return STATESTATUS_INTERRUPT;
		}
		else
		{
			return STATESTATUS_FINISH;
		}
	}

	return STATESTATUS_TICK;
}
Ejemplo n.º 5
0
// Execute until the end of a frame, or a breakpoint, whichever comes first
void ExecuteChunk ()
{
    // Is the reset button is held in?
    if (g_fReset)
    {
        // Advance to the end of the frame
        g_dwCycleCounter = TSTATES_PER_FRAME;
    }

// Execute the first CPU core if only 1 CPU core is compiled in
#if defined(USE_ONECPUCORE)
    if (1)
#else
    if (Debug::IsBreakpointSet())
#endif
    {
        // Loop until we've reached the end of the frame
        for (g_fBreak = false ; !g_fBreak ; )
        {
            // Keep track of the current and previous state of whether we're processing an indexed instruction
            pHlIxIy = pNewHlIxIy;
            pNewHlIxIy = &HL;

            // Fetch... (and advance PC)
            bOpcode = timed_read_code_byte(PC++);
            R++;

            // ... Decode ...
            switch (bOpcode)
            {
#include "Z80ops.h"     // ... Execute!
            }

            // Update the line/global counters and check/process for pending events
            CheckCpuEvents();

            // Are there any active interrupts?
            if (status_reg != STATUS_INT_NONE && IFF1)
                CheckInterrupt();

            // If we're not in an IX/IY instruction, check for breakpoints
            if (pNewHlIxIy == &HL && Debug::BreakpointHit())
                break;

#ifdef _DEBUG
            if (g_fDebug) g_fDebug = !Debug::Start();
#endif
        }
    }
#if !defined(USE_ONECPUCORE)
    else
    {
        // Loop until we've reached the end of the frame
        for (g_fBreak = false ; !g_fBreak ; )
        {
            // Keep track of the current and previous state of whether we're processing an indexed instruction
            pHlIxIy = pNewHlIxIy;
            pNewHlIxIy = &HL;

            // Fetch... (and advance PC)
            bOpcode = timed_read_code_byte(PC++);
            R++;

            // ... Decode ...
            switch (bOpcode)
            {
#include "Z80ops.h"     // ... Execute!
            }

            // Update the line/global counters and check/process for pending events
            CheckCpuEvents();

            // Are there any active interrupts?
            if (status_reg != STATUS_INT_NONE && IFF1)
                CheckInterrupt();

#ifdef _DEBUG
            if (g_fDebug) g_fDebug = !Debug::Start();
#endif
        }
    }
#endif  // !defined(USE_ONECPUCORE)
}