|
STM32寫的測溫代碼
- #include "stm32f4xx.h"
- #include "led.h"
- #include "key.h"
- #include "exti.h"
- #include "delay.h"
- #include "usart.h"
- #include "adc.h"
- #include "tim.h"
- #include "dht11.h"
- #include "GY90614_Iic.h"
- #include "rtc.h"
- #include "function.h"
- #include "flash.h"
- #include "beep.h"
- int main(void)
- {
-
- //設置NVIC分組(一個項目只能配置一次)
- //NVIC第二分組:搶占優先級范圍:0~3 響應優先級范圍:0~3
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
-
- Delay_Init();
- Led_Init();//LED初始化
- Key_Init();//按鍵初始化
-
- //中斷初始化
- Exti_KEY_Init();
- Usart1_Init(115200);
- Oled_Iic_Init(); //OLED初始化
-
- OLED_Init(); //要先供電,才能初始化
-
-
-
- ADC1_Init();
- DMA_Config();
- Tim3_Init();
- ADC_SoftwareStartConv(ADC1);
-
-
- Dht11_Init(); //DHT11采集溫濕度初始化
- GY90614_Iic_Init(); //GY90614紅外測溫模塊初始化
-
- OLED_CLS(); //清屏
- delay_ms(1800); //這個延時時間(加上上面初始化的總時間)決定KEY1按鍵時長,小于可正常進入由待命模式變為運行模式,在待命模式下大于這個延時可能會重復進入待命模式
- Rtc_Init();
- Beep_Init();
-
- Flash_Read(0x08020000, &Safe_T, 1); //每次復位后,從flash讀取報警溫度
-
- while(1)
- {
- Home_Display(); //開機顯示的主界面(時間和實時時間)
- delay_s(1);
-
- }
- return 0;
- }
復制代碼
|
-
-
程序.7z
2024-10-7 22:58 上傳
點擊文件名下載附件
52.97 KB, 下載次數: 0
代碼
|