描述
<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>
<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;">本次工程主要是做桌面迷你温湿度数显器,其主控采用STM32G030K6T6芯片低功耗设计按键触发,传感器使用盛思锐优秀传感器进行数据采集,用数码管来显示,可以实时采集环境温湿度,测量温度在-5——105度,湿度在0-90度范围内,精度高,体积小,功耗极低等特点。</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;">*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;">原创模仿</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;">完成自己的第一次画电路板,写程序,完成软件的配置和实物的调试工作。</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;"><span style="color: #95a5a6; font-size: 14px;">产品具有低功耗和数显功能,其他我在以后的使用过程中进行升级改造。</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;"><span style="color: #95a5a6; font-size: 14px;">程序使用中断延时等功能。</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;"> </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>
<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;">产品成品3D图如下图:</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;"><img src="//image.lceda.cn/oshwhub/e16471b67b0741c690f214841a33e877.png"></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;"><img src="//image.lceda.cn/oshwhub/da2aba368ba04ca3aa34f40ffce6538b.png"></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;">PCB走线图如下图</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;"><img src="//image.lceda.cn/oshwhub/d04c460bcd5f4f1eb50c8b8d2bd4f440.png"></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;">*5、软件部分</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>
<div>/* USER CODE BEGIN Header */</div>
<div>/**</div>
<div> ******************************************************************************</div>
<div> * @file : main.c</div>
<div> * @brief : Main program body</div>
<div> ******************************************************************************</div>
<div> * @attention</div>
<div> *</div>
<div> * Copyright (c) 2024 STMicroelectronics.</div>
<div> * All rights reserved.</div>
<div> *</div>
<div> * This software is licensed under terms that can be found in the LICENSE file</div>
<div> * in the root directory of this software component.</div>
<div> * If no LICENSE file comes with this software, it is provided AS-IS.</div>
<div> *</div>
<div> ******************************************************************************</div>
<div> */</div>
<div>/* USER CODE END Header */</div>
<div>/* Includes ------------------------------------------------------------------*/</div>
<div>#include "main.h"</div>
<div>#include "adc.h"</div>
<div>#include "i2c.h"</div>
<div>#include "tim.h"</div>
<div>#include "gpio.h"</div>
<div> </div>
<div>/* Private includes ----------------------------------------------------------*/</div>
<div>/* USER CODE BEGIN Includes */</div>
<div> </div>
<div>/* USER CODE END Includes */</div>
<div> </div>
<div>/* Private typedef -----------------------------------------------------------*/</div>
<div>/* USER CODE BEGIN PTD */</div>
<div> </div>
<div>/* USER CODE END PTD */</div>
<div> </div>
<div>/* Private define ------------------------------------------------------------*/</div>
<div>/* USER CODE BEGIN PD */</div>
<div> </div>
<div>/* USER CODE END PD */</div>
<div> </div>
<div>/* Private macro -------------------------------------------------------------*/</div>
<div>/* USER CODE BEGIN PM */</div>
<div> </div>
<div>/* USER CODE END PM */</div>
<div> </div>
<div>/* Private variables ---------------------------------------------------------*/</div>
<div> </div>
<div>/* USER CODE BEGIN PV */</div>
<div> </div>
<div>/* USER CODE END PV */</div>
<div> </div>
<div>/* Private function prototypes -----------------------------------------------*/</div>
<div>void SystemClock_Config(void);</div>
<div>/* USER CODE BEGIN PFP */</div>
<div> </div>
<div>/* USER CODE END PFP */</div>
<div> </div>
<div>/* Private user code ---------------------------------------------------------*/</div>
<div>/* USER CODE BEGIN 0 */</div>
<div>struct DEVICE_PARAMTER device_paramter = {0};</div>
<div>/* USER CODE END 0 */</div>
<div> </div>
<div>/**</div>
<div> * @brief The application entry point.</div>
<div> * @retval int</div>
<div> */</div>
<div>int main(void)</div>
<div>{</div>
<div> /* USER CODE BEGIN 1 */</div>
<div>float temperature = 0;</div>
<div>float humidity = 0;</div>
<div> /* USER CODE END 1 */</div>
<div> </div>
<div> /* MCU Configuration--------------------------------------------------------*/</div>
<div> </div>
<div> /* Reset of all peripherals, Initializes the Flash interface and the Systick. */</div>
<div> HAL_Init();</div>
<div> </div>
<div> /* USER CODE BEGIN Init */</div>
<div> </div>
<div> /* USER CODE END Init */</div>
<div> </div>
<div> /* Configure the system clock */</div>
<div> SystemClock_Config();</div>
<div> </div>
<div> /* USER CODE BEGIN SysInit */</div>
<div>HAL_DeInit();</div>
<div> /* USER CODE END SysInit */</div>
<div> </div>
<div> /* Initialize all configured peripherals */</div>
<div> MX_GPIO_Init();</div>
<div> MX_ADC1_Init();</div>
<div> MX_I2C1_Init();</div>
<div> MX_TIM14_Init();</div>
<div> /* USER CODE BEGIN 2 */</div>
<div>HAL_Delay(100);</div>
<div> SN74HC595_Send_Data(SN_DIG,0xFF); //¹Ø±ÕÊýÂë¹ÜÏÔʾ</div>
<div> SN74HC595_Send_Data(SN_LED1,0x00);</div>
<div> SN74HC595_Send_Data(SN_LED2,0x00);</div>
<div> </div>
<div> /* USER CODE END 2 */</div>
<div>HAL_SuspendTick();//ÔÝÍ£µÎ´ð¶¨Ê±Æ÷£¬·Àֹͨ¹ýµÎ´ð¶¨Ê±Æ÷Öжϻ½ÐÑ</div>
<div>HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /* Ö´ÐÐWFIÖ¸Áî, ½øÈë˯Ãßģʽ */</div>
<div> /* Infinite loop */</div>
<div> /* USER CODE BEGIN WHILE */</div>
<div> while (1)</div>
<div> {</div>
<div> /* USER CODE END WHILE */</div>
<div> </div>
<div> /* USER CODE BEGIN 3 */</div>
<div>if(device_paramter.KeyStatus == KEY_SHAKE_STATE)</div>
<div>{</div>
<div>HAL_Delay(10);</div>
<div>if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_5) == GPIO_PIN_RESET)</div>
<div>{</div>
<div>while(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_5) == GPIO_PIN_RESET);</div>
<div> </div>
<div>SHT40_Read_RHData(&temperature,&humidity);//¶ÁÈ¡ÎÂʪ¶È</div>
<div>device_paramter.Temp = temperature * 10;//·Å´óÎÂʪ¶È</div>
<div>device_paramter.Humi = humidity * 10;</div>
<div>HAL_TIM_Base_Start_IT(&htim14); //¿ªÊ¼¶¨Ê±Æ÷£¬ÏÔʾÁ½´ÎÊý¾Ý </div>
<div>device_paramter.sleepStatus = 0;//Çå³ýÐÝÃß±êÖ¾</div>
<div>device_paramter.KeyStatus = KEY_NO_PRESS;//Çå³ý°´Ï±êÖ¾</div>
<div>}</div>
<div>}</div>
<div>else if(device_paramter.sleepStatus == 1)//ÏÔʾ½áÊø£¬½øÈëÐÝÃß</div>
<div>{</div>
<div>HAL_SuspendTick();//ÔÝÍ£µÎ´ð¶¨Ê±Æ÷£¬·Àֹͨ¹ýµÎ´ð¶¨Ê±Æ÷Öжϻ½ÐÑ</div>
<div>HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /* Ö´ÐÐWFIÖ¸Áî, ½øÈë˯Ãßģʽ */</div>
<div>}</div>
<div> }</div>
<div> /* USER CODE END 3 */</div>
<div>}</div>
<div> </div>
<div>/**</div>
<div> * @brief System Clock Configuration</div>
<div> * @retval None</div>
<div> */</div>
<div>void SystemClock_Config(void)</div>
<div>{</div>
<div> RCC_OscInitTypeDef RCC_OscInitStruct = {0};</div>
<div> RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};</div>
<div> </div>
<div> /** Configure the main internal regulator output voltage</div>
<div> */</div>
<div> HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);</div>
<div> </div>
<div> /** Initializes the RCC Oscillators according to the specified parameters</div>
<div> * in the RCC_OscInitTypeDef structure.</div>
<div> */</div>
<div> RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;</div>
<div> RCC_OscInitStruct.HSIState = RCC_HSI_ON;</div>
<div> RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;</div>
<div> RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;</div>
<div> RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;</div>
<div> RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;</div>
<div> RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;</div>
<div> RCC_OscInitStruct.PLL.PLLN = 8;</div>
<div> RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;</div>
<div> RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;</div>
<div> if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)</div>
<div> {</div>
<div> Error_Handler();</div>
<div> }</div>
<div> </div>
<div> /** Initializes the CPU, AHB and APB buses clocks</div>
<div> */</div>
<div> RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK</div>
<div> |RCC_CLOCKTYPE_PCLK1;</div>
<div> RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;</div>
<div> RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;</div>
<div> RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;</div>
<div> </div>
<div> if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)</div>
<div> {</div>
<div> Error_Handler();</div>
<div> }</div>
<div>}</div>
<div> </div>
<div>/* USER CODE BEGIN 4 */</div>
<div> </div>
<div>/* USER CODE END 4 */</div>
<div> </div>
<div>/**</div>
<div> * @brief This function is executed in case of error occurrence.</div>
<div> * @retval None</div>
<div> */</div>
<div>void Error_Handler(void)</div>
<div>{</div>
<div> /* USER CODE BEGIN Error_Handler_Debug */</div>
<div> /* User can add his own implementation to report the HAL error return state */</div>
<div> __disable_irq();</div>
<div> while (1)</div>
<div> {</div>
<div> }</div>
<div> /* USER CODE END Error_Handler_Debug */</div>
<div>}</div>
<div> </div>
<div>#ifdef USE_FULL_ASSERT</div>
<div>/**</div>
<div> * @brief Reports the name of the source file and the source line number</div>
<div> * where the assert_param error has occurred.</div>
<div> * @param file: pointer to the source file name</div>
<div> * @param line: assert_param error line source number</div>
<div> * @retval None</div>
<div> */</div>
<div>void assert_failed(uint8_t *file, uint32_t line)</div>
<div>{</div>
<div> /* USER CODE BEGIN 6 */</div>
<div> /* User can add his own implementation to report the file name and line number,</div>
<div> ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */</div>
<div> /* USER CODE END 6 */</div>
<div>}</div>
<div>#endif /* USE_FULL_ASSERT */</div>
<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>
<span style="color: #95a5a6; font-size: 14px;"> </span>
<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;"><img src="//image.lceda.cn/oshwhub/6427885554464a358a88bd336991b693.png"></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;"><img src="//image.lceda.cn/oshwhub/743a5b08e9024175bd03faafc33879ab.png"></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>
<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;"><img src="//image.lceda.cn/oshwhub/3af843e948674c829b747ecc55d06230.png" alt="LOGO" width="628" height="502"></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>
<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;">视频在附件里MP4文件</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;"> </p>
</div>
评论(0)