描述
<p><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;">注:<em> 为必填项</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;"></em> 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;"><em>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;"></em> 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;"><em>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;"></em>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>/<em> USER CODE BEGIN Header </em>/</div>
<div>/<strong></div>
<div> <strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>****</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></div>
<div> <em> @file : main.c</div>
<div> </em> @brief : Main program body</div>
<div> <strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></div>
<div> <em> @attention</div>
<div> </em></div>
<div> <em> Copyright (c) 2024 STMicroelectronics.</div>
<div> </em> All rights reserved.</div>
<div> <em></div>
<div> </em> This software is licensed under terms that can be found in the LICENSE file</div>
<div> <em> in the root directory of this software component.</div>
<div> </em> If no LICENSE file comes with this software, it is provided AS-IS.</div>
<div> *</div>
<div> <strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>**</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></div>
<div> <em>/</div>
<div>/</em> USER CODE END Header <em>/</div>
<div>/</em> Includes ------------------------------------------------------------------<em>/</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>/</em> Private includes ----------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN Includes <em>/</div>
<div> </div>
<div>/</em> USER CODE END Includes <em>/</div>
<div> </div>
<div>/</em> Private typedef -----------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN PTD <em>/</div>
<div> </div>
<div>/</em> USER CODE END PTD <em>/</div>
<div> </div>
<div>/</em> Private define ------------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN PD <em>/</div>
<div> </div>
<div>/</em> USER CODE END PD <em>/</div>
<div> </div>
<div>/</em> Private macro -------------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN PM <em>/</div>
<div> </div>
<div>/</em> USER CODE END PM <em>/</div>
<div> </div>
<div>/</em> Private variables ---------------------------------------------------------<em>/</div>
<div> </div>
<div>/</em> USER CODE BEGIN PV <em>/</div>
<div> </div>
<div>/</em> USER CODE END PV <em>/</div>
<div> </div>
<div>/</em> Private function prototypes -----------------------------------------------<em>/</div>
<div>void SystemClock_Config(void);</div>
<div>/</em> USER CODE BEGIN PFP <em>/</div>
<div> </div>
<div>/</em> USER CODE END PFP <em>/</div>
<div> </div>
<div>/</em> Private user code ---------------------------------------------------------<em>/</div>
<div>/</em> USER CODE BEGIN 0 <em>/</div>
<div>struct DEVICE_PARAMTER device_paramter = {0};</div>
<div>/</em> USER CODE END 0 */</div>
<div> </div>
<div>/<strong></div>
<div> <em> @brief The application entry point.</div>
<div> </em> @retval int</div>
<div> <em>/</div>
<div>int main(void)</div>
<div>{</div>
<div> /</em> USER CODE BEGIN 1 <em>/</div>
<div>float temperature = 0;</div>
<div>float humidity = 0;</div>
<div> /</em> USER CODE END 1 <em>/</div>
<div> </div>
<div> /</em> MCU Configuration--------------------------------------------------------<em>/</div>
<div> </div>
<div> /</em> Reset of all peripherals, Initializes the Flash interface and the Systick. <em>/</div>
<div> HAL_Init();</div>
<div> </div>
<div> /</em> USER CODE BEGIN Init <em>/</div>
<div> </div>
<div> /</em> USER CODE END Init <em>/</div>
<div> </div>
<div> /</em> Configure the system clock <em>/</div>
<div> SystemClock_Config();</div>
<div> </div>
<div> /</em> USER CODE BEGIN SysInit <em>/</div>
<div>HAL_DeInit();</div>
<div> /</em> USER CODE END SysInit <em>/</div>
<div> </div>
<div> /</em> Initialize all configured peripherals <em>/</div>
<div> MX_GPIO_Init();</div>
<div> MX_ADC1_Init();</div>
<div> MX_I2C1_Init();</div>
<div> MX_TIM14_Init();</div>
<div> /</em> USER CODE BEGIN 2 <em>/</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> /</em> USER CODE END 2 <em>/</div>
<div>HAL_SuspendTick();//ÔÝÍ£µÎ´ð¶¨Ê±Æ÷£¬·Àֹͨ¹ýµÎ´ð¶¨Ê±Æ÷Öжϻ½ÐÑ</div>
<div>HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); /</em> Ö´ÐÐWFIÖ¸Áî, ½øÈë˯Ãßģʽ <em>/</div>
<div> /</em> Infinite loop <em>/</div>
<div> /</em> USER CODE BEGIN WHILE <em>/</div>
<div> while (1)</div>
<div> {</div>
<div> /</em> USER CODE END WHILE <em>/</div>
<div> </div>
<div> /</em> USER CODE BEGIN 3 <em>/</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 </em> 10;//·Å´óÎÂʪ¶È</div>
<div>device_paramter.Humi = humidity <em> 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); /</em> Ö´ÐÐWFIÖ¸Áî, ½øÈë˯Ãßģʽ <em>/</div>
<div>}</div>
<div> }</div>
<div> /</em> USER CODE END 3 */</div>
<div>}</div>
<div> </div>
<div>/*<em></div>
<div> </em> @brief System Clock Configuration</div>
<div> <em> @retval None</div>
<div> </em>/</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> /</strong> Configure the main internal regulator output voltage</div>
<div> */</div>
<div> HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);</div>
<div> </div>
<div> /<strong> Initializes the RCC Oscillators according to the specified parameters</div>
<div> <em> in the RCC_OscInitTypeDef structure.</div>
<div> </em>/</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> /</strong> Initializes the CPU, AHB and APB buses clocks</div>
<div> <em>/</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>/</em> USER CODE BEGIN 4 <em>/</div>
<div> </div>
<div>/</em> USER CODE END 4 */</div>
<div> </div>
<div>/*<em></div>
<div> </em> @brief This function is executed in case of error occurrence.</div>
<div> <em> @retval None</div>
<div> </em>/</div>
<div>void Error_Handler(void)</div>
<div>{</div>
<div> /<em> USER CODE BEGIN Error_Handler_Debug </em>/</div>
<div> /<em> User can add his own implementation to report the HAL error return state </em>/</div>
<div> __disable_irq();</div>
<div> while (1)</div>
<div> {</div>
<div> }</div>
<div> /<em> USER CODE END Error_Handler_Debug </em>/</div>
<div>}</div>
<div> </div>
<div>#ifdef USE_FULL_ASSERT</div>
<div>/*<em></div>
<div> </em> @brief Reports the name of the source file and the source line number</div>
<div> <em> where the assert_param error has occurred.</div>
<div> </em> @param file: pointer to the source file name</div>
<div> <em> @param line: assert_param error line source number</div>
<div> </em> @retval None</div>
<div> <em>/</div>
<div>void assert_failed(uint8_t </em>file, uint32_t line)</div>
<div>{</div>
<div> /<em> USER CODE BEGIN 6 </em>/</div>
<div> /<em> 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) </em>/</div>
<div> /<em> USER CODE END 6 </em>/</div>
<div>}</div>
<div>#endif /<em> USE_FULL_ASSERT </em>/</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;"><em>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;"></em>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></p>
评论(0)