Exemplo n.º 1
0
uint8 gRadio_CheckReceived(void)
{  
    /* Read ITs, clear pending ones */
    si446x_get_int_status(0u, 0u, 0u);

    si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_READY);
    
    /* check the reason for the IT */
    if (Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_PACKET_RX_PEND_BIT)
    {  
      RfRxDataX[0]=0;
      si446x_fifo_info(0u);        
      si446x_read_rx_fifo(1, &RfRxDataX[0]);    
      
      //si446x_read_rx_fifo(RxBuffer[0], &RxBuffer[1]);        
      
      //RxBuff2FrameBuff(RxBuffer,&FrameBuffToUart);      
      
      RfRxFlag=RfRxData;      
      
      /* Reset FIFO */
      si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_RX_BIT); 
      si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_RX);
      return TRUE;  
    }
    /* Reset FIFO */
    si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_RX_BIT); 
    si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_RX);
    return FALSE;
}
Exemplo n.º 2
0
/*!
 *  Check if Packet received IT flag is pending.
 *
 *  @return   TRUE - Packet successfully received / FALSE - No packet pending.
 *
 *  @note
 *
 */
uint8 gRadio_CheckReceived_VariablePacket(void)
{
  uint8 nirq_recv_var= SI4463_NIRQ_Bit();
  
  if (nirq_recv_var == FALSE)
  {
    /* Read ITs, clear pending ones */
    si446x_get_int_status(0u, 0u, 0u);

	if (Si446xCmd.GET_INT_STATUS.CHIP_PEND & SI446X_CMD_GET_CHIP_STATUS_REP_CMD_ERROR_PEND_BIT)
    {
      /* State change to */
      si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_SLEEP);
	
	  /* Reset FIFO */
      si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_RX_BIT);
      
	  /* State change to */
      si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_RX);
    }

    /* check the reason for the IT */
    if (Si446xCmd.GET_INT_STATUS.MODEM_PEND & SI446X_CMD_GET_INT_STATUS_REP_SYNC_DETECT_BIT)
    {
      /* Blink once LED2 to show Sync Word detected */
      //vHmi_ChangeLedState(eHmi_Led2_c, eHmi_LedBlinkOnce_c);
    }

    if (Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_PACKET_RX_PEND_BIT)
    {
      /* Blink once LED3 as CRC OK or not enabled */
     // vHmi_ChangeLedState(eHmi_Led3_c, eHmi_LedBlinkOnce_c);

      /* Read the length of RX_FIFO */
      si446x_fifo_info(0u);

      /* Packet RX */
      si446x_read_rx_fifo(Si446xCmd.FIFO_INFO.RX_FIFO_COUNT, &fixRadioPacket[0]);

      /* Do not use UART in case of direct firmware load */
#ifdef UART_LOGGING_SUPPORT
      {
          /* Send it to UART */
        UartSendByte(fixRadioPacket,RadioConfiguration.Radio_PacketLength);
      }
#endif

      return TRUE;
    }

    if (Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_CRC_ERROR_BIT)
    {
      /* Reset FIFO */
      si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_RX_BIT);
    }
  }

  return FALSE;
}
Exemplo n.º 3
0
Arquivo: radio.c Projeto: x893/WDS
/*!
 *  Check if Packet received IT flag is pending.
 *
 *  @return   TRUE - Packet successfully received / FALSE - No packet pending.
 *
 *  @note
 *
 */
BIT gRadio_CheckReceived(void)
{
  U8 lCnt;

  if (RF_NIRQ == FALSE)
  {
    /* Read ITs, clear pending ones */
    si446x_get_int_status(0u, 0u, 0u);

    /* check the reason for the IT */
    if (Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_PACKET_RX_PEND_BIT)
    {
      /* Packet RX */
      si446x_read_rx_fifo(RadioConfiguration.Radio_PacketLength, (U8 *) &fixRadioPacket[0u]);

      /* Send it to UART */
      for (lCnt = 0u; lCnt < RadioConfiguration.Radio_PacketLength; lCnt++)
      {
        Comm_IF_SendUART(*((U8 *) &fixRadioPacket[0u] + lCnt));
      }
      Comm_IF_SendUART('\n');

      return TRUE;
    }

    /* Reset FIFO */
    si446x_fifo_info(0x02);
  }

  return FALSE;
}
Exemplo n.º 4
0
/*!
 *  Check if Packet sent IT flag or Packet Received IT is pending.
 *
 *  @return   SI4455_CMD_GET_INT_STATUS_REP_PACKET_SENT_PEND_BIT / SI4455_CMD_GET_INT_STATUS_REP_PACKET_RX_PEND_BIT
 *
 *  @note
 *
 */
U8 bRadio_Check_Tx_RX(void)
{
  if (RF_NIRQ == FALSE)
  {
      /* Read ITs, clear pending ones */
      si446x_get_int_status(0u, 0u, 0u);

	  if (Si446xCmd.GET_INT_STATUS.CHIP_PEND & SI446X_CMD_GET_CHIP_STATUS_REP_CHIP_PEND_CMD_ERROR_PEND_BIT)
      {
      	/* State change to */
      	si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEXT_STATE1_NEW_STATE_ENUM_SLEEP);
	
	  	/* Reset FIFO */
      	si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_FIFO_RX_BIT);
      
	  	/* State change to */
        si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEXT_STATE1_NEW_STATE_ENUM_RX);
      }

      if(Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_PH_PEND_PACKET_SENT_PEND_BIT)
      {
        return SI446X_CMD_GET_INT_STATUS_REP_PH_PEND_PACKET_SENT_PEND_BIT;
      }

      if(Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_PH_PEND_PACKET_RX_PEND_BIT)
      {
        /* Packet RX */

        /* Get payload length */
        si446x_fifo_info(0x00);

        si446x_read_rx_fifo(Si446xCmd.FIFO_INFO.RX_FIFO_COUNT, &customRadioPacket[0]);

        return SI446X_CMD_GET_INT_STATUS_REP_PH_PEND_PACKET_RX_PEND_BIT;
      }
      
	  if (Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_PH_STATUS_CRC_ERROR_BIT)
      {
      	/* Reset FIFO */
      	si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_FIFO_RX_BIT);
      }


  }

  return 0;
}
Exemplo n.º 5
0
void vRadio_StartTx_Variable_Packet(U8 channel, U8 *pioRadioPacket, U8 length)
{
  /* Leave RX state */
  si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_READY);
  
  /*Switch to TX match network*/
  RF_Switch_TX();
  
  
  /* Read ITs, clear pending ones */
  si446x_get_int_status(0u, 0u, 0u);

  /* Reset the Tx Fifo */
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_TX_BIT);

  si446x_fifo_info(0u);
  /* Fill the TX fifo with datas */
  si446x_write_tx_fifo(length, pioRadioPacket);
  si446x_fifo_info(0u);
  /* Start sending packet, channel 0, START immediately */
   si446x_start_tx(channel, 0x30, length);   
}
Exemplo n.º 6
0
uint8 New_SI4463_Transmit(U8 * pSrc,U8 len)
{
   
  
  SI4463_Enable_NIRQ_TX();
  
 
  
  
  /* Check if the radio is already in TX state */
  si446x_request_device_state();
  if (SI446X_CMD_REQUEST_DEVICE_STATE_REP_MAIN_STATE_ENUM_TX == \
      (Si446xCmd.REQUEST_DEVICE_STATE.CURR_STATE & 0x0F)) {
    /* Still transmitting */
    return FALSE;
  }

  /* Reset TX FIFO */
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_TX_BIT);

  /* Fill the TX FIFO with data */
  si446x_write_tx_fifo(len, pSrc);


  /* Start sending packet, channel 0, START immediately,
   * Packet length according to 'len', go READY when done */
  si446x_start_tx(0u, 0x30,  len);
  
 uint32 counter = 0;
 StatTime = tmpGlobalTime;
 while(TRUE != gRadio_CheckTransmitted())
 {
   
  asm("nop");
  counter++;
  if(counter >= 0xFFFFFFFF)
  {
     
    SI4463_Enable_NIRQ_RX();
    EXTILineNIRQ_Config();
    return FALSE;
  }
    
 }  
  StopTime = tmpGlobalTime-StatTime;
 

 SI4463_Enable_NIRQ_RX();
  EXTILineNIRQ_Config();
  return TRUE;
}
Exemplo n.º 7
0
/*!
 *  Set Radio to RX mode. .
 *
 *  @param channel Freq. Channel,  packetLength : 0 Packet handler fields are used , nonzero: only Field1 is used
 *
 *  @note
 *
 */
void vRadio_StartRX(U8 channel, U8 packetLenght )
{
  // Read ITs, clear pending ones
  si446x_get_int_status(0u, 0u, 0u);

   // Reset the Rx Fifo
   si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_FIFO_RX_BIT);

  /* Start Receiving packet, channel 0, START immediately, Packet length used or not according to packetLength */
  si446x_start_rx(channel, 0u, packetLenght,
                  SI446X_CMD_START_RX_ARG_NEXT_STATE1_RXTIMEOUT_STATE_ENUM_NOCHANGE,
                  SI446X_CMD_START_RX_ARG_NEXT_STATE2_RXVALID_STATE_ENUM_READY,
                  SI446X_CMD_START_RX_ARG_NEXT_STATE3_RXINVALID_STATE_ENUM_RX );
}
Exemplo n.º 8
0
/*!
 *  Set Radio to TX mode, fixed packet length.
 *
 *  @param channel Freq. Channel, Packet to be sent
 *
 *  @note
 *
 */
void  vRadio_StartTx(uint8_t channel, uint8_t *pioFixRadioPacket)
{
  /* Reset TX FIFO */
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_TX_BIT);

  // Read ITs, clear pending ones
  si446x_get_int_status(0u, 0u, 0u);

  /* Fill the TX fifo with datas */
  si446x_write_tx_fifo(RadioConfiguration.Radio_PacketLength, pioFixRadioPacket);

  /* Start sending packet, channel 0, START immediately, Packet length according to PH, go READY when done */
  si446x_start_tx(channel, 0x30,  0x00);
}
Exemplo n.º 9
0
/*!
 *  Set Radio to TX mode, variable packet length.
 *
 *  @param channel Freq. Channel, Packet to be sent length of of the packet sent to TXFIFO
 *
 *  @note
 *
 */
void set_txd_mode(void)
{
  volatile unsigned int  tick_tmp=1000; //延时220uS;
  PA_Txen();
  RXD_LED(0);
  si4438_phy.RF_status=RF_IDLE_FLAG;
  si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_READY);
  while(tick_tmp--);
  si446x_get_int_status(0u, 0u, 0u);
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_TX_BIT);
  /* Reset the Tx Fifo */
  si4438_phy.tx_flag=TX_ON;
  si4438_phy.RF_status=RF_TX_FLAG;
  
}
Exemplo n.º 10
0
void vRadio_StartTx_Variable_Packet(U8 channel, U8 *pioRadioPacket, U8 length)
{
//  DBUG("send channel=%d pioRadioPacket=%d length=%d\r\n",channel,pioRadioPacket,length);
  /* Read ITs, clear pending ones */
  Clear_int_status();
  /* Reset the Tx Fifo */
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_TX_BIT);

  /* Fill the TX fifo with datas */
  si446x_write_tx_fifo(length, pioRadioPacket);

  /* Start sending packet, channel 0, START immediately */
   si446x_start_tx(channel, 0x80, length);  
  
  si4438_phy.tx_flag=TX_ON;
  si4438_phy.RF_status=RF_TX_FLAG;
}
Exemplo n.º 11
0
void vRadio_Init(void)
{
  U16 wDelay;

  /* Power Up the radio chip */
  vRadio_PowerUp();

  /* Load radio configuration */
  while (SI446X_SUCCESS != si446x_configuration_init(pRadioConfiguration->Radio_ConfigurationArray))
  {

    for (wDelay = 0x7FFF; wDelay--; ) ;

    /* Power Up the radio chip */
    vRadio_PowerUp();
  }

  // Read ITs, clear pending ones
  si446x_get_int_status(0u, 0u, 0u);  
  
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_RX_BIT);
} 
Exemplo n.º 12
0
void RXHandlerInGDO0_SI4463(void)
{
   /* Read ITs, clear pending ones */
    si446x_get_int_status(0u, 0u, 0u);

    /* check the reason for the IT */
    if (Si446xCmd.GET_INT_STATUS.PH_PEND & SI446X_CMD_GET_INT_STATUS_REP_PACKET_RX_PEND_BIT)
    {
      /* Packet RX */
      si446x_read_rx_fifo(RadioConfiguration.Radio_PacketLength, (U8 *) &fixRadioPacket[0u]);

      /* Send it to UART */
//      for (lCnt = 0u; lCnt < RadioConfiguration.Radio_PacketLength; lCnt++)
//      {
//        Comm_IF_SendUART(*((U8 *) &fixRadioPacket[0u] + lCnt));
//      }
//      Comm_IF_SendUART('\n');
    }

    /* Reset FIFO */
    si446x_fifo_info(0x02);
}
Exemplo n.º 13
0
/*!
 *  Set Radio to RX mode, fixed packet length.
 *
 *  @param channel Freq. Channel
 *
 *  @note
 *
 */
void vRadio_StartRX(U8 channel)
{
//  volatile unsigned int  tick_tmp=1000; //延时220uS;
//  while(tick_tmp--);
#ifdef LOW_RATE_CHECK

  SetHighRate();
#endif
  PA_Rxen();
  si4438_phy.RF_status=RF_IDLE_FLAG;
  si446x_change_state(SI446X_CMD_CHANGE_STATE_ARG_NEW_STATE_ENUM_READY);
  si4438_phy.rx_flag=RX_ON;
  si4438_phy.RF_status=RF_RX_FLAG;
  // Read ITs, clear pending ones
  si446x_get_int_status(0u, 0u, 0u);
  /* Reset FIFO */
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_RX_BIT);
  /* Start Receiving packet, channel 0, START immediately, Packet length according to PH */
  si446x_start_rx(channel, 0u, 0x00,
            SI446X_CMD_START_RX_ARG_RXTIMEOUT_STATE_ENUM_NOCHANGE,
            SI446X_CMD_START_RX_ARG_RXVALID_STATE_ENUM_RX,
            SI446X_CMD_START_RX_ARG_RXINVALID_STATE_ENUM_RX );
}
Exemplo n.º 14
0
uint8 SI4463_Config_Transmit_singlerate(U8 * pSrc1,U8 len1)
{
  
  //发送第一个包
   trx_state = 0;//f发送模式
  
  /* Check if the radio is already in TX state */
  si446x_request_device_state();
  if (SI446X_CMD_REQUEST_DEVICE_STATE_REP_MAIN_STATE_ENUM_TX == \
      (Si446xCmd.REQUEST_DEVICE_STATE.CURR_STATE & 0x0F)) {
    /* Still transmitting */
    return FALSE;
  }

  /* Reset TX FIFO */
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_TX_BIT);

  /* Fill the TX FIFO with data */
  si446x_write_tx_fifo(len1, pSrc1);


  /* Start sending packet, channel 0, START immediately,
   * Packet length according to 'len', go READY when done */
  si446x_start_tx(0u, 0x30,  len1);
  
  uint32 counter = 0;
  while (PKT_Sent_Flag!=1)//发送等待
  {
  //等待保护
  asm("nop");
  counter++;
  if(counter >= 0xFFFFFFFF)
    {
     //第一个包未发送成功
    counter=0;
    return FALSE;
    }  
  }
  
   PKT_Sent_Flag =0;
  
  
#if 0
  //DelayMs(1);
//发送第二个包
  
  vRadio_config_2nd();
  
  trx_state = 0;//f发送模式
  
  /* Check if the radio is already in TX state */
  si446x_request_device_state();
  if (SI446X_CMD_REQUEST_DEVICE_STATE_REP_MAIN_STATE_ENUM_TX == \
      (Si446xCmd.REQUEST_DEVICE_STATE.CURR_STATE & 0x0F)) {
    /* Still transmitting */
    return FALSE;
  }

  /* Reset TX FIFO */
  si446x_fifo_info(SI446X_CMD_FIFO_INFO_ARG_TX_BIT);

  /* Fill the TX FIFO with data */
  si446x_write_tx_fifo(len2, pSrc2);


  /* Start sending packet, channel 0, START immediately,
   * Packet length according to 'len', go READY when done */
  si446x_start_tx(0u, 0x30,  len2);
  
  
  while (PKT_Sent_Flag!=1)//发送等待
  {
  //等待保护
  asm("nop");
  counter++;
  if(counter >= 0xFFFFFFFF)
  {
     //第一个包未发送成功
    counter=0;
    return FALSE;
  }
    
  }
  
  PKT_Sent_Flag =0;
  vRadio_config_1st();
  
  vRadio_StartRX_1st(pRadioConfiguration_1st->Radio_ChannelNumber);//回复第一个包的接收模式
  trx_state = 1;//第二个包发完之后默认为接收状态
   
#endif 
  
    vRadio_StartRX(pRadioConfiguration->Radio_ChannelNumber);//回复第一个包的接收模式
  trx_state = 1;//第二个包发完之后默认为接收状态
  
  return TRUE;
}