payload_array[i] += 1;
}
}
NRF905SE_SendPacket(payload_array, payloadSize);
//NRF905SE_SetTxPayload(payload_array, payloadSize);
//NRF905SE_SendData();
/*
for(u32 i=0; i<1000; i++) {
for(u32 j = 0; j<1000; j++)
for(u32 k=0; k<5; k++);
}
*/
}
#endif
//receive data
#if 0
NRF905SE_SetRxAddress("1234", 4);
NRF905SE_SetTxAddress("0123", 4);
u8 tx_array[4];
u8 rx_array[4];
NRF905SE_GetRxAddress(rx_array, 4);
NRF905SE_GetTxAddress(tx_array, 4);
usart_cls();
usart_puts("this is the NRF905SE transfer for receive data, its info are as follows: ");
usart_println();
usart_puts("我的接收地址: ");
usart_printArray(rx_array, 4);
usart_println();
usart_puts("我的目标发送地址:");
usart_printArray(tx_array, 4);
usart_println();
usart_puts("我开始接受来自发射器:");
usart_printArray(tx_array, 4);
usart_puts("发送来的数据:");
usart_println();
u8 payloadSize = NRF905SE_GetRxPayloadSize();
u8 n = 48;
while(1) {
/*****发送32字节的数据包*****/
if(n== 58 ) {
n -= 10;
usart_println();
}
if(NRF905SE_ReceivePacket(NRF905SE_RxBuffer, payloadSize) ) {
usart_puts("收包(");
usart_putc(n++);
usart_puts("): ");
usart_printArray(NRF905SE_RxBuffer, payloadSize);
usart_println();
}
}
#endif
while(1);
}
#ifdef DEBUG
/*******************************************************************************
* Function Name : assert_failed
* Description : Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* Input : - file: pointer to the source file name
* - line: assert_param error line source number
* Output : None
* Return : None
*******************************************************************************/
void assert_failed(u8* file, u32 line)
{
volatile bool Flag = TRUE;
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %drn", file, line) */
/* Infinite loop */
while (Flag )
{
}
}
#endif
4.备注:以上代码是基于stm32固件库的,具体的端口配置,具体的板子相关。代码是基于IAR开发的。
[1] [2] [3] [4]