added slow lptim to BSP_POWER
This commit is contained in:
19
Application/BSP/BSP_POWER.c
Normal file
19
Application/BSP/BSP_POWER.c
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
#include "BSP_POWER.h"
|
||||
#include "lptim.h"
|
||||
#include "ulog.h"
|
||||
|
||||
#define LPTIM_CLK 500 // Hz
|
||||
#define SLEEP_TIME 10 // seconds to wait
|
||||
|
||||
void BSP_POWER_Init() {
|
||||
uint16_t counter = LPTIM_CLK * SLEEP_TIME;
|
||||
HAL_LPTIM_Counter_Start_IT(&hlptim4, counter);
|
||||
}
|
||||
|
||||
|
||||
void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim) {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
#pragma once
|
||||
// Driver for standby and sleep managment
|
||||
// Timer for automatic standby
|
||||
// Wakeup Pin Setting
|
||||
// also shutdown procedure
|
||||
// also shutdown procedure
|
||||
|
||||
void BSP_POWER_Init();
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
add_library(BSP STATIC
|
||||
BSP_EE24.c
|
||||
BSP_INA.c
|
||||
BSP_POWER.c
|
||||
)
|
||||
|
||||
target_include_directories(BSP PUBLIC ./)
|
||||
target_link_libraries(BSP PRIVATE EE24 INA219)
|
||||
target_link_libraries(BSP PRIVATE EE24 INA219 ulog)
|
||||
|
||||
@@ -171,7 +171,7 @@ I2C2.I2C_Speed_Mode=I2C_Standard
|
||||
I2C2.IPParameters=Timing,I2C_Speed_Mode,Analog_Filter,I2C_Rise_Time,I2C_Fall_Time
|
||||
I2C2.Timing=0x00D0D8FF
|
||||
KeepUserPlacement=false
|
||||
LPTIM4.ClockPrescaler=LPTIM_PRESCALER_DIV2
|
||||
LPTIM4.ClockPrescaler=LPTIM_PRESCALER_DIV64
|
||||
LPTIM4.IPParameters=ClockPrescaler
|
||||
LPUART1.BaudRate=2000000
|
||||
LPUART1.IPParameters=BaudRate
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "tim.h"
|
||||
#include "BSP_EE24.h"
|
||||
#include "BSP_INA.h"
|
||||
#include "BSP_POWER.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -181,6 +182,8 @@ void StartDefaultTask(void *argument)
|
||||
|
||||
BSP_INA_Init();
|
||||
|
||||
BSP_POWER_Init();
|
||||
|
||||
char INA_LOG[72];
|
||||
|
||||
/* Infinite loop */
|
||||
|
||||
@@ -39,7 +39,7 @@ void MX_LPTIM4_Init(void)
|
||||
/* USER CODE END LPTIM4_Init 1 */
|
||||
hlptim4.Instance = LPTIM4;
|
||||
hlptim4.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;
|
||||
hlptim4.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV2;
|
||||
hlptim4.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV64;
|
||||
hlptim4.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;
|
||||
hlptim4.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH;
|
||||
hlptim4.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE;
|
||||
|
||||
@@ -26,6 +26,7 @@ set(sources_SRCS ${sources_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/gpio.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/i2c.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/tim.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/lptim.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/rng.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/rtc.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/sdmmc.c
|
||||
@@ -69,6 +70,7 @@ set(sources_SRCS ${sources_SRCS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sd.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sd_ex.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_lptim.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c
|
||||
|
||||
Reference in New Issue
Block a user