资源简介

包含TEA5767的完整工程文件,基于STM32F767的HAL库,还有代码资料,芯片的资料以及自己开发时做的关于寄存器组织的笔记

资源截图

代码片段和文件信息

#include “FM.h“

//外部变量,保存寄存器写入读出的值
extern unsigned char radio_read_data[5];
extern unsigned char radio_write_data[5];



//读 TEA5767 状态并转换成频率
unsigned long radio_read(void)
{
unsigned char temp_ltemp_h;
unsigned long pll=0;
unsigned long frequency;

HAL_I2C_Master_Receive(&hi2c20xc1radio_read_data5500);

temp_l=radio_read_data[1];
temp_h=radio_read_data[0];
temp_h&=0x3f;

pll=temp_h*256+temp_l;

if (radio_write_data[2]&0x10)
frequency=(unsigned long)((float)(pll)*(float)8.192-225); //频率单位:KHz
else
frequency=(unsigned long)((float)(pll)*(float)8.192+225); //频率单位:KHz

printf(“frequency:%ld\r\n“frequency);

return frequency;
}


//手动设置频率mode=1+0.1MHz; mode=0:-0.1MHz 不用考虑 TEA5767 用于搜台的相关位:SMSUD
void search(uint8_t mode)
{
unsigned long pll=0;
unsigned long frequency;

frequency = radio_read();

if(mode)
{
frequency+=200;
if(frequency>max_freq)
frequency=min_freq;
}
else
{
frequency-=200;
if(frequency frequency=max_freq;
}

if (radio_write_data[2]&0x10)
pll=(unsigned long)((float)((frequency+225)*4)/(float)32.768); //频率单位:k
else
pll=(unsigned long)((float)((frequency-225)*4)/(float)32.768); //频率单位:k

radio_write_data[0]=pll/256;
radio_write_data[1]=pll%256;
radio_write_data[2]=0x20;
radio_write_data[3]=0x11;
radio_write_data[4]=0x00;

HAL_I2C_Master_Transmit(&hi2c20xc0radio_write_data5500);

}


//自动搜台mode=1频率增加搜台; mode=“0:频率减小搜台“.
void Auto_Search(unsigned char mode)
{
unsigned long pll=0;
unsigned long frequency;

frequency = radio_read();

if (radio_write_data[2]&0x10)
pll=(unsigned long)((float)((frequency+225)*4)/(float)32.768); //频率单位:k
else
pll=(unsigned long)((float)((frequency-225)*4)/(float)32.768); //频率单位:k

if(mode)
{
radio_write_data[2] = 0xb1;
if(pll > max_pll)
{
pll = min_pll;
}
}
else
{
radio_write_data[2] = 0x41;
if(pll < min_pll)
{
pll = max_pll;
}
}

radio_write_data[0] = pll/256+0x40;
radio_write_data[1] = pll%256; 
radio_write_data[3] = 0x11;
radio_write_data[4] = 0x40;

HAL_I2C_Master_Transmit(&hi2c20xc0radio_write_data5500);


while(!(radio_read_data[0]&0x80)) //RF电台就绪标志
{
frequency = radio_read();


}








 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-03-12 09:33  code\
     目录           0  2018-03-12 09:26  code\FM_test\
     文件        5388  2018-03-10 16:27  code\FM_test\.mxproject
     目录           0  2018-03-12 09:33  code\FM_test\EWARM\
     文件         235  2018-03-12 09:33  code\FM_test\EWARM\FM_Test.dep
     文件       50973  2018-03-10 16:27  code\FM_test\EWARM\FM_Test.ewd
     文件       31535  2018-03-10 16:27  code\FM_test\EWARM\FM_Test.ewp
     文件       91510  2018-03-10 14:28  code\FM_test\EWARM\FM_Test.ewt
     文件         151  2018-03-10 14:26  code\FM_test\EWARM\Project.eww
     目录           0  2018-03-10 16:27  code\FM_test\EWARM\settings\
     文件         384  2018-03-12 09:33  code\FM_test\EWARM\settings\FM_Test.crun
     文件          69  2018-03-12 09:33  code\FM_test\EWARM\settings\FM_Test.dbgdt
     文件        3617  2018-03-12 09:33  code\FM_test\EWARM\settings\FM_Test.dnx
     文件        1504  2018-03-12 09:33  code\FM_test\EWARM\settings\FM_Test.FM_Test.cspy.bat
     文件        1445  2018-03-12 09:33  code\FM_test\EWARM\settings\FM_Test.FM_Test.cspy.ps1
     文件         379  2018-03-12 09:33  code\FM_test\EWARM\settings\FM_Test.FM_Test.driver.xcl
     文件         346  2018-03-12 09:33  code\FM_test\EWARM\settings\FM_Test.FM_Test.general.xcl
     文件       25465  2018-03-12 09:33  code\FM_test\EWARM\settings\Project.wsdt
     文件       31647  2018-01-24 15:52  code\FM_test\EWARM\startup_stm32f767xx.s
     文件        1598  2018-03-10 16:27  code\FM_test\EWARM\stm32f767xx_flash.icf
     文件        1634  2018-03-10 16:27  code\FM_test\EWARM\stm32f767xx_ITCM_flash.icf
     文件        1598  2018-03-10 16:27  code\FM_test\EWARM\stm32f767xx_sram.icf
     文件        8142  2018-03-10 16:27  code\FM_test\FM_Test.ioc
     目录           0  2018-03-10 17:07  code\FM_test\Inc\
     文件         368  2018-03-10 17:07  code\FM_test\Inc\FM.h
     文件        3042  2018-03-10 16:27  code\FM_test\Inc\gpio.h
     文件        3111  2018-03-10 16:27  code\FM_test\Inc\i2c.h
     文件        3709  2018-03-10 16:29  code\FM_test\Inc\main.h
     文件       17281  2018-03-10 16:27  code\FM_test\Inc\stm32f7xx_hal_conf.h
     文件        2848  2018-03-10 16:27  code\FM_test\Inc\stm32f7xx_it.h
     文件        3130  2018-03-10 16:27  code\FM_test\Inc\usart.h
............此处省略14个文件信息

评论

共有 条评论