fw/services/common: conditionally initialize accel_manager

Only initialize accel_manager if the accelerometer driver successfully
initialized.

Signed-off-by: Joshua Jun <joshuajun@proton.me>
This commit is contained in:
Joshua Jun 2025-10-13 17:15:31 +02:00 committed by Jinchang
parent 4051c5bb97
commit 791d22ecf1
1 changed files with 14 additions and 1 deletions

View File

@ -27,6 +27,7 @@
#ifdef MICRO_FAMILY_STM32F2 #ifdef MICRO_FAMILY_STM32F2
#include "services/common/legacy/factory_registry.h" #include "services/common/legacy/factory_registry.h"
#endif #endif
#include "drivers/accel.h"
#include "services/common/accel_manager.h" #include "services/common/accel_manager.h"
#include "services/common/bluetooth/bluetooth_persistent_storage.h" #include "services/common/bluetooth/bluetooth_persistent_storage.h"
#include "services/common/comm_session/app_session_capabilities.h" #include "services/common/comm_session/app_session_capabilities.h"
@ -42,13 +43,25 @@
#include "services/common/touch/touch.h" #include "services/common/touch/touch.h"
#include "services/common/vibe_pattern.h" #include "services/common/vibe_pattern.h"
#include "services/runlevel_impl.h" #include "services/runlevel_impl.h"
#include "system/logging.h"
#include "util/size.h" #include "util/size.h"
#define LOG_DOMAIN "services_common"
void services_common_init(void) { void services_common_init(void) {
firmware_update_init(); firmware_update_init();
put_bytes_init(); put_bytes_init();
poll_remote_init(); poll_remote_init();
accel_manager_init();
// Only initialize the accelerometer manager if the accelerometer driver
// successfully initialized. We test this by attempting to peek at a sample.
AccelDriverSample probe_sample;
if (accel_peek(&probe_sample) == 0) {
accel_manager_init();
} else {
PBL_LOG(LOG_LEVEL_WARNING, "Accelerometer driver not initialized, skipping accel_manager_init");
}
light_init(); light_init();
cron_service_init(); cron_service_init();