初级会员
- 积分
- 62
- 金钱
- 62
- 注册时间
- 2015-7-2
- 在线时间
- 2 小时
|
楼主 |
发表于 2016-4-25 18:51:51
|
显示全部楼层
发送部分我感觉应该没啥事
我就把接收的函数部分的代码传上来
[mw_shl_code=c,true]u8 NRF_Rx_Dat(u8 *rxbuf)
{
u8 state;
int i;
//à-¸ßòy½Åê1Äü·¢ËíÄ£ê½
CE_High();
state=SPI_NRF_ReadReg(STATUS);
SPI_NRF_WriteReg(NRF_WRITE_REG+STATUS,state);
if(state&RX_OK)
{
GPIO_SetBits(GPIOD,GPIO_Pin_0);
SPI_NRF_ReadBuf(RD_RX_PLOAD,rxbuf,RX_PLOAD_WIDTH);
SPI_NRF_WriteReg(FLUSH_RX,0xFF);
GPIO_ResetBits(GPIOD,GPIO_Pin_0);
return SUCCESS;
}
else
{
GPIO_SetBits(GPIOD,GPIO_Pin_0);
GPIO_ResetBits(GPIOD,GPIO_Pin_0);
return ERROR;
}[/mw_shl_code]
以及接收的部分配置(发送部分的参数和他一样 稍微变化)
[mw_shl_code=c,true]void NRF_RX_Mode(void)
{
int i;
CE_Low();
SPI_NRF_WriteBuf(NRF_WRITE_REG+TX_ADDR,(u8*)TX_ADDRESS,TX_ADR_WIDTH);
SPI_NRF_WriteBuf(NRF_WRITE_REG+RX_ADDR_P0,(u8*)RX_ADDRESS,RX_ADR_WIDTH);
SPI_NRF_WriteReg(NRF_WRITE_REG+EN_AA,0x01);
SPI_NRF_WriteReg(NRF_WRITE_REG+EN_RXADDR,0x01);
SPI_NRF_WriteReg(NRF_WRITE_REG+RF_CH,40);
SPI_NRF_WriteReg(NRF_WRITE_REG+RX_PW_P0,RX_PLOAD_WIDTH);
SPI_NRF_WriteReg(NRF_WRITE_REG+RF_SETUP,0x24);
SPI_NRF_WriteReg(NRF_WRITE_REG+CONFIG, 0x0f);
CE_High();
}[/mw_shl_code] |
|