From 4fa9d97e4db333e3252b0e87584d29753f2da74d Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 14 Jul 2017 17:41:43 +1000 Subject: [PATCH] stmhal/servo: Don't compile servo code when it's not enabled. --- stmhal/servo.c | 4 ++++ stmhal/timer.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/stmhal/servo.c b/stmhal/servo.c index 2916ca2807..e4bcbc30e5 100644 --- a/stmhal/servo.c +++ b/stmhal/servo.c @@ -33,6 +33,8 @@ #include "timer.h" #include "servo.h" +#if MICROPY_HW_ENABLE_SERVO + // This file implements the pyb.Servo class which controls standard hobby servo // motors that have 3-wires (ground, power, signal). // @@ -328,3 +330,5 @@ const mp_obj_type_t pyb_servo_type = { .make_new = pyb_servo_make_new, .locals_dict = (mp_obj_dict_t*)&pyb_servo_locals_dict, }; + +#endif // MICROPY_HW_ENABLE_SERVO diff --git a/stmhal/timer.c b/stmhal/timer.c index 7db15f6492..39f168fc89 100644 --- a/stmhal/timer.c +++ b/stmhal/timer.c @@ -216,9 +216,11 @@ TIM_HandleTypeDef *timer_tim6_init(uint freq) { // Interrupt dispatch void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { + #if MICROPY_HW_ENABLE_SERVO if (htim == &TIM5_Handle) { servo_timer_irq_callback(); } + #endif } // Get the frequency (in Hz) of the source clock for the given timer.