전원 버튼 BSP 제거, GPIO 제어로 전환

- 전원 OFF 로직 추가(main_s)
- processing 변수 삭제
This commit is contained in:
2026-04-16 16:55:59 +09:00
parent 742681554e
commit 24a4be94df
6 changed files with 86 additions and 59 deletions

View File

@@ -152,28 +152,31 @@ void main_loop(void * p_context) /* For x ms */
* Continuous read mode. If not waiting for BLE TX (ble_got_new_data==false),
* call icm42670_main() and restart timer after 10ms for repeated execution.
*/
if(motion_raw_data_enabled == true) {
if (motion_raw_data_enabled == true)
{
main_timer_stop(); /* Stop timer (prevent re-entry) */
if(motion_data_once == true)
if (motion_data_once == true)
{
/* One-shot mode: init HW I2C then read IMU data once */
hw_i2c_init_once(); /* Switch to HW TWI mode (400kHz) */
icm42670_main(); /* Read and process IMU data */
}
else{
hw_i2c_init_once(); /* Switch to HW TWI mode (400kHz) */
icm42670_main(); /* Read and process IMU data */
}
else
{
/* Continuous mode: repeat read if not waiting for BLE TX */
if(ble_got_new_data==false){
//for(uint16_t i=0 ; i<60 ;i++)
//{
DBG_PRINTF("IMU \r\n");
if (ble_got_new_data==false)
{
//for(uint16_t i=0 ; i<60 ;i++)
//{
DBG_PRINTF("IMU \r\n");
icm42670_main(); /* Read IMU data */
motion_raw_data_enabled = true; /* Keep flag set (continuous read) */
main_timer_start_ms(1000); /* Next IMU read after 1s */
}
// else if(ble_got_new_data==true){
// motion_data_once = true;
// }
icm42670_main(); /* Read IMU data */
motion_raw_data_enabled = true; /* Keep flag set (continuous read) */
main_timer_start_ms(1000); /* Next IMU read after 1s */
}
// else if(ble_got_new_data==true){
// motion_data_once = true;
// }
}
}
@@ -184,7 +187,8 @@ void main_loop(void * p_context) /* For x ms */
* Called after IMU continuous read in info4 mode.
* Timer remains stopped after measurement.
*/
if(go_batt == true) {
if (go_batt == true)
{
DBG_PRINTF("IMU BATT\r\n");
main_timer_stop(); /* Stop timer */
go_batt = false; /* Consume flag (one-shot) */
@@ -203,7 +207,8 @@ void main_loop(void * p_context) /* For x ms */
* After completion, sets motion_data_once=true so the next IMU read
* uses one-shot mode (with HW I2C re-init).
*/
if(go_temp == true) {
if (go_temp == true)
{
DBG_PRINTF("IMU Temp\r\n");
main_timer_stop(); /* Stop timer */
// go_batt = false;
@@ -218,21 +223,24 @@ void main_loop(void * p_context) /* For x ms */
/* ---- System control event handling ---- */
/* Device power OFF handling */
if(go_device_power_off == true){
if (go_device_power_off == true)
{
main_timer_stop(); /* Stop timer */
DBG_PRINTF("Off main_timer\r\n");
device_power_off(); /* Execute device power OFF */
}
/* Sleep mode entry handling */
if(go_sleep_mode_enter == true){
if (go_sleep_mode_enter == true)
{
main_timer_stop(); /* Stop timer */
DBG_PRINTF("sleep main timer\r\n");
sleep_mode_enter(); /* Execute sleep mode entry */
}
/* NVIC system reset handling */
if(go_NVIC_SystemReset == true) {
if (go_NVIC_SystemReset == true)
{
main_timer_stop(); /* Stop timer */
NVIC_SystemReset(); /* ARM Cortex-M4 system reset */
}

View File

@@ -48,26 +48,20 @@ APP_TIMER_DEF(m_power_timer_id);
/* Power sequence current step (0: I2C init, 1: reserved, 2: complete) */
static uint8_t p_order;
/* Data processing flag (declared in external module) */
extern volatile bool processing;
/* Power sequence lock flag (true = sequence in progress) */
bool lock_check = false;
/**
* @brief Enter device sleep mode
*
* Clears the processing flag so the main loop stops
* processing sensor data.
*
* @return 0 (always succeeds)
*/
int device_sleep_mode(void){
int device_sleep_mode(void)
{
int rc = 0;
nrf_delay_ms(2);
DBG_PRINTF("Device_Sleep_Mode OK!\r\n");
nrf_delay_ms(10);
processing = false; /* Clear processing flag -> stop sensor handling */
return rc;
}