unsigned char recvBeacon( ob_data* block ) {
    unsigned long crc;
    unsigned char ret=0, status;

	ob_switchRXMode();
	if((AT91F_PIO_GetInput(AT91C_BASE_PIOA)&IRQ_PIN)==0)
	{
		portENTER_CRITICAL();
			status=nRFAPI_GetStatus();
			if(status&MASK_RX_DR_FLAG ) {

				ret=nRFAPI_RX((unsigned char*)block, sizeof(ob_data) );

				if(ret>0) {
					// CRC Check
					crc = env_crc16(block->payload, sizeof(block->payload) );
					if(block->crc == swapshort(crc)) {
						increment(ob_int_mgmt.rx_beacons, 4);
					} else {
						increment(ob_int_mgmt.fail_rx_beacons, 4);
						ret=0;
					}
				}
				nRFAPI_FlushRX();
			}

			nRFAPI_ClearIRQ(status);
		portEXIT_CRITICAL ();
	}
	return ret;
}
Exemplo n.º 2
0
uint8_t
nRFAPI_DetectChip (void)
{
  uint8_t mac[NRF_MAX_MAC_SIZE], i;

  // blank read
  nRFAPI_GetStatus ();

  // set dummy MAC size
  nRFAPI_SetSizeMac (NRF_MIN_MAC_SIZE);

  // verify dummy MAC size
  if (nRFAPI_GetSizeMac () != NRF_MIN_MAC_SIZE)
    return 0;

  // set dummy MAC size
  nRFAPI_SetSizeMac (NRF_MAX_MAC_SIZE);

  // verify dummy MAC size
  if (nRFAPI_GetSizeMac () != NRF_MAX_MAC_SIZE)
    return 0;

  // set dummy MAC
  nRFAPI_SetTxMAC (rfbroadcast_mac, NRF_MAX_MAC_SIZE);

  //  get dummy MAC
  memset (&mac, 0, sizeof (mac));
  nRFAPI_GetTxMAC (mac, NRF_MAX_MAC_SIZE);

  // if can't verify written MAC - return with error
  for (i = 0; i < NRF_MAX_MAC_SIZE; i++)
    if (mac[i] != rfbroadcast_mac[i])
      return 0;

  // everything is fine
  return 1;
}
Exemplo n.º 3
0
Arquivo: nRF_API.c Projeto: CMon/dld
unsigned char nRFAPI_GetPipeCurrent(void)
{
    return (nRFAPI_GetStatus()>>1) & 0x7;
}
Exemplo n.º 4
0
uint8_t
nRFAPI_GetPipeCurrent (void)
{
  return (nRFAPI_GetStatus () >> 1) & 0x7;
}
char isFinishTransmit() {
	return (nRFAPI_GetStatus()&STATUS_TX_DS)==STATUS_TX_DS;
}