|
/**
* Application entry point.
*/
void simple_rx_example(void)
{
/* Loop forever receiving frames. */
while (1)
{
int i;
/* TESTING BREAKPOINT LOCATION #1 */
LED0_TOGGLE();
/* Clear local RX buffer to avoid having leftovers from previous receptions This is not necessary but is included here to aid reading
* the RX buffer.
* This is a good place to put a breakpoint. Here (after first time through the loop) the local status register will be set for last event
* and if a good receive has happened the data buffer will have the data in it, and frame_len will be set to the length of the RX frame. */
for (i = 0 ; i < FRAME_LEN_MAX; i++ )
{
rx_buffer = 0;
}
/* Activate reception immediately. See NOTE 3 below. */
dwt_rxenable(DWT_START_RX_IMMEDIATE);
/* Poll until a frame is properly received or an error/timeout occurs. See NOTE 4 below.
* STATUS register is 5 bytes long but, as the event we are looking at is in the first byte of the register, we can use this simplest API
* function to access it. */
while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))
{
printf("status_reg:%x",status_reg);
delay_ms(200);
};
if (status_reg & SYS_STATUS_RXFCG)
{
/* A frame has been received, copy it to our local buffer. */
frame_len = dwt_read32bitreg(RX_FINFO_ID) & RX_FINFO_RXFL_MASK_1023;
if (frame_len <= FRAME_LEN_MAX)
{
dwt_readrxdata(rx_buffer, frame_len, 0);
printf("Recv frame,frame_len is %d,frame data:\r\n",frame_len);
for(i=0; i<frame_len; i++){
printf("%02x",rx_buffer);
}
printf("\r\n");
}
/* Clear good RX frame event in the DW1000 status register. */
dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_RXFCG);
}
else
{
/* Clear RX error events in the DW1000 status register. */
dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR);
}
}
}
并且打印状态 一直返回 0x0x00800002,求大神解疑
|
|