新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > A7105(2.4G)與STC89C52單片機(jī)無(wú)線收發(fā)程序(發(fā)射程序)

A7105(2.4G)與STC89C52單片機(jī)無(wú)線收發(fā)程序(發(fā)射程序)

作者: 時(shí)間:2016-11-27 來(lái)源:網(wǎng)絡(luò) 收藏
A7105是臺(tái)灣笙科的一款2.4G收發(fā)芯片,一般網(wǎng)上都可以找得到程序的,但是下面的程序都是我自己親自測(cè)試過(guò)的。

以下A7105的發(fā)射程序:

本文引用地址:http://m.butianyuan.cn/article/201611/322550.htm

#include
#include
typedef unsigned int uint;
typedef unsigned char uchar;

#define MODE_REG0x00//寄存器設(shè)置
#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,,最后一位為結(jié)束位
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,手動(dòng)校驗(yàn)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,在設(shè)定的目標(biāo)內(nèi)持續(xù)調(diào)整,直到收到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[]={0x00,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,0x55,0xaa,0xff};
bit RX_Flag;
uchar timer,seq,Err_Hop_Ctn,timer_ctn;
uchar Read_ID[4];

void Init_A7105(void);
void A7105_Config_Chip(void);
void A7105_Calibration(void);
void A7105_Entry_Stdy(void);
void A7105_Setup_Wpll(void);
void A7105_Setup_Channel(uchar ch);
void A7105_Entry_TX(void);
void A7105_Entry_RX(void);
void A7105_Reset_Chip(void);
void A7105_Reset_RX_FIFO(void);
void A7105_Reset_TX_FIFO(void);
void Write_Register(uchar bits,uchar value);
uchar Read_Register(void);
void A7105_Write_Command(uchar cmd);
void A7105_Write_Register(uchar addr,uchar value);
uchar A7105_Read_Register(uchar addr);
void A7105_Write_ID(void);
void A7105_Read_ID(uchar *Read_Ptr);
void A7105_Write_DATA_To_FIFO(void);
void A7105_Read_DATA_From_FIFO(void);
void Send_DATA_By_RF(uchar Send_Byte);
void Rec_RF_DATA(void);

void delay_us(uint x)
{
while(x--);
}

void delay_ms(uint x)
{
uint i;
while(x--)for(i=0;i<120;i++);
}


上一頁(yè) 1 2 下一頁(yè)

評(píng)論


技術(shù)專區(qū)

關(guān)閉