Added the possibility to enable the watchdog timer in case something goes sideways using the app_config.h file (enabled by default)

This commit is contained in:
anschrammh 2023-11-27 08:37:08 +01:00
parent 598feba07a
commit 68e1accde7
4 changed files with 36 additions and 3 deletions

View File

@ -102,7 +102,7 @@
#define VIBRATION_MOTOR_PWM_CHANNEL (0)
/**
* @brief BLE advertised device name
* @brief Define the BLE advertised device name
*
*/
#if HARDWARE_PLATFORM == SMART_WATCH_BREADBOARD
@ -111,6 +111,12 @@
#define BLE_DEVICE_NAME "MDBT42Q_PCBDEV"
#else
#define BLE_DEVICE_NAME "MDBT42Q_W800SW"
#endif
#endif
/**
* @brief Define if the watchdog timer should be enabled or not
*
*/
#define WATCHDOG_TIMER_ENABLE (1)
#endif //APP_CONFIG_H

View File

@ -5,6 +5,7 @@
#include "wm_adc.h"
#include "wm_timer.h"
#include "wm_pwm.h"
#include "wm_watchdog.h"
#include "i2c.h"
#include "BMP280.h"
#include "bma456w.h"
@ -17,6 +18,9 @@
#define BATTERY_CONTROLLER_STATUS_DETECTION_POLICY INTERRUPT_POLICY
/* Watchdog configured timeout value is milliseconds */
#define WATCHDOG_TIMEOUT_MS (2000)
/* Battery voltage and ADC */
static int8_t _adc_offset = 0;
@ -285,6 +289,18 @@ void watch_peripherals_init(int8_t adcOffset)
/* Let's init the I2C interface */
i2c_init(I2C_SDA, I2C_SCL, I2C_CLOCK_SPEED);
/* Let's init the watchdog timer in case the software freezes */
#if WATCHDOG_TIMER_ENABLE
tls_watchdog_init(WATCHDOG_TIMEOUT_MS * 1000);
#endif
}
void watch_peripherals_feed_watchdog(void)
{
#if WATCHDOG_TIMER_ENABLE
tls_watchdog_clr();
#endif
}
void watch_peripherals_register_battery_controller_status_change_cb(BatteryControllerStatusChangeCb_t BatteryControllerStatusChangeCb)

View File

@ -43,6 +43,12 @@ const char *battery_controller_status_2_str(battery_controller_status_e status);
*/
void watch_peripherals_init(int8_t adcOffset);
/**
* @brief Feeds the watchdog timer to prevent the watch from reseting.
*
*/
void watch_peripherals_feed_watchdog(void);
/**
* @brief Registers the user provided callback function to notify the battery controller status change event
* @note This function should be as short as possible, do not call LVGL functions in it.

View File

@ -724,7 +724,7 @@ void gfx_task(void *param)
/* Initialize lvgl screens */
watch_face_init(&watchFace);
menu_screen_init(&menuScreen);
menu_screen_register_on_menu_item_click_cb(&menuScreen, &(watch_peripherals_vibrate_on_item_click));
menu_screen_register_user_feedback_cb(&menuScreen, &(watch_peripherals_vibrate_on_item_click));
compass_screen_init(&compassScreen);
compass_screen_register_on_state_change_cb(&compassScreen, &(compass_screen_on_state_change_cb));
@ -736,12 +736,14 @@ void gfx_task(void *param)
music_player_screen_init(&musicPlayerScreen);
music_player_screen_register_music_playback_control_cb(&musicPlayerScreen, &(sendMusicPlaybackBLECommandCb));
music_player_screen_register_music_player_time_ref_ms_cb(&musicPlayerScreen, &(elapsed_ms));
music_player_screen_register_user_feedback_cb(&musicPlayerScreen, &(watch_peripherals_vibrate_on_item_click));
notification_screen_init(&notificationScreen);
notification_screen_register_on_state_change_cb(&notificationScreen, &(notification_on_state_change_cb));
settings_screen_init(&settingsScreen);
settings_screen_register_on_state_change_cb(&settingsScreen, &(settings_screen_on_state_change_cb));
settings_screen_register_user_feedback_cb(&settingsScreen, &(watch_peripherals_vibrate_on_item_click));
settings_screen_register_API_interface(&settingsScreen, &settingsScreenAPIInterface);
watch_face_register_date_time_cb(&watchFace, &(date_time_cb));
@ -924,6 +926,9 @@ void gfx_task(void *param)
_perform_deferred_display_wake_up_set_timestamp();
}
}
/* Let's feed the watchdog timer */
watch_peripherals_feed_watchdog();
}
}