在两次传感器读取期间关闭 GPIO 时钟以降低功耗
This commit is contained in:
parent
633d780c8e
commit
177f127cb3
@ -1,14 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* @file main.c
|
* @file main.c
|
||||||
* @author Myth
|
* @author Myth
|
||||||
* @version 0.6
|
* @version 0.7
|
||||||
* @date 2021.10.15
|
* @date 2021.10.15
|
||||||
* @brief 工程主函数文件
|
* @brief 工程主函数文件
|
||||||
* @details 初始化及主循环
|
* @details 初始化及主循环
|
||||||
* @note 此版本实现功能:
|
* @note 此版本实现功能:
|
||||||
* 串口回显,回显时 PC13 上的 LED 闪烁
|
* 串口回显,回显时 PC13 上的 LED 闪烁
|
||||||
* AHT20 温度湿度读取及 BH1750 光照度读取
|
* AHT20 温度湿度读取及 BH1750 光照度读取
|
||||||
* 此版本实现了 AHT20 和 BH1750 的最高速读取。每一次读取结束后 LED 闪烁
|
* 此版本 AHT20 和 BH1750 在两次读取期间关闭 GPIO 时钟以降低功耗。每一次读取结束后 LED 闪烁
|
||||||
* JTAG 已禁用,请使用 SWD 调试
|
* JTAG 已禁用,请使用 SWD 调试
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -16,8 +16,6 @@
|
|||||||
#include "systick.h"
|
#include "systick.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
|
||||||
#include "softi2c.h"
|
|
||||||
|
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "aht20.h"
|
#include "aht20.h"
|
||||||
#include "bh1750.h"
|
#include "bh1750.h"
|
||||||
@ -48,6 +46,8 @@ int main(void)
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
//程序主循环
|
//程序主循环
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE(); //开启 GPIOB 时钟
|
||||||
|
|
||||||
AHT20_Start(); // AHT20 开始测量
|
AHT20_Start(); // AHT20 开始测量
|
||||||
BH1750_Start(); // BH1750 开始测量
|
BH1750_Start(); // BH1750 开始测量
|
||||||
|
|
||||||
@ -61,6 +61,10 @@ int main(void)
|
|||||||
|
|
||||||
printf("humi: %.1f temp: %.1f light: %.1f\n", humi, temp, light);
|
printf("humi: %.1f temp: %.1f light: %.1f\n", humi, temp, light);
|
||||||
LED1_Toggle;
|
LED1_Toggle;
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOB_CLK_DISABLE(); //关闭 GPIOB 时钟以降低功耗
|
||||||
|
|
||||||
|
Delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user