| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #include "stm32f4xx_gpio.h"
- #include "stm32f4xx_rcc.h"
- #include "clock.h"
- #include "delay.h"
- #include "myUart.h"
- #include "myRadio.h"
- static rfRxPacket_ts rfRecvPacket;
- static rfTxPacket_ts rfTxPacket;
- static bool rftxflag = true;
- void rfRx_callback(uint8_t status, rfRxPacket_ts packet)
- {
- switch (status)
- {
- case RX_STA_SECCESS:
- {
- printf("RX_STA_SECCESS\r\n");
- rfRecvPacket = packet;
- printf("rf get Packet:%s\r\n", rfRecvPacket.payload);
- myRadio_receiver();
- }
- break;
- case TX_STA_SECCESS:
- {
- printf("TX_STA_SECCESS\r\n");
- myRadio_receiver();
- rftxflag = false;
- }
- break;
- default:
- break;
- }
- }
- int main(void)
- {
-
- SCB->VTOR = FLASH_BASE; // Vector Table Relocation in Internal FLASH
- HSI_Init(16, 200, 2, 7);//高速的内部时钟为16M,配置之后为:16/16*112/2=56M
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); //中断分组配置
- myUart1_init(115200, 0); //串口1初始化
- myRadio_init(0, rfRx_callback);
- myRadio_receiver();
- unsigned int i,j,k,Test = 0;
- printf("Hello World!\r\n");
- while(1)
- {
- if (rftxflag == false)
- {
- if (Test++ >= 100)
- {
- Test = 0;
- rftxflag = true;
- rfTxPacket.len = 5;
- strcpy(rfTxPacket.payload, "hello");
- myRadio_transmit(&rfTxPacket);
- }
-
- }
- myRadio_delay(10);
- myRadio_process();
- }
- }
|