描述
<div class="document">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">注:* 为必填项</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><strong><span style="color: #0093e6;">请在报名阶段填写 ↓</span></strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">* 1、项目功能介绍</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">该设计用于检测环境的温度和湿度。用SHT40高精度温湿度传感器模块,实现对温湿度的检测。</span></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*2、项目属性</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">非原创,无获奖和答辩情况</span></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">* 3、开源协议</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">Public Domain</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<p style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><strong><span style="color: #0093e6;">请在竞赛阶段填写 ↓</span></strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*4、硬件部分</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*5、软件部分</h3>
<hr class="horizontal-splitline normal-bold-2">
<p>/* USER CODE BEGIN Header */<br>/**<br> ******************************************************************************<br> * @file : main.c<br> * @brief : Main program body<br> ******************************************************************************<br> * @attention<br> *<br> * Copyright (c) 2024 STMicroelectronics.<br> * All rights reserved.<br> *<br> * This software is licensed under terms that can be found in the LICENSE file<br> * in the root directory of this software component.<br> * If no LICENSE file comes with this software, it is provided AS-IS.<br> *<br> ******************************************************************************<br> */<br>/* USER CODE END Header */<br>/* Includes ------------------------------------------------------------------*/<br>#include "main.h"<br>#include "adc.h"<br>#include "i2c.h"<br>#include "tim.h"<br>#include "gpio.h"</p>
<p>/* Private includes ----------------------------------------------------------*/<br>/* USER CODE BEGIN Includes */</p>
<p>/* USER CODE END Includes */</p>
<p>/* Private typedef -----------------------------------------------------------*/<br>/* USER CODE BEGIN PTD */</p>
<p>/* USER CODE END PTD */</p>
<p>/* Private define ------------------------------------------------------------*/<br>/* USER CODE BEGIN PD */</p>
<p>/* USER CODE END PD */</p>
<p>/* Private macro -------------------------------------------------------------*/<br>/* USER CODE BEGIN PM */</p>
<p>/* USER CODE END PM */</p>
<p>/* Private variables ---------------------------------------------------------*/</p>
<p>/* USER CODE BEGIN PV */</p>
<p>/* USER CODE END PV */</p>
<p>/* Private function prototypes -----------------------------------------------*/<br>void SystemClock_Config(void);<br>/* USER CODE BEGIN PFP */</p>
<p>/* USER CODE END PFP */</p>
<p>/* Private user code ---------------------------------------------------------*/<br>/* USER CODE BEGIN 0 */<br>struct DEVICE_PARAMTER device_paramter = {0};<br>/* USER CODE END 0 */</p>
<p>/**<br> * @brief The application entry point.<br> * @retval int<br> */<br>int main(void)<br>{<br> /* USER CODE BEGIN 1 */<br> float temperature = 0; <br> float humidity = 0;<br> /* USER CODE END 1 */</p>
<p> /* MCU Configuration--------------------------------------------------------*/</p>
<p> /* Reset of all peripherals, Initializes the Flash interface and the Systick. */<br> HAL_Init();</p>
<p> /* USER CODE BEGIN Init */</p>
<p> /* USER CODE END Init */</p>
<p> /* Configure the system clock */<br> SystemClock_Config();</p>
<p> /* USER CODE BEGIN SysInit */<br> HAL_DeInit();<br> /* USER CODE END SysInit */</p>
<p> /* Initialize all configured peripherals */<br> MX_GPIO_Init(); <br> MX_ADC1_Init();<br> MX_I2C1_Init();<br> MX_TIM14_Init();<br> /* USER CODE BEGIN 2 */<br> HAL_Delay(100);<br> SN74HC595_Send_Data(SN_DIG,0xFF); //¹Ø±ÕÊýÂë¹ÜÏÔʾ<br> SN74HC595_Send_Data(SN_LED1,0x00);<br> SN74HC595_Send_Data(SN_LED2,0x00);<br> <br> /* USER CODE END 2 */<br> HAL_SuspendTick(); //ÔÝÍ£µÎ´ð¶¨Ê±Æ÷£¬·Àֹͨ¹ýµÎ´ð¶¨Ê±Æ÷Öжϻ½ÐÑ<br> HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /* Ö´ÐÐWFIÖ¸Áî, ½øÈë˯Ãßģʽ */<br> /* Infinite loop */<br> /* USER CODE BEGIN WHILE */<br> while (1)<br> {<br> /* USER CODE END WHILE */</p>
<p> /* USER CODE BEGIN 3 */<br> if(device_paramter.KeyStatus == KEY_SHAKE_STATE)<br> {<br> HAL_Delay(10);<br> if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_5) == GPIO_PIN_RESET)<br> {<br> while(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_5) == GPIO_PIN_RESET);<br> <br> SHT40_Read_RHData(&temperature,&humidity); //¶ÁÈ¡ÎÂʪ¶È<br> device_paramter.Temp = temperature * 10; //·Å´óÎÂʪ¶È<br> device_paramter.Humi = humidity * 10;<br> HAL_TIM_Base_Start_IT(&htim14); //¿ªÊ¼¶¨Ê±Æ÷£¬ÏÔʾÁ½´ÎÊý¾Ý <br> device_paramter.sleepStatus = 0; //Çå³ýÐÝÃß±êÖ¾<br> device_paramter.KeyStatus = KEY_NO_PRESS; //Çå³ý°´Ï±êÖ¾<br> }<br> }<br> else if(device_paramter.sleepStatus == 1) //ÏÔʾ½áÊø£¬½øÈëÐÝÃß<br> {<br> HAL_SuspendTick(); //ÔÝÍ£µÎ´ð¶¨Ê±Æ÷£¬·Àֹͨ¹ýµÎ´ð¶¨Ê±Æ÷Öжϻ½ÐÑ<br> HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /* Ö´ÐÐWFIÖ¸Áî, ½øÈë˯Ãßģʽ */<br> }<br> }<br> /* USER CODE END 3 */<br>}</p>
<p>/**<br> * @brief System Clock Configuration<br> * @retval None<br> */<br>void SystemClock_Config(void)<br>{<br> RCC_OscInitTypeDef RCC_OscInitStruct = {0};<br> RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};</p>
<p> /** Configure the main internal regulator output voltage<br> */<br> HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);</p>
<p> /** Initializes the RCC Oscillators according to the specified parameters<br> * in the RCC_OscInitTypeDef structure.<br> */<br> RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;<br> RCC_OscInitStruct.HSIState = RCC_HSI_ON;<br> RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;<br> RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;<br> RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;<br> RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;<br> RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;<br> RCC_OscInitStruct.PLL.PLLN = 8;<br> RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;<br> RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;<br> if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)<br> {<br> Error_Handler();<br> }</p>
<p> /** Initializes the CPU, AHB and APB buses clocks<br> */<br> RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK<br> |RCC_CLOCKTYPE_PCLK1;<br> RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;<br> RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;<br> RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;</p>
<p> if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)<br> {<br> Error_Handler();<br> }<br>}</p>
<p>/* USER CODE BEGIN 4 */</p>
<p>/* USER CODE END 4 */</p>
<p>/**<br> * @brief This function is executed in case of error occurrence.<br> * @retval None<br> */<br>void Error_Handler(void)<br>{<br> /* USER CODE BEGIN Error_Handler_Debug */<br> /* User can add his own implementation to report the HAL error return state */<br> __disable_irq();<br> while (1)<br> {<br> }<br> /* USER CODE END Error_Handler_Debug */<br>}</p>
<p>#ifdef USE_FULL_ASSERT<br>/**<br> * @brief Reports the name of the source file and the source line number<br> * where the assert_param error has occurred.<br> * @param file: pointer to the source file name<br> * @param line: assert_param error line source number<br> * @retval None<br> */<br>void assert_failed(uint8_t *file, uint32_t line)<br>{<br> /* USER CODE BEGIN 6 */<br> /* User can add his own implementation to report the file name and line number,<br> ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */<br> /* USER CODE END 6 */<br>}<br>#endif /* USE_FULL_ASSERT */</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*6、BOM清单</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*7、大赛LOGO验证</h3>
<hr class="horizontal-splitline normal-bold-2">
<p style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/703e112b0bc74b9da664b7ff8e620115.jpg" alt="" width="1162" height="737"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">* 8、演示您的项目并录制成视频上传</h3>
<hr class="horizontal-splitline normal-bold-2">
<p style="line-height: 1.8;">如附件所示</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="font-size: 14px;"><a href="/posts/de460543d4cf4dacb5f0326612455578" target="_blank">前往查看更多详情 ></a></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
</div>
评论(0)