diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index e592449fe6..d8d2de3c7f 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -374,7 +374,7 @@ void AP_Notify::add_backends(void) // ChibiOS noise makers #if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS ADD_BACKEND(new Buzzer()); -#if HAL_PWM_COUNT > 0 || HAL_DSHOT_ALARM_ENABLED +#if AP_NOTIFY_TONEALARM_ENABLED ADD_BACKEND(new AP_ToneAlarm()); #endif diff --git a/libraries/AP_Notify/AP_Notify_config.h b/libraries/AP_Notify/AP_Notify_config.h index 373de3297b..9d6eec2e03 100644 --- a/libraries/AP_Notify/AP_Notify_config.h +++ b/libraries/AP_Notify/AP_Notify_config.h @@ -48,3 +48,7 @@ #ifndef AP_NOTIFY_NEOPIXEL_ENABLED #define AP_NOTIFY_NEOPIXEL_ENABLED AP_NOTIFY_SERIALLED_ENABLED #endif + +#ifndef AP_NOTIFY_TONEALARM_ENABLED +#define AP_NOTIFY_TONEALARM_ENABLED ((defined(HAL_PWM_ALARM) || HAL_DSHOT_ALARM_ENABLED)) +#endif diff --git a/libraries/AP_Notify/ToneAlarm.cpp b/libraries/AP_Notify/ToneAlarm.cpp index 64721f7c54..c6a6886d94 100644 --- a/libraries/AP_Notify/ToneAlarm.cpp +++ b/libraries/AP_Notify/ToneAlarm.cpp @@ -105,9 +105,7 @@ bool AP_ToneAlarm::init() if (pNotify->buzzer_enabled() == false) { return false; } -#if ((defined(HAL_PWM_ALARM) || defined(HAL_PWM_ALT_ALARM) || HAL_DSHOT_ALARM_ENABLED) && CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS) || \ - CONFIG_HAL_BOARD == HAL_BOARD_LINUX || \ - CONFIG_HAL_BOARD == HAL_BOARD_SITL +#if AP_NOTIFY_TONEALARM_ENABLED if (!hal.util->toneAlarm_init(pNotify->get_buzzer_types())) { return false; }