boot_timer.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright (C) 2017 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _BOOT_TIMER_IRQ_H_
  13. #define _BOOT_TIMER_IRQ_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /**
  21. * \brief timer callback function type
  22. *
  23. * Functions in bootloader shoudn't depend on interrupt. And there is
  24. * only one exception, using timer interrupt to feed external watchdog.
  25. * When external watchdog is used, there are no opportunity to feed
  26. * external watchdog during firmware update. So, it is needed to
  27. * enabled timer interrupt, and feed external watchdog in timer ISR.
  28. *
  29. * Add an exception in fdl2 download process, using timer interrupt to
  30. * check a normal uart communication for factory systematic process.
  31. */
  32. typedef void (*bootTimerCallback_t)(void *ctx);
  33. /**
  34. * \brief enable bootloader timer
  35. *
  36. * There is no critical section mechanism inside bootloader. So, the
  37. * timer callback shouldn't use shared resources with normal bootloader.
  38. *
  39. * Currently, the only purpose of timer interrupt callback is to feed
  40. * external watchdog.
  41. *
  42. * The callback shouldn't be located on flash, due to it is possible
  43. * there are flash erase and program in normal bootloader.
  44. *
  45. * \param cb timer ISR callback
  46. * \param ctx the parameter callback function
  47. * \param period_ms timer period in milliseconds
  48. */
  49. void bootEnableTimer(bootTimerCallback_t cb, void *ctx, unsigned period_ms);
  50. /**
  51. * \brief disable bootloader timer
  52. *
  53. * In order not to affect normal application, when bootloader timer is
  54. * enabled, it is needed to disable the timer before jump to normal
  55. * application.
  56. */
  57. void bootDisableTimer(void);
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif