IC解密LPC1788的多路数据采集系统下位机
IC解密单片机源程序如下:
- #include "../LPC177x_8x/LPC177x_8x.h"
- #include "../LPC177x_8x/type.h"
- #include "../ADC/adc.h"
- #define BEEPON (LPC_GPIO3->CLR = 1ul << 30) /* 蜂鸣器工作 */
- #define BEEPOFF (LPC_GPIO3->SET = 1ul << 30) /* 蜂鸣器不工作 */
- #if ADC_DEBUG
- #include "../UART/uart.h"
- #endif
- extern volatile uint32_t ADCValue[ADC_NUM];
- extern volatile uint32_t ADCIntDone;
- #if ADC_DEBUG
- extern volatile uint32_t UART0Count;
- extern volatile uint8_t UART0Buffer[BUFSIZE];
- #endif
- #if ADC_DEBUG
- /*********************************************************************************************************
- ** 函数名称 :ConvertDigital
- ** 函数功能 :Convert Digital to ASCII
- ** 输入参数 : 字符
- ** 返回值 : ASCII字符
- *********************************************************************************************************/
- static uint8_t ConvertDigital ( uint8_t digit )
- {
- static uint8_t hex[] = "0123456789ABCDEF";
- return hex[digit & 0xf];
- }
- #endif
- /*********************************************************************************************************
- ** 函数名称:myDelay
- ** 函数描述:软件延时
- ** 输入参数:ulTime 延时大小
- ** 返回值 :无
- *********************************************************************************************************/
- //uint8_t tdata[5]={0x00,0x00,0x00,0x00,0x00};
- uint8_t buf[7];
- uint8_t sbuf,check;
- void myDelay (uint32_t ulTime)
- {
- uint32_t i = 0;
- while (ulTime--)
- {
- for (i = 0; i < 20000; i++);
- }
- }
- void usDelay (uint32_t ulTime)
- {
- uint32_t i = 0;
- while (ulTime--)
- {
- for (i = 0; i < 20; i++);
- }
- }
- void DHT11_Rst(void)
- {
- LPC_GPIO3->DIR |= 1<<25; //SET OUTPUT
- LPC_GPIO3->CLR = 1ul << 25 ; //拉低DQ
- myDelay(20); //拉低至少18ms
- LPC_GPIO3->SET = 1ul << 25; //DQ=1
- usDelay(30); //主机拉高20~40us
- }
- //等待DHT11的回应
- //返回1:未检测到DHT11的存在
- //返回0:存在
- uint8_t DHT11_Check(void)
- {
- uint8_t retry=0;
- LPC_GPIO3->DIR &= ~(1 << 25); //SET INPUT
- while (!(LPC_GPIO3->PIN & 1 << 25)&&retry<100)//DHT11会拉低40~80us
- {
- retry++;
- usDelay(1);
- }
- if(retry>=100)
- return 1;
- else retry=0;
- while ((LPC_GPIO3->PIN & 1 << 25)&&retry<100)//DHT11拉低后会再次拉高40~80us
- {
- retry++;
- usDelay(1);
- }
- if(retry>=100)
- return 1;
- return 0;
- }

芯片解密