标题:
STM32+CC1101,SPI驱动,非GPIO模拟源程序
[打印本页]
作者:
danruhai
时间:
2019-7-31 10:39
标题:
STM32+CC1101,SPI驱动,非GPIO模拟源程序
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "usart2.h"
#include "time2.h"
#include "Time3.h"
#include "string.h"
#include "stdlib.h"
#include "spi_cc1101.h"
#include "led.h"
extern u8 PaTabel[8];
u8 SWitch1Flg;
u8 SWitch2Flg;
u8 SWitch3Flg;
u8 txBuffer[4];
int main(void)
{
u8 i;
SWitch1Flg = 0;
SWitch2Flg = 0;
SWitch3Flg = 0;
delay_init(); //延时函数初始化
//LED_Init();
NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
uart_init(115200); //串口初始化为9600
USART2_Config();
USAT2_NVIC_Configuration();
printf("SYS INIT OK....\r\n");
SPI_CC1101_Init();
CC1101_POWER_RESET();
halRfWriteRfSettings();
halSpiWriteBurstReg(CCxxx0_PATABLE, PaTabel, 8);//发射功率设置
while(1)
{
if (SWitch1Flg == 1)
{
SWitch1Flg = 0;
txBuffer[0] = 0xfe;
txBuffer[1] = 0x01;
txBuffer[2] = 0xf0;
txBuffer[3] = 0xf1;
halRfSendPacket(txBuffer, 4);
//printf("5\r\n");
}
if (SWitch2Flg == 1)
{
SWitch2Flg = 0;
txBuffer[0] = 0xfe;
txBuffer[1] = 0x02;
txBuffer[2] = 0xf0;
txBuffer[3] = 0xf1;
halRfSendPacket(txBuffer, 4);
// printf("6\r\n");
}
if (SWitch3Flg == 1)
{
SWitch3Flg = 0;
txBuffer[0] = 0xfe;
txBuffer[1] = 0x03;
txBuffer[2] = 0xf0;
txBuffer[3] = 0xf1;
halRfSendPacket(txBuffer, 4);
// printf("6\r\n");
}
}
}
复制代码
STM32CC1101.7z
2019-7-31 22:29 上传
点击文件名下载附件
下载积分: 黑币 -5
222.25 KB, 下载次数: 31, 下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1