stm32测量数据通过nrf24l01无线通信芯片解密
芯片解密单片机源程序如下:
- 芯片解密#include "main.h" //main.h 中含有TX/RX、软件SPI/硬件SPI选择配置选项
- 芯片解密#include <string.h>
- 芯片解密#include <stdio.h>
- 芯片解密#include "Main.h"
- 芯片解密#include "stm32f10x_rcc.h"
- #include "stm32f10x_gpio.h"
- #include "drv_UART.h"
- #include "UART2.h"
- #include "drv_delay.h"
- #include "JY901.h"
- #include "celiang.h"
- uint8_t g_UartRxBuffer1[ 100 ] = "zmbyaaaaa";
- const char *g_Ashining = "receive";
- uint8_t g_TxMode = 0, g_UartRxFlag = 0;
- uint8_t g_UartRxBuffer[ 100 ] = { 0 };
- uint8_t g_RF24L01RxBuffer[ 32 ] = { 0 };
- struct SAcc stcAcc; //加速度
- struct SGyro stcGyro; //角速度
- struct SAngle stcAngle; //角度
- //CopeSerialData为串口2中断调用函数,串口每收到一个数据,调用一次这个函数。
- void CopeSerial2Data(unsigned char ucData)
- {
- static unsigned char ucRxBuffer[250];
- static unsigned char ucRxCnt = 0;
- ucRxBuffer[ucRxCnt++]=ucData; //将收到的数据存入缓冲区中
- if (ucRxBuffer[0]!=0x55) //数据头不对,则重新开始寻找0x55数据头
- {
- ucRxCnt=0;
- return;
- }
- if (ucRxCnt<9) {return;}//数据不满11个,则返回
- else
- {
- switch(ucRxBuffer[1])//判断数据是哪种数据,然后将其拷贝到对应的结构体中,有些数据包需要通过上位机打开对应的输出后,才能接收到这个数据包的数据
- {
- //memcpy为编译器自带的内存拷贝函数,需引用"string.h",将接收缓冲区的字符拷贝到数据结构体里面,从而实现数据的解析。
- case 0x51: memcpy(&stcAcc,&ucRxBuffer[2],8);break;
- case 0x52: memcpy(&stcGyro,&ucRxBuffer[2],8);break;
- case 0x53: memcpy(&stcAngle,&ucRxBuffer[2],8);break;
-
- }
- ucRxCnt=0;//清空缓存区
- }
- }
- void CopeSerial1Data(unsigned char ucData)
- {
- UART2_Put_Char(ucData);//转发串口1收到的数据给串口2(JY模块)
- }
- uint16_t Array_Size(uint8_t * array_pt)
- {
- uint8_t * pt;
- uint16_t size;
- for(pt = array_pt; *pt != '\n'; pt++)
- {
- size++;
- }
- return size;
- }
下一篇:高度集成带来的技术挑战芯片解密

芯片解密