蓝色天使 发表于 2021-7-18 09:58

智能燃气泄漏报警器

<p style="text-align: center;"><span style="font-family:Microsoft YaHei;"><strong><span style="font-size:10.5pt"><span style="font-size:16.0pt">智能燃气泄漏报警器</span></span></strong></span></p>

<p align="center" style="text-align:center">&nbsp;</p>

<p align="right" style="text-align:right"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="word-break:break-all"><b><span style="font-size:14.0pt">作者:蓝色天使 </span>&nbsp; </b></span></span></span></p>

<p><span style="font-family:Microsoft YaHei;">五月下旬拿到板子,只把硬件和数据采集调通。蓝牙以及aap数据上传没有做。现将完成部分提交。<span style="font-size:10.5pt"><span style="word-break:break-all"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="font-size:16.0pt">一、作品简介</span><br />
<span style="font-size:12.0pt">(智能燃气泄漏报警器基于TGS813可燃气体传感器感知空气中燃气浓度转换对应的电阻值,RSL10蓝牙开发板通过IIC接口,用高精度AD MCP3421将传感器电阻值转换燃气浓度值,进行判断。超出安全值,通过无线蓝牙发送至手机告知用户通风检查。</span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="font-size:16.0pt">二、系统框图</span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="font-weight:normal">软件架构:</span><span lang="EN-US"><span style="font-weight:normal">RSL10 </span></span><span style="font-weight:normal">系统初始化之后</span> <span style="font-weight:normal">(包含系统时钟,定时器,蓝牙,</span><span lang="EN-US"><span style="font-weight:normal">IIC</span></span><span style="font-weight:normal">接口)。系统进入休眠状态每隔</span><span lang="EN-US"><span style="font-weight:normal">5</span></span><span style="font-weight:normal">分钟(这个时间可以通过手机</span><span lang="EN-US"><span style="font-weight:normal">APP</span></span><span style="font-weight:normal">自行设定)定时器中断唤醒主机采集一次数据,通过蓝牙发给手机。手机对数据进行判断,如果异常提醒用户。</span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="font-size:16.0pt">三、各部分功能说明</span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt">电源部分:将AC220V转换为DC15V:</span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt">传感器&amp;ADC部分:该部分就是为可燃性气体传感器TGS813提供电源系统(按照DATASHEET操作)为AD采集提供条件;然后通过IIC接口与RSL10I蓝牙版IIC接口通信</span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="font-size:16.0pt">四、作品源码</span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="font-size:12.0pt"><span style="font-weight:normal">目前因为蓝牙部分还没有调通,传感器部分是在STM32F103RCT6上调试的。现将传感器采集部分展示出来:</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">IIC</span></span><span style="font-size:12.0pt"><span style="font-weight:normal">接口初始化:</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/**</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; ******************************************************************************</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; * File Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;: I2C.c</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; * Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;: This file provides code for the configuration</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of the I2C instances.</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; ******************************************************************************</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; * <a href="home.php?mod=space&amp;uid=1020061" target="_blank">@attention</a> </span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; *</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; * &lt;h2&gt;&lt;center&gt;&amp;copy; Copyright (c) 2020 STMicroelectronics.</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; * All rights reserved.&lt;/center&gt;&lt;/h2&gt;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; *</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; * This software component is licensed by ST under BSD 3-Clause license,</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; * the &quot;License&quot;; You may not use this file except in compliance with the</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; * License. You may obtain a copy of the License at:</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; *&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opensource.org/licenses/BSD-3-Clause</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; *</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; ******************************************************************************</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/* Includes ------------------------------------------------------------------*/</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">#include &quot;i2c.h&quot;</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/* USER CODE BEGIN 0 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/* USER CODE END 0 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">I2C_HandleTypeDef hi2c1;</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/* I2C1 init function */</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">void MX_I2C1_Init(void)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">{</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Instance = I2C1;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Init.ClockSpeed = 100000;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Init.OwnAddress1 = 0;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Init.OwnAddress2 = 0;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; if (HAL_I2C_Init(&amp;hi2c1) != HAL_OK)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; {</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; Error_Handler();</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; }</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">}</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">{</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; GPIO_InitTypeDef GPIO_InitStruct = {0};</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; if(i2cHandle-&gt;Instance==I2C1)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; {</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; /* USER CODE BEGIN I2C1_MspInit 0 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; /* USER CODE END I2C1_MspInit 0 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; __HAL_RCC_GPIOB_CLK_ENABLE();</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; /**I2C1 GPIO Configuration</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; PB6&nbsp;&nbsp;&nbsp;&nbsp; ------&gt; I2C1_SCL</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; PB7&nbsp;&nbsp;&nbsp;&nbsp; ------&gt; I2C1_SDA</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; */</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; HAL_GPIO_Init(GPIOB, &amp;GPIO_InitStruct);</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; /* I2C1 clock enable */</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; __HAL_RCC_I2C1_CLK_ENABLE();</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; /* USER CODE BEGIN I2C1_MspInit 1 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; /* USER CODE END I2C1_MspInit 1 */</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; }</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">}</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">{</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; if(i2cHandle-&gt;Instance==I2C1)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; {</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; /* USER CODE BEGIN I2C1_MspDeInit 0 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; /* USER CODE END I2C1_MspDeInit 0 */</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; /* Peripheral clock disable */</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; __HAL_RCC_I2C1_CLK_DISABLE();</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; /**I2C1 GPIO Configuration</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; PB6&nbsp;&nbsp;&nbsp;&nbsp; ------&gt; I2C1_SCL</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; PB7&nbsp;&nbsp;&nbsp;&nbsp; ------&gt; I2C1_SDA</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; */</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp; HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; /* USER CODE BEGIN I2C1_MspDeInit 1 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; /* USER CODE END I2C1_MspDeInit 1 */</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; }</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">}</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/* USER CODE BEGIN 1 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/* USER CODE END 1 */</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">MCP3421</span></span><span style="font-size:12.0pt"><span style="font-weight:normal">采集:</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">#include &quot;mcp3421.h&quot;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">#include &quot;usart.h&quot;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">#include &quot;i2c.h&quot;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/***************************************************************************/</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">void MCP3421_Init(void)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">{</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp; if(HAL_I2C_IsDeviceReady(&amp;hi2c1,MCP3421ADDR,5,100)==HAL_OK)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">//&nbsp;&nbsp; &nbsp;&nbsp; if(!HAL_I2C_IsDeviceReady(&amp;hi2c1,MCP3421ADDR,5,100))</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp; {</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp; printf(&quot;MCP3421 is ok.\n\r&quot;);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp; }</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;else</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;{</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; printf(&quot;MCP3421 is error.\n\r&quot;);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;}</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;uint8_t parameter = 0x9c;&nbsp; //</span></span><span style="font-size:12.0pt"><span style="font-weight:normal">系统参数配置为18位精度,自动转换模式,无PGA增益。配置字见数据手册。</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;HAL_I2C_Master_Transmit(&amp;hi2c1,MCP3421ADDR,&amp;parameter,1,100);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;HAL_Delay(5);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;while(HAL_I2C_IsDeviceReady(&amp;hi2c1,MCP3421ADDR,5,100))</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;{</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; HAL_Delay(5);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;}</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;printf (&quot;MCP3421 RESET is OK.\n\r&quot;);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">}</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/************************************************************************/</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">uint32_t MCP3421_Get_Value(void)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">{</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; uint32_t ADC_Value;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uint8_t Adc_Temp={0};</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; if(HAL_I2C_IsDeviceReady(&amp;hi2c1,MCP3421ADDR,5,100)==HAL_OK)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HAL_I2C_Master_Receive(&amp;hi2c1,MCP3421ADDR,Adc_Temp,3,100);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADC_Value = Adc_Temp;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADC_Value&amp;=0x03;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADC_Value&lt;&lt;=8;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADC_Value+= Adc_Temp;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADC_Value&lt;&lt;=8;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADC_Value+= Adc_Temp;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return&nbsp; ADC_Value;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">}</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/*****************************************************************/</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">void Voltage_Convert(void)</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">{</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp; uint32_t&nbsp; Voltage;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float Measure;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Voltage = MCP3421_Get_Value();</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Voltage = %d\n\r&quot;,Voltage);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if((Voltage&amp;0x00020000)==0x00020000)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //</span></span><span style="font-size:12.0pt"><span style="font-weight:normal">判断最高位符号位是否为为1;为&ldquo;1&rdquo;则为负电压</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Voltage&amp;=0x0001ffff;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Voltage=(~Voltage)+1;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Voltage &amp;=0x0001ffff; </span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Measure = 15.625*Voltage;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //15.625</span></span><span style="font-size:12.0pt"><span style="font-weight:normal">为18位分辨率的精度。其他分辨率的精度见数据手册。</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Measure = Measure *0.001;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Measure Result Voltage = -%fmv\n\r&quot;,Measure);</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //</span></span><span style="font-size:12.0pt"><span style="font-weight:normal">为&ldquo;0&rdquo;则正电压直接转换</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Voltage&amp;=0x0001ffff;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Measure = 15.625*Voltage;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Measure = Measure *0.001;</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Measure Result Voltage = %fmv\n\r&quot;,Measure); </span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">}</span></span></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span lang="EN-US" style="font-size:12.0pt"><span style="font-weight:normal">/******************************************************/</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><strong><span style="font-size:10.5pt"><span style="font-size:16.0pt">五、作品功能演示视频</span></span></strong></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="font-size:12.0pt"><span style="font-weight:normal">(暂无)</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><b><span style="font-size:16.0pt">六、项目总结</span></b></span></span></p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><span style="font-size:12.0pt"><span style="font-weight:normal">(暂无)</span></span></span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify"><span style="font-family:Microsoft YaHei;"><span style="font-size:10.5pt"><b><span style="font-size:16.0pt">七、其他</span></b></span></span></p>

<p style="text-align:justify"><br />
&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>
页: [1]
查看完整版本: 智能燃气泄漏报警器