程序代码.zip

  • sss345
    了解作者
  • C/C++
    开发工具
  • 107KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 0
    下载次数
  • 2021-04-06 10:52
    上传日期
检测空气中一氧化碳的含量,当超过安全值时实现报警
程序代码.zip
  • 程序代码
  • project
  • main.lst
    13.3KB
  • project_uvopt.bak
    61KB
  • StandarIIC.obj
    6KB
  • uart.lst
    6.5KB
  • project
    56.2KB
  • project.plg
    197B
  • Timer0.lst
    2.1KB
  • project.hex
    18.3KB
  • LCD1602.lst
    3.7KB
  • SHT20.lst
    15.8KB
  • uart2.obj
    12.9KB
  • StandarIIC.lst
    4.1KB
  • main.__i
    93B
  • project.lnp
    133B
  • project.M51
    57.2KB
  • project.uvproj
    13.9KB
  • project_uvproj.bak
    13.6KB
  • uart.__i
    93B
  • uart2.lst
    11.8KB
  • LCD1602.obj
    6.6KB
  • uart2.__i
    96B
  • project.uvopt
    61KB
  • main.obj
    17.2KB
  • SHT20.obj
    13.6KB
  • Timer0.obj
    2.5KB
  • uart.obj
    6.9KB
  • inc
  • StandarIIC.h
    433B
  • SHT20.h
    680B
  • Timer0.h
    129B
  • LCD1602.H
    777B
  • uart2.h
    261B
  • uart.H
    123B
  • src
  • SHT20.c
    10.4KB
  • uart.c
    3.4KB
  • uart2.c.orig
    6.5KB
  • uart2.c
    7.2KB
  • main.c
    7.3KB
  • Timer0.c
    812B
  • LCD1602.c
    1.7KB
  • StandarIIC.c.orig
    1.6KB
  • uart.c.orig
    2.8KB
  • LCD1602.c.orig
    1.4KB
  • StandarIIC.c
    1.5KB
  • main.c.orig
    3.8KB
  • Timer0.c.orig
    698B
内容介绍
/*******底层驱动*************************/ #include "reg52.h" #include "intrins.h" /*******应用层驱动****************************/ #include "SHT20.h" #define uint8_t unsigned char #define uint16_t unsigned int #define SHT21ADDR 0x80 //#define LITTLE_ENDIAN typedef unsigned char u8t; ///< range: 0 .. 255 typedef signed char i8t; ///< range: -128 .. +127 typedef unsigned short u16t; ///< range: 0 .. 65535 typedef signed short i16t; ///< range: -32768 .. +32767 typedef unsigned long u32t; ///< range: 0 .. 4'294'967'295 typedef signed long i32t; ///< range: -2'147'483'648 .. +2'147'483'647 typedef float ft; ///< range: +-1.18E-38 .. +-3.39E+38 typedef double dt; ///< range: .. +-1.79E+308 typedef union { u16t u16; // element specifier for accessing whole u16 i16t i16; // element specifier for accessing whole i16 struct { #ifdef LITTLE_ENDIAN // Byte-order is little endian u8t u8L; // element specifier for accessing low u8 u8t u8H; // element specifier for accessing high u8 #else // Byte-order is big endian u8t u8H; // element specifier for accessing low u8 u8t u8L; // element specifier for accessing high u8 #endif } s16; // element spec. for acc. struct with low or high u8 } nt16; typedef union { u32t u32; // element specifier for accessing whole u32 i32t i32; // element specifier for accessing whole i32 struct { #ifdef LITTLE_ENDIAN // Byte-order is little endian u16t u16L; // element specifier for accessing low u16 u16t u16H; // element specifier for accessing high u16 #else // Byte-order is big endian u16t u16H; // element specifier for accessing low u16 u16t u16L; // element specifier for accessing high u16 #endif } s32; // element spec. for acc. struct with low or high u16 } nt32; // sensor command typedef enum { TRIG_T_MEASUREMENT_HM = 0xE3, // command trig. temp meas. hold master TRIG_RH_MEASUREMENT_HM = 0xE5, // command trig. humidity meas. hold master TRIG_T_MEASUREMENT_POLL = 0xF3, // command trig. temp meas. no hold master TRIG_RH_MEASUREMENT_POLL = 0xF5, // command trig. humidity meas. no hold master USER_REG_W = 0xE6, // command writing user register USER_REG_R = 0xE7, // command reading user register SOFT_RESET = 0xFE // command soft reset } etSHT2xCommand; typedef enum { SHT2x_RES_12_14BIT = 0x00, // RH=12bit, T=14bit SHT2x_RES_8_12BIT = 0x01, // RH= 8bit, T=12bit SHT2x_RES_10_13BIT = 0x80, // RH=10bit, T=13bit SHT2x_RES_11_11BIT = 0x81, // RH=11bit, T=11bit SHT2x_RES_MASK = 0x81 // Mask for res. bits (7,0) in user reg. } etSHT2xResolution; typedef enum { SHT2x_EOB_ON = 0x40, // end of battery SHT2x_EOB_MASK = 0x40, // Mask for EOB bit(6) in user reg. } etSHT2xEob; typedef enum { SHT2x_HEATER_ON = 0x04, // heater on SHT2x_HEATER_OFF = 0x00, // heater off SHT2x_HEATER_MASK = 0x04, // Mask for Heater bit(2) in user reg. } etSHT2xHeater; // measurement signal selection typedef enum { HUMIDITY, TEMP } etSHT2xMeasureType; typedef enum { I2C_ADR_W = 128, // sensor I2C address + write bit I2C_ADR_R = 129 // sensor I2C address + read bit } etI2cHeader; //I2C level typedef enum { LOW = 0, HIGH = 1, } etI2cLevel; //Error codes typedef enum { ACK_ERROR = 0x01, TIME_OUT_ERROR = 0x02, CHECKSUM_ERROR = 0x04, UNIT_ERROR = 0x08 } etError; // CRC #define POLYNOMIAL 0x131 //P(x)=x^8+x^5+x^4+1 = 100110001 //------------------------------------------------------------------------------ u8t SHT2x_CheckCrc(u8t datain[], u8t nbrOfBytes, u8t checksum); u8t SHT2x_ReadUserRegister(u8t *pRegisterValue); u8t SHT2x_WriteUserRegister(u8t *pRegisterValue); u8t SHT2x_MeasurePoll(etSHT2xMeasureType eSHT2xMeasureType, nt16 *pMeasurand); u8t SHT2x_SoftReset(void); float SHT2x_CalcRH(u16t u16sRH); float SHT2x_CalcTemperatureC(u16t u16sT); //u8t SHT2x_GetSerialNumber(u8t u8SerialNumber[]); unsigned char SHT_Temp(float *temp) ; unsigned char SHT_Humi(float *humi) ; //============================================================================== //============================================================================== //FUNCTION NAME: SHT_Temp(); //FUNCTION DESCRIPTION: SHT11??????? //CREATED BY: Arvin HE //INPUT: *temp //OUTPUT: *temp, error //RETURN: error //CREATE DATE: 2010.11.12 09:10 //MODIFY DATE: //REVISION HISTORY: //----------------------------------------------------------------------------- unsigned char SHT_Temp(float *temp) { u8t error = 0; //variable for error code. For codes see system.h nt16 sT; //variable for raw temperature ticks // --- measure temperature with "Polling Mode" (no hold master) --- error |= SHT2x_MeasurePoll(TEMP, &sT); //-- calculate temperature -- *temp = SHT2x_CalcTemperatureC(sT.u16); return error; } //----------------------------------------------------------------------------- //FUNCTION NAME: SHT_Humi(); //FUNCTION DESCRIPTION: SHT11???????,?????????? //CREATED BY: Arvin HE //INPUT: *humi, *temp //OUTPUT: *humi, *temp, error //RETURN: error //CREATE DATE: 2010.11.12 09:10 //MODIFY DATE: //REVISION HISTORY: //----------------------------------------------------------------------------- unsigned char SHT_Humi(float *humi) { u8t error = 0; //variable for error code. For codes see system.h nt16 sRH; //variable for raw humidity ticks // --- measure humidity with "Polling Mode" (no hold master) --- error |= SHT2x_MeasurePoll(HUMIDITY, &sRH); //-- calculate humidity -- *humi = SHT2x_CalcRH(sRH.u16); return error; } //============================================================================== u8t SHT2x_CheckCrc(u8t datain[], u8t nbrOfBytes, u8t checksum) //============================================================================== { u8t bitin; u8t crc = 0; u8t byteCtr; //calculates 8-Bit checksum with given polynomial for (byteCtr = 0; byteCtr < nbrOfBytes; ++byteCtr) { crc ^= (datain[byteCtr]); for (bitin = 8; bitin > 0; --bitin) { if (crc & 0x80) crc = (crc << 1) ^ POLYNOMIAL; else crc = (crc << 1); } } if (crc != checksum) return CHECKSUM_ERROR; else return 0; } //=========================================================================== //u8t SHT2x_ReadUserRegister(u8t *pRegisterValue) ////=========================================================================== //{ // u8t checksum; //variable for checksum byte // u8t error=0; //variable for error code // // IIC_Start(); // error |= IIC_Send_Byte (I2C_ADR_W); // error |= IIC_Send_Byte (USER_REG_R); // IIC_Start(); // error |= IIC_Send_Byte (I2C_ADR_R); // *pRegisterValue = IIC_Read_Byte(OK_ACK); // checksum=IIC_Read_Byte(NO_ACK); // error |= SHT2x_CheckCrc (pRegisterValue,1,checksum); // IIC_Stop(); // return error; //} //=========================================================================== //u8t SHT2x_WriteUserRegister(u8t *pRegisterValue) ////=========================================================================== //{ // p
评论
    相关推荐
    • qitibaojingqi.rar
      家用有毒气体报警器,现场声光报警,信号远传到物业值班室,进行远程报警!
    • aa.rar
      一个报警装置,可燃气体报警器,可以有效的把情况反映出来,效果不错
    • combustible-gas-alarm.zip
      可燃气体报警 单片机 A/D转换 声光报警 继电动作
    • 单片机的气体监测.rar
      用于日常生活中CO气体的检测和报警,设计基于STC89C52为主控芯片,通过专用CO检测传感器MQ-7采集当下气体浓度并转化成电压模拟信号,经过模数转换ADC0832将转换后的数字信号传递给单片机处理。
    • 基于ADUCM360(ARM CORTEX M3)控制的有毒气体CO\SO2等)检测方案-电路方案
      这类检测小巧轻便,方便随身携带,可以检测暴露在环境中的危险气体 CO 的浓度,清晰地读出气体浓度、峰值和高、低浓度报警水平。如果当前气体高、低浓度值超出预设限度值时,仪器以声、光报警提醒用户。多数便携式...
    • 资料汇总 杨秀珠.zip
      在单片机上用C语言实现煤气报警器,一旦煤气浓度超过预制,就会报警
    • 智能家居必备——空气质量检测仪(包括硫化物、颗粒、CO等)-电路方案
      本设计的主要检测对象是室内空气污染中对人体有害的气体,如:硫化物,可吸入颗粒物,一氧化碳,苯和液化气等等。将各传统的空气质量检测模块相关功能可集成可分离单独检测,使得产品的功能更加丰富,更加人性化。该...
    • 基于瑞萨单片机家用燃气报警器电路+源代码+说明文档等-电路方案
      采用瑞萨单片机R7F0C802作为主控制芯片,同时采用TGS5042作为CO传感器等实现家用燃气报警器功能。 报警浓度/时间,采用EN50291欧洲或美国标准设计: 浓度大于50ppm,报警器在60-90分钟内报警; 浓度大于100ppm,报警...
    • 气体传感器 检测 水果 气味
      最近,工控传感器论坛上关于气体传感器的分类的帖子好像颇受欢迎,但是遗憾的是,内容不尽详细,本人在此略谈一二,希望对这一讨论有所裨益!  
    • Proteus7.12.rar
      Proteus7.12完美破解版.rar电路仿真软件很好用可以仿真单片数字模拟电路