有谁用过C9652 收音芯片,有没有完整驱动啊

zhangwulin1207 2018-11-06 08:31:52
这两天调试时遇到问题,原厂只提供了硬件原理图和驱动接口,没有芯片说明书之类的(主要想要寄存器的说明),也没有demo程序
...全文
32 点赞 收藏 3
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangwulin1207 2018-11-06
程序只是接口,没有完整调用流程,那些寄存器没有说明,一堆数字不知道什么意思
回复
zhangwulin1207 2018-11-06
/****************************************************************************
c9652源码 涵盖频段FM,AM,WB
****************************************************************************/
#define RADIO_CHIP_VISION_F
#define FM_FREQ_TOP 10800
#define FM_FREQ_BOTTON 8750
#define FM_STEP 10
#define AM_FREQ_TOP 1710
#define AM_FREQ_BOTTON 520
#define AM_STEP 10
#define WB_FREQ_TOP 65020
#define WB_FREQ_BOTTON 64960
#define WB_STEP 10

#define AM 0
#define FM 1
#define WB 2

#define UP 1
#define DOWN 0

unsigned char am_fm;
unsigned char ChipVision;
unsigned int fm_freq;
unsigned int wb_freq;
unsigned int am_freq;


void _pll_i2c_wait(void)
{
_nop_();
_nop_();
}
void _pll_i2c_start(void)
{
PLL_SET_SCLK_OUT;
PLL_SET_SDAT_OUT;
PLL_SCLK(1);
PLL_SDA(1);
_pll_i2c_wait();
PLL_SDA(0);
_pll_i2c_wait();
PLL_SCLK(0);
}
void _pll_i2c_stop(void)
{
PLL_SET_SDAT_OUT;
_pll_i2c_wait();
PLL_SCLK(0);
PLL_SDA(0);
_pll_i2c_wait();
PLL_SCLK(1);
_pll_i2c_wait();
PLL_SDA(1);
_dly_1ms(1); /****此延时必须有******/
}
void _pll_i2c_no_ack(void)
{
PLL_SET_SDAT_OUT;
_pll_i2c_wait();
PLL_SCLK(0);
_pll_i2c_wait();
PLL_SDA(1);
PLL_SCLK(1);
_pll_i2c_wait();
PLL_SCLK(0);
}
void _pll_i2c_ack(void)
{
PLL_SET_SDAT_OUT;
_pll_i2c_wait();
PLL_SCLK(0);
_pll_i2c_wait();
PLL_SDA(0);
PLL_SCLK(1);
_pll_i2c_wait();
PLL_SCLK(0);
}
u8_t _pll_i2c_wr_byte(u8_t bdat)
{
u8_t i;
PLL_SET_SDAT_OUT;
for(i=0;i<8;i++)
{
PLL_SCLK(0);
_pll_i2c_wait();
PLL_SDA(bdat&0x80);
_pll_i2c_wait();
PLL_SCLK(1);
_pll_i2c_wait();
PLL_SCLK(0);
bdat<<=1;
}
PLL_SET_SDAT_IN;
_pll_i2c_wait();
PLL_SCLK(1);
_pll_i2c_wait();
if(PLL_SDA_IN)
{
PLL_SCLK(0);
return 0;
}
else
{
PLL_SCLK(0);
return 1;
}
}
u8_t _pll_i2c_rd_byte(void)
{
u8_t i,bdat;
PLL_SET_SDAT_IN;
for(i=0;i<8;i++)
{
bdat<<=1;
PLL_SCLK(0);
_pll_i2c_wait();
PLL_SCLK(1);
_pll_i2c_wait();
if(PLL_SDA_IN)
{
bdat|=0x01;
}
}
PLL_SCLK(0);
_pll_i2c_wait();
return bdat;
}

void __ca96xx_wr_reg(u8_t *dat, u8_t bytes)
{
u8_t i;
_pll_i2c_start();
_pll_i2c_wr_byte(0x22);
for(i=0;i<bytes;i++)
{
_pll_i2c_wr_byte(*dat++);
}
_pll_i2c_stop();
}
void __ca96xx_rd_reg(u8_t *dat, u8_t bytes)
{
u8_t i;
_pll_i2c_start();
_pll_i2c_wr_byte(0x23);
for(i=0;i<bytes;i++)
{
*dat++=_pll_i2c_rd_byte();
if(i==bytes-1) _pll_i2c_no_ack();
else _pll_i2c_ack();
}
_pll_i2c_stop();
}
// send command , if received, STATUS==0x80
void __ca96xxcom(u8_t *dat,u8_t bytes)
{
u8_t xdata loop_counter=0,ca96xx_reg_data[1],error_ind = 0;
__ca96xx_wr_reg(dat,bytes);
do
{
__ca96xx_rd_reg(ca96xx_reg_data,1);
loop_counter++;
}
while((((ca96xx_reg_data[0])&0x80) != 0x80) && (loop_counter < 0x10));
}

void __ca96xx_power_up(void)
{
u8_t xdata ca96xx_set_property[3] = {0x01,0x10,0x05};
if(am_fm==AM)
ca96xx_set_property[1]=0x11;
else if(am_fm == WB)
ca96xx_set_property[1]=0x13;
__ca96xx_wr_reg(ca96xx_set_property,3);
_dly_100ms(6);
}
void __ca96xx_power_down(void)
{
code u8_t ca96xx_set_property[] = {0x21};
__ca96xx_wr_reg(ca96xx_set_property,1);
}
/**************************************

***************************************/
u16_t __ca96xx_rd_freq(void)
{
u8_t xdata ca96xx_reg[8];
u8_t xdata ca96xx_get_int_status[] = {0x52,0x00};
if(am_fm==AM)
{
ca96xx_get_int_status[0]=0x62;
}
__ca96xx_wr_reg(ca96xx_get_int_status,2);
__ca96xx_rd_reg(ca96xx_reg,8);
return (ca96xx_reg[2]*256+ca96xx_reg[3]);
}


void __ca96xx_cancle_seek(void)
{
u8_t xdata ca96xx_get_int_status[] = {0x52,0x03};
if(am_fm==AM)
{
ca96xx_get_int_status[0]=0x62;
}
__ca96xx_wr_reg(ca96xx_get_int_status,2);
}

void __ca96xx_set_ic_voltage(void) //内核电压
{
u8_t code ca96xx_set_ic_voltage0[] = {0xe8,0x0,0x20};
u8_t code ca96xx_set_ic_voltage1[] = {0xe8,0x1,0x2d};
u8_t code ca96xx_set_ic_voltage2[] = {0xe1,0x1,0x21,0x60,0x36};
__ca96xx_wr_reg(ca96xx_set_ic_voltage0,3);
__ca96xx_wr_reg(ca96xx_set_ic_voltage1,3);
__ca96xx_wr_reg(ca96xx_set_ic_voltage2,5);
}
void __ca96xx_init_selectcap(void) //选频网络 am发起搜台和搜台过程中每读一次频率时调用
{
u8_t xdata ca96xx_set_cap[] = {0xe1, 0x02, 0x21, 0x4E, 0x00,0x00};
__ca96xxcom(ca96xx_set_cap, 6);
}

void __ca96xx_seek_start(u8_t u_d)
{
code u8_t ca96xx_set_propertyU[] = {0x51,0x0c};
code u8_t ca96xx_set_propertyD[] = {0x51,0x04};
xdata u8_t ca96xx_set_propertyUU[] = {0x61,0x0c,0x00,0x00,0x00,0x00};
xdata u8_t ca96xx_set_propertyDD[] = {0x61,0x04,0x00,0x00,0x00,0x00};
if(am_fm==FM||(am_fm==WB))
{
if(u_d==UP)
__ca96xxcom(ca96xx_set_propertyU,2);
else
__ca96xxcom(ca96xx_set_propertyD,2);
}
else
{
__ca96xx_init_selectcap();
if(u_d == UP)
{
__ca96xxcom(ca96xx_set_propertyUU,6);
}
else
{
__ca96xxcom(ca96xx_set_propertyDD,6);
}
}
_dly_100ms(1);
}
u8_t __ca96xx_wait_STC(void)
{
u8_t ca96xx_reg[2];
u8_t xdata ca96xx_get_int_status[] = {0x52,0x00};
if(am_fm==AM)
{
ca96xx_get_int_status[0]=0x62;
}
__ca96xx_wr_reg(ca96xx_get_int_status,2);
_delay_25nop()
__ca96xx_rd_reg(ca96xx_reg,2);
if((ca96xx_reg[1]&0x81)== 0 ) return 0;
return 1;
}
void __ca96xx_set_wb_max_tune_error(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x11,0x08,0x00,0x08};
__ca96xxcom(ca96xx_set_property,6);
}
void __ca96xx_set_fm_seek_top(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x14,0x01,0x00,0x00};
ca96xx_set_property[4]=FM_FREQ_TOP>>8;
ca96xx_set_property[5]=FM_FREQ_TOP;
__ca96xxcom(ca96xx_set_property,6);
}
void __ca96xx_set_wb_seek_top(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x14,0x01,0x00,0x00};
ca96xx_set_property[4]=WB_FREQ_TOP>>8;
ca96xx_set_property[5]=WB_FREQ_TOP;
__ca96xxcom(ca96xx_set_property,6);
}
void __ca96xx_set_fm_seek_botton(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x14,0x00,0x00,0x00};
ca96xx_set_property[4]=FM_FREQ_BOTTON>>8;
ca96xx_set_property[5]=FM_FREQ_BOTTON;
__ca96xxcom(ca96xx_set_property,6);
}
void __ca96xx_set_wb_seek_botton(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x14,0x00,0x00,0x00};
ca96xx_set_property[4]=WB_FREQ_BOTTON>>8;
ca96xx_set_property[5]=WB_FREQ_BOTTON;
__ca96xxcom(ca96xx_set_property,6);
}
void __ca96xx_set_fm_seek_space(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x14,0x02,0x00,0x00};
ca96xx_set_property[5]=FM_STEP;
__ca96xxcom(ca96xx_set_property,6);
}
void __ca96xx_set_wb_seek_space(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x14,0x02,0x00,0x00};
ca96xx_set_property[5]=WB_STEP;
__ca96xxcom(ca96xx_set_property,6);
}
void __ca96xx_set_fm_snr_threshold(void)
{
code u8_t ca96xx_set_property[] = {0x22,0x00,0x14,0x03,0x00,0x03};
__ca96xxcom(ca96xx_set_property,6);
}
void __ca96xx_set_fm_rssi_threshold(void)
{
code u8_t ca96xx_set_property[] = {0x22,0x00,0x14,0x04,0x00,0x08};
__ca96xxcom(ca96xx_set_property,6);
}

void __ca96xx_fm_mute_snr_para(void)
{
u8_t code ca96xx_fm_mute_snr_para[] = {0x22,0x00,0x13,0x03,0x00,0x01}; //修改底噪声,可以考虑修改大一些max:0x5
__ca96xxcom(ca96xx_fm_mute_snr_para, 6);
}

void __ca96xx_wb_mute_snr_para(void)
{
u8_t code ca96xx_wb_mute_snr_para[] = {0x22,0x00,0x13,0x03,0x00,0x01}; //修改底噪声,可以考虑修改大一些max:0x5
__ca96xxcom(ca96xx_wb_mute_snr_para, 6);
}

void __ca96xx_set_fm_mono_st_blend(void)
{
u8_t code FM_BLEND_RSSI_STEREO_THRESHOLD_st[]={0x22,0x00,0x18,0x00,0x00,0x2F};
u8_t code FM_BLEND_RSSI_MONO_THRESHOLD_st[]={0x22,0x00,0x18,0x01,0x00,0x3};
u8_t code FM_RSQ_BLEND_THRESHOLD_st[]={0x22,0x00,0x12,0x07,0x00,0x80};
//FM_RSQ_BLEND_st[4]为可修改对的参数,范围0x0-0x9,数字越大灵敏度越高
u8_t code FM_RSQ_BLEND_st[5]={0xE1,0x01,0x21,0x1E,0x06};

u8_t code FM_BLEND_RSSI_STEREO_THRESHOLD_mono[]={0x22,0x00,0x18,0x00,0x00,0x7f};
u8_t code FM_BLEND_RSSI_MONO_THRESHOLD_mono[]={0x22,0x00,0x18,0x01,0x00,0x7f};

if(st_mo == STEREO)
{
__ca96xxcom(FM_BLEND_RSSI_STEREO_THRESHOLD_st,6);
__ca96xxcom(FM_BLEND_RSSI_MONO_THRESHOLD_st,6);
__ca96xxcom(FM_RSQ_BLEND_THRESHOLD_st,6);
__ca96xxcom(FM_RSQ_BLEND_st,5); }
else
{
__ca96xxcom(FM_BLEND_RSSI_STEREO_THRESHOLD_mono,6);
__ca96xxcom(FM_BLEND_RSSI_MONO_THRESHOLD_mono,6);
}
}
void __ca96xx_set_fm_deemphasis(void)
{
#if (FM_STEP==5)//50k
code u8_t ca96xx_set_property[] = {0x22,0x00,0x11,0x00,0x00,0x01};//50μs
#else//100k,200k
code u8_t ca96xx_set_property[] = {0x22,0x00,0x11,0x00,0x00,0x02};//75μs
#endif
__ca96xxcom(ca96xx_set_property,6);
}
void _ca96xx_MuteIc(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x40,0x01,0x00,0x03};
__ca96xxcom(ca96xx_set_property,6);
}
void _ca96xx_DisMuteIc(void)
{
u8_t xdata ca96xx_set_property[] = {0x22,0x00,0x40,0x01,0x00,0x00};
__ca96xxcom(ca96xx_set_property,6);


}

code u8_t CA96XX_VOLUME_TABLE[]=
{
0,38,40,42,44,46,48,50, //VOLUME 0-7
52,54,56,58,59,60,61,62,63 //VOLUME 8-16
};
void _ca96xx_set_volume(u8_t vol)
{
u8_t xdata ca96xx_get_int_status[6] = {0x22,0x00,0x40, 0x00, 0x00,0x00}; //ic内部vol 0-63
ca96xx_get_int_status[5] = CA96XX_VOLUME_TABLE[vol];
__ca96xx_wr_reg(ca96xx_get_int_status,6);
}

void __ca96xx_set_am_freq(void)
{
u8_t xdata ca96xx_set_property[] = {0x60,0x00,0x27,0xF6,0x00,0x00};
#ifdef RADIO_CHIP_VISION_F
if(ChipVision == 1)
{
u8_t xdata ca96xx_set_property1[] = {0xE1,0x1,0x22,0xe2,0x0};
u8_t xdata ca96xx_set_property2[] = {0xE3,0x14,0x0};
__ca96xxcom(ca96xx_set_property1,5);
__ca96xxcom(ca96xx_set_property2,3);
}
#endif
ca96xx_set_property[2] = am_freq>>8;
ca96xx_set_property[3] = am_freq;
__ca96xxcom(ca96xx_set_property,6);

_dly_100ms(1);
#ifdef RADIO_CHIP_VISION_F
if((ChipVision == 1)&&(am_fm == AM))//同lw
{
u8_t xdata ca96xx_set_property1[] = {0xE1,0x01,0x22,0xE2,0x01};
__ca96xxcom(ca96xx_set_property1,5);
}
#endif
}
void __ca96xx_set_fm_freq(void)
{
u8_t xdata ca96xx_set_property[] = {0x50,0x00,0x27,0xF6,0x00};
if(am_fm==WB)
{
ca96xx_set_property[2] = wb_freq>>8;
ca96xx_set_property[3] = wb_fre
回复
zhangwulin1207 2018-11-06
回复
发帖
其它技术问题
创建于2007-09-28

3842

社区成员

C/C++ 其它技术问题
申请成为版主
帖子事件
创建了帖子
2018-11-06 08:31
社区公告
暂无公告