IC解密STM32+PT100热敏电阻测温nrf24L01无线通信
IC解密用于PT100的测量采集,并通过NRF通信。核心包括电压采集与数据转换与发送。
IC解密单片机源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "24l01.h"
- #include "adc.h"
- u8 s_zb[10]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
- u8 Cs_cl[14]={0xD6,0xD8,0xD0,0xC2,0xBF,0xAA,0xCA,0xBC,0xB2,0xE2,0xC1,0xBF,0x0D,0x0A};
- void Vccc(float dy);
- void Temc(float wd);
- void Ssdc(float sd);
- int main(void)
- { int k=0;
- u16 adcx;
- float T,S,V;
- u8 RX_Buf[4]; //只存4位
- Adc_Init();
-
-
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
- delay_init(); //延时函数初始化
- uart_init(115200); //串口初始化为115200
- LED_Init();
- NRF24L01_Init(); //NRF24L01初始化
- NRF24L01_RX_Mode(); //接受模式
-
- while(NRF24L01_Check())//检查NRF24L01
- {
- printf ("NRF24L01 Error!!\n\r");
- delay_ms(200);
- }
- printf ("NRF24L01 OK!!\n\r");
-
- while(1)
- {
- if (k==1)
- {
- L1: NRF24L01_TX_Mode();
- NRF24L01_TxPacket(Cs_cl);
- NRF24L01_RX_Mode(); //接受模式
- }
- if(NRF24L01_RxPacket(RX_Buf)==RESET)//接收到数据
- {
- // T=26.5;
-
- adcx=Get_Adc_Average(ADC_Channel_1,100);
- S=adcx; //四位数
-
- V=(float)adcx*(3.3/4096);
- T=V*10; //
-
- // V=adcx;
-
- LED0 =!LED0;
- switch(RX_Buf[1])//到时根据题目要求RX_Buf[1]&RX_Buf[2],RX_Buf[0]为字长
- {
- case 0x30:Ssdc(S);/*添加题目所需执行指令;*/break;
- case 0x31:Vccc(V);/*添加题目所需执行指令;*/break;
- case 0x32: goto L1;
- default:Temc(T); break;
- }
- }
-
- }
- }

芯片解密