void si4432_init(void)
{
spi_init();
//CS引脚
GPIOB->DDR|=(1<<4);
GPIOB->ODR|=(1<<4); //高
GPIOB->CR1|=(1<<4);
GPIOB->CR2|=(1<<4);
//IRQ引脚 PC0
GPIOC->DDR&=~(1<<0);
GPIOC->CR1|=(1<<0);//悬浮输入(上拉关)
GPIOC->CR2&=~(1<<0);//中断禁止
//GPIOC->CR2|=(1<<0);//中断使能
//EXTI->CR1|=(1<<1);//Px0引脚下降沿触发
si4432_write_reg(0x07, 0x80); //恢复所有寄存器为默认值
delay_ms(500);
si4432_read_reg(0x03); //清除所有中断标志
si4432_read_reg(0x04); //清除所有中断标志
si4432_write_reg(0x05, 0x00); //清除所有中断使能
si4432_write_reg(0x06, 0x00); //清除所有中断使能
si4432_write_reg(0x06, 0x80); //使能同步字侦测
si4432_write_reg(0x07, 0x01); //进入 Ready 模式
si4432_write_reg(0x09, 0x64); //负载电容= 10P
si4432_write_reg(0x0a, 0x05); //关闭低频输出
si4432_write_reg(0x0b, 0xea); //GPIO 0 当做普通输出口
si4432_write_reg(0x0c, 0xea); //GPIO 1 当做普通输出口
si4432_write_reg(0x0d, 0xf4); //GPIO 2 输出收到的数据
si4432_write_reg(0x70, 0x24);
si4432_write_reg(0x1d, 0x40); //使能 afc
// 1.2K bps setting
si4432_write_reg(0x1c, 0x16); //IF滤波带宽
si4432_write_reg(0x20, 0x83);
si4432_write_reg(0x21, 0xc0); //
si4432_write_reg(0x22, 0x13); //
si4432_write_reg(0x23, 0xa9); //
si4432_write_reg(0x24, 0x00); //
si4432_write_reg(0x25, 0x04); //
si4432_write_reg(0x2a, 0x14);
si4432_write_reg(0x6e, 0x09);
si4432_write_reg(0x6f, 0xd5);
//1.2K bps setting end
si4432_write_reg(0x30, 0x8c); //使能PH+ FIFO模式,高位在前面,使能CRC校验
si4432_write_reg(0x32, 0xff); //byte 0,1,2,3 作为头码
si4432_write_reg(0x33, 0x42); //byte 0,1,2,3 是头码,同步字3,2 是同步字
si4432_write_reg(0x34, 16); //发射16个Nibble的Preamble
si4432_write_reg(0x35, 0x20); //需要检测4个nibble的Preamble
si4432_write_reg(0x36, 0x2d); //同步字为 0x2dd4
si4432_write_reg(0x37, 0xd4);
si4432_write_reg(0x38, 0x00);
si4432_write_reg(0x39, 0x00);
si4432_write_reg(0x3a, '7'); //发射的头码为:"7250"
si4432_write_reg(0x3b, '2');
si4432_write_reg(0x3c, '5');
si4432_write_reg(0x3d, '0');
si4432_write_reg(0x3e, 10); //总共发射TxBuf_Len个字节的数据
si4432_write_reg(0x3f, '7'); //需要校验的头码为:"7250"
si4432_write_reg(0x40, '2');
si4432_write_reg(0x41, '5');
si4432_write_reg(0x42, '0');
si4432_write_reg(0x43, 0xff); //头码1,2,3,4 的所有位都需要校验
si4432_write_reg(0x44, 0xff); //
si4432_write_reg(0x45, 0xff); //
si4432_write_reg(0x46, 0xff); //
si4432_write_reg(0x6d, 0x07); //发射功率设置 0x00:+1dBM 0x01:+2dBM 0x02:+5dBM 0x03:+8dBM 0x04:+11dBM 0x05:+14dBM 0x06:+17dBM 0x07:+20dBM
si4432_write_reg(0x79, 0x0); //不需要跳频
si4432_write_reg(0x7a, 0x0); //不需要跳频
si4432_write_reg(0x71, 0x22); //发射不需要CLK,FiFo,FSK模式
si4432_write_reg(0x72, 0x30); //频偏为 30KHz
si4432_write_reg(0x73, 0x0); //没有频率偏差
si4432_write_reg(0x74, 0x0); //没有频率偏差
si4432_write_reg(0x75, 0x53); //频率设置 434
si4432_write_reg(0x76, 0x57); //
si4432_write_reg(0x77, 0x80);
SI4432_ANT_RDY_SEL; // 天线开关不在发射,接收状态
si4432_write_reg(0x07, 1); //IDLE模式
}