微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > A7105(2.4G)与STC89C52单片机无线收发程序(接收程序)

A7105(2.4G)与STC89C52单片机无线收发程序(接收程序)

时间:11-27 来源:互联网 点击:
A7105与STC89C52无线模块接收程序,如下所示:

#include
#include
typedefunsigned int uint;
typedef unsigned char uchar;
//A7105寄存器地址定义
#define MODE_REG0x00//寄存器设置
#define MODE_CONTROL_REG0x01//
#define CALIBRATION_REG0x02
#define FIFO_REGISTER1_REG 0x03
#define FIFO_REGISTER2_REG 0x04
#define FIFO_DATA_REG0x05
#define ID_DATA_REG0x06
#define RC_OSC1_REG0x07
#define RC_OSC2_REG0x08
#define RC_OSC3_REG0x09
#define CKO_CONTROL_REG0x0a
#define GIPO1_CONTROL_REG0x0b
#define GIPO2_CONTROL_REG0x0c
#define CLOCK_REG0x0d
#define DATA_RATE_REG0x0e
#define PLL1_REG0x0f
#define PLL2_REG0x10
#define PLL3_REG0x11
#define PLL4_REG0x12
#define PLL5_REG0x13
#define TX1_REG0x14
#define TX2_REG0x15
#define DELAY1_REG0x16
#define DELAY2_REG0x17
#define RX_REG0x18
#define RX_GAIN1_REG0x19
#define RX_GAIN2_REG0x1a
#define RX_GAIN3_REG0x1b
#define RX_GAIN4_REG0x1c
#define RSSI_THRESHOLD_REG 0x1d
#define ADC_CONTROL_REG0x1e
#define CODE1_REG0x1f
#define CODE2_REG0x20
#define CODE3_REG0x21
#define IF_CALIBRATION1_REG0x22
#define IF_CALIBRATION2_REG0x23
#define VCO_CURRENT_CAL_REG0x24
#define VCO_SINGLE_BAND_CAL1_REG0x25
#define VCO_SINGLE_BAND_CAL2_REG0x26
#define BATTERY_DETECT_REG0x27
#define TX_TEST_REG0x28
#define RX_DEM_TEST1_ERG0x29
#define RX_DEM_TEST2_REG0x2a
#define CPC_REG0x2b
#define CRYSTAL_TEST_REG0x2c
#define PLL_TEST_REG0x2d
#define VCO_TEST1_REG0x2e
#define VCO_TEST2_REG0x2f
#define IFAT_REG0x30
#define RSSI_CALE_REG0x31
#define FILTER_TEST_REG0x32
//A7105命令定义
#define CMD_SLEEP0x80
#define CMD_IDLE0x90
#define CMD_STBY0xa0
#define CMD_PLL0xb0
#define CMD_RX0xc0
#define CMD_TX0xd0
#define CMD_TX_FIFO_RESET0xe0
#define CMD_RX_FIFO_RESET0xf0
//ID CODE define
#define ID_CODE00x54
#define ID_CODE10x75
#define ID_CODE20xc5
#define ID_CODE30x2a

#define RF_DATA_PACKET_SIZE64

sbit SCK=P3^5;
sbit SCS=P3^4;
sbit SDIO=P3^6;
sbit GPIO1=P3^7;
sbit LED=P2^0;
sbit Key=P2^4;

const uchar code A7105_Default_Par[]=
{
0x00,// reset register
0x42,//mode register:FIFO mode
0x00,//calibration register
0x3f,//FIFO1 register:packet length,,最后一位为结束位
0x00,//FIFO2 register,,4/60byte(TX/RX)FIFO
0x00,//FIFO register,,R/W data register
0x00,//ID DATA register,not use on config
0x00,//RCOSC1 register
0x00,//RCOSC2 register
0x00,//RCOSC3 register
0x00,//CKO register
0x01,//GPIO1 register,,GPIO1 PIN Enable Output
0x21,//GPIO2 register
0x05,//CLOCK register:Crystal oscillator enable bit
0x00,//DATA RATE register,,,500k
0x50,//PLL1 register
0x9e,//PLL2 register
0x4b,//PLL3 register
0x00,//PLL4 register
0x02,//PLL5 register
0x16,//TX1 register
0x2b,//TX2 register
0x12,//DELAY1 register
0x00,//DELAY2 register
0x62,//RX register,Demodulator filter bandwidth = 1M,Demodulator gain select * 1,BPF:bandwidth 500khz
0x80,//RX GAIN1 register,手动校验VGA,PGA gain select 12db,mixer gain select 24db,LNA gain select 24db.
0x80,//RX GAIN2 register,VGA calibrate upper limit target
0x00,//RX GAIN3 register,VGA calibrate lower limit target
0x0a,//RX GAIN4 register,在设定的目标内持续调整,直到收到ID CODE为止,Mixer high current 1.2ma,LNA current select 1.0ma
0x32,//RSSI register
0xc3,//ADC register
0x07,//CODE1 register;ID length 4 bytes, preamble length 4 bytes
0x16,//CODE2 register
0x00,//CODE3 register
0x00,//IF CALI1 register
0x00,//IF CALI2 register
0x00,//VCO_C_CALI register
0x00,//VCO CALI1 register
0x3b,//VCO CALI2 register
0x00,//BATTERY register
0x17,//TX TEST register
0x47,//RX DEM1 register
0x80,//RX DEM2 register
0x03,//CPC register
0x01,//CRYSTAL register
0x45,//PLL TEST register
0x18,//VCO TEST1 register
0x00,//VCO TSET2 register
0x01,//IFAT register
0x0f,//RSCALE register
0x00//FILTERTEST register
};

uchar const Hop_Tab[]={20,40,80,120,160};
uchar RX_DATA_Buffer[RF_DATA_PACKET_SIZE];
const uchar code LED_BIT[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63};
bit RX_Flag;
uchar timer,seq,Err_Hop_Ctn,timer_ctn;
uchar Read_ID[4];

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top