STM8S103F3+hs6200实现无线通信,接收端能够接收得到信号,但是发送端一直收不到ack信号。且重发次数一直都为0。哪个大大给帮忙看下,非常感谢。
//发送端
void HS6200_Init(void)
{
uint8_t temp[5];
uint8_t TmpLastFrequence = GetLastFrequenceIndex();
printf("HS6200_Init\r\n");
/* calibration */
HS6200_Calibration();
/* analog init */
HS6200_Analog_Init();
/* the same to nRF24L01 */
HS6200_Bank0_Activate();
/* PRX POWER Up, 2Byte CRC. */
rf_write_reg(HS6200_BANK0_CONFIG, 0x0F);
rf_write_reg(HS6200_BANK0_EN_RXADDR, 0x01);
/* 5Bytes Address width */
rf_write_reg(HS6200_BANK0_SETUP_AW, 0x03);
/* Rf channel */
printf("It is transimit ending, ChannelFrequence:\r\n");
printf_hex(ChannelFrequence[TmpLastFrequence]);
printf("\r\n");
rf_write_reg(HS6200_BANK0_EN_AA, 0x01); //edit by jerry
hal_nrf_set_auto_retr(RF_RETRANSMITS, RF_RETRANS_DELAY);
rf_write_reg(HS6200_BANK0_RF_CH, ChannelFrequence[TmpLastFrequence]);
#if HS6200_DR_2M
temp[0] = 0x4F; /* 2MHz 5dBm */
#elif HS6200_DR_1M
temp[0] = 0x47; /* 1MHz 5dBm. */
#else
temp[0] = 0x6F; /* 500K 5DBm */
#endif
HS6200_Write_Reg(HS6200_BANK0_RF_SETUP, temp, 1);
temp[0] = 0x46;
temp[1] = 0x0B;
temp[2] = 0xAF;
temp[3] = 0x43;
temp[4] = 0x98;
HS6200_Write_Reg(HS6200_BANK0_RX_ADDR_P0, temp, 5); /* set address */
HS6200_Write_Reg(HS6200_BANK0_TX_ADDR, temp, 5); /* set address */
rf_write_reg(HS6200_BANK0_DYNPD, 0x3F); /* dynamic length */
rf_write_reg(HS6200_BANK0_FEATURE, 0x04);
HS6200_Flush_Rx_Fifo();
HS6200_Flush_Tx_Fifo();
rf_write_reg(HS6200_BANK0_STATUS, 0x70);
temp[0] = 0x52;
temp[1] = 0x95;
temp[2] = 0x29;
temp[3] = 0x01;
temp[4] = 0x03;
HS6200_Write_Reg(HS6200_BANK0_SETUP_VALUE, temp, 5);
}
//接收端
void HS6200_Init(void)
{
uint8_t temp[5];
uint8_t TmpFrequence = GetLastFrequenceIndex();
printf("HS6200_Init\r\n");
/* calibration */
HS6200_Calibration();
/* analog init */
HS6200_Analog_Init();
/* the same to nRF24L01 */
HS6200_Bank0_Activate();
/* PRX POWER Up, 2Byte CRC. */
rf_write_reg(HS6200_BANK0_CONFIG, 0x0F);
/* ENAA */
rf_write_reg(HS6200_BANK0_EN_RXADDR, 0x01);
/* 5Bytes Address width */
rf_write_reg(HS6200_BANK0_SETUP_AW, 0x03);
/* Rf channel */
printf("It is receive ending, ChannelFrequence:\r\n");
printf_hex(ChannelFrequence[TmpFrequence]);
printf("\r\n");
rf_write_reg(HS6200_BANK0_RF_CH, ChannelFrequence[TmpFrequence]);
rf_write_reg(HS6200_BANK0_EN_AA, 0x01);
rf_write_reg(HS6200_BANK0_SETUP_RETR, 0x00);
#if HS6200_DR_2M
temp[0] = 0x4F; /* 2MHz 5dBm */
#elif HS6200_DR_1M
temp[0] = 0x47; /* 1MHz 5dBm. */
#else
temp[0] = 0x6F; /* 500K 5DBm */
#endif
HS6200_Write_Reg(HS6200_BANK0_RF_SETUP, temp, 1);
temp[0] = 0x46;
temp[1] = 0x0B;
temp[2] = 0xAF;
temp[3] = 0x43;
temp[4] = 0x98;
HS6200_Write_Reg(HS6200_BANK0_RX_ADDR_P0, temp, 5); /* set address */
HS6200_Write_Reg(HS6200_BANK0_TX_ADDR, temp, 5); /* set address */
rf_write_reg(HS6200_BANK0_DYNPD, 0x3F); /* dynamic length */
rf_write_reg(HS6200_BANK0_FEATURE, 0x04);
HS6200_Flush_Rx_Fifo();
HS6200_Flush_Tx_Fifo();
rf_write_reg(HS6200_BANK0_STATUS, 0x70);
temp[0] = 0x52;
temp[1] = 0x95;
temp[2] = 0x29;
temp[3] = 0x01;
temp[4] = 0x03;
HS6200_Write_Reg(HS6200_BANK0_SETUP_VALUE, temp, 5);
}
|
|