Esempio n. 1
0
// Main function defining gate rf manipulation workflow
uint8_t gate_radio_strobe(gate_state_t target_state)
{
    if (gate_get_state() == target_state) {
        return 0;
    }

    int ret = 1;
    prepare();

    for (int i = 0; i < NUM_BROADCAST_TRIES; ++i)
    {
        broadcast_code();
        wait_for_broadcast_end();
        sleep_until_gate_reacts();
        if (gate_get_state() == target_state)
        {
            ret = 0;
            break;
        }
    }

    finish();
    return ret;
}
Esempio n. 2
0
void *MemoryTask() {
	p_gate 	pCE1	= NULL;
	p_gate 	pCE2	= NULL;
	p_gate 	pRD	    = NULL;
	p_gate 	pWR	    = NULL;
	p_slist pSCE1	= NULL;
	p_slist pSCE2	= NULL;
	p_slist pSRD	= NULL;
	p_slist pSWR	= NULL;

	dt_16bit 	ma	= 0;
	dt_8bit		dt	= 0;
	
	pCE1  = devMemory->mem_gate[ MEM__CE1 ];
	pCE2  = devMemory->mem_gate[ MEM__CE2 ];
	pRD  = devMemory->mem_gate[ MEM__RD ];
	pWR   = devMemory->mem_gate[ MEM__WR ];

	if ( pCE1->Wire != NULL )
		pSCE1 = pCE1->Wire->stato->att;
	if ( pCE2->Wire != NULL )
		pSCE2 = pCE2->Wire->stato->att;
	if ( pRD->Wire != NULL )
		pSRD = pRD->Wire->stato->att;
	if ( pWR->Wire != NULL )
		pSWR = pWR->Wire->stato->att;

	//	Lettura
	if ( pSCE1 != NULL && pSRD != NULL ) {

		if ( (TSTBIT( pSCE1->flag , STATO_FLAG_FALL ) || TSTBIT( pSCE1->flag , STATO_FLAG_LOW )) && TSTBIT( pSRD->flag , STATO_FLAG_FALL ) ) {

			ma = _mem_read_address();
			dt = devMemory->memory[ ma ];

			gate_set_state( devMemory->mem_gate[ MEM_Data_00 ], GATEMODE_OUTPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_01 ], GATEMODE_OUTPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_02 ], GATEMODE_OUTPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_03 ], GATEMODE_OUTPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_04 ], GATEMODE_OUTPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_05 ], GATEMODE_OUTPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_06 ], GATEMODE_OUTPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_07 ], GATEMODE_OUTPUT );

			_mem_send_data( dt );
			
		}
	
		if ( ( gate_get_state( devMemory->mem_gate[ MEM_Data_00 ] ) == GATEMODE_OUTPUT ) && ( TSTBIT( pSCE1->flag , STATO_FLAG_HIGH ) || TSTBIT( pSCE2->flag , STATO_FLAG_HIGH ) ) ) {

			gate_set_state( devMemory->mem_gate[ MEM_Data_00 ], GATEMODE_INPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_01 ], GATEMODE_INPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_02 ], GATEMODE_INPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_03 ], GATEMODE_INPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_04 ], GATEMODE_INPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_05 ], GATEMODE_INPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_06 ], GATEMODE_INPUT );
			gate_set_state( devMemory->mem_gate[ MEM_Data_07 ], GATEMODE_INPUT );

		}
	
	}

	//	Scrittura
	if ( pSCE1 != NULL && pSWR != NULL ) {

		if ( (TSTBIT( pSCE1->flag , STATO_FLAG_FALL ) || TSTBIT( pSCE1->flag , STATO_FLAG_LOW )) && TSTBIT( pSWR->flag , STATO_FLAG_FALL ) ) {

			ma = _mem_read_address();
			dt = _mem_read_data();

			devMemory->memory[ ma ] = dt;
			
		}
	
	}

	return NULL;
}