下面是樓主的接受程序
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "usart.h"
- #include "wdg.h"
- #include "timer.h"
- #include "beep.h"
- #include "si4463.h"
- #include <string.h>
- #include <stdlib.h>
- int main(void)
- {
- // u16 t=0;
- delay_init(); //延時函數初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設置中斷優先級分組為組2:2位搶占優先級,2位響應優先級
- uart_init(115200); //串口初始化為115200
- LED_Init(); //初始化與LED連接的硬件接口
- KEY_Init(); //初始化按鍵
- BEEP_Init();BEEP=1;
- TIM3_Int_Init(49,7199);//10Khz的計數頻率,計數到5000為500ms 主要用于喂狗500ms一次6
- // IWDG_Init(6,625); //與分頻數為4*2^6=256,重載值為625,溢出時間為256*625/40=4000ms=4s 4s沒喂就復位
- flag_interrupt_4463=0;//清除標志位
- RF433_GPIO_config();
- EXTI_RF433Configuration();
- SI446X_RESET( ); //SI446X 模塊復位
- SI446X_CONFIG_INIT( ); //SI446X 模塊初始化配置函數
- SI446X_SET_PROPERTY_1(PA_PWR_LVL, 0X7F);
- SI446X_START_RX( 0, 0, PACKET_LENGTH,8,8,8 ); //接收狀態
- // memset(Si4463_rxbuffer,0,10);//清空接受緩存
- BEEP=0;
-
- while(1)
- {
- if(si4463irq==0)
- {
- flag_interrupt_4463=0;//清除標志位
- SI446X_INT_STATUS( Si4463_rxbuffer ); //讀狀態寄存器
- if( Si4463_rxbuffer[3] & ( 1<<4 ) ) //接收中斷產生 收到有效數據包
- {
- g_length = SI446X_READ_PACKET( Si4463_rxbuffer );//未知
- g_Si4463_RecvFlag=1;//未知
- SI446X_START_RX( 0, 0, PACKET_LENGTH,8,8,8 );
- if(Si4463_rxbuffer[1]==0x50)
- {
- memset(Si4463_rxbuffer,0,10);//清空接受緩存
- BEEP=!BEEP;
- }
- SI446X_CONFIG_INIT(); // ??????,?????WDS??????
- SI446X_START_RX(0, 0, PACKET_LENGTH, 8, 8, 8); // ??????
- }
- if (Si4463_rxbuffer[3] & ( 1<<5 )) //發送中斷
- {
- SI446X_START_RX( 0, 0, PACKET_LENGTH,8,8,8 ); //接收狀態
- }
- }
- if(send_adc_flag>100)//大約1s鐘改變一次狀態
- {
- send_adc_flag=0;
- LED0=!LED0;
- }
- }
- }
復制代碼 |