Skip to content

Hamichev/universal_program_timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

universal_program_timer

Content

Functions

  • Start the program timer.
  • Stop the program timer.
  • Trigger the program timer.
  • Check the program timer for reaching the set value.
  • Check the program timer for operation.
  • Program timer handler.

Using

To use the program timer driver in your project, follow these steps:

  1. Include the necessary header files in your project:
 #include "universal_program_timer.h"

Example

!!!IMPORTANT!!!

It is necessary to place the universal_program_timer_handle() function in the interrupt handler, which is triggered every ms. The program timer is designed to handle small events (raising a flag, increasing a counter, etc.). It should not be used as a handler for large functions, as the callback is executed inside SysTick_handler, which can cause the entire system to freeze (due to the high interrupt priority)!

init_program_timer.c

#include "universal_program_timer.h"

static universal_program_timer_t _work_time = {
   .counter = 0,
   .interval = 1000,
   .mode = eProgramTimerModeCircle,
   .run = false,
   .overflow = false,
   .callback = callback_work_time
};

static universal_program_timer_t _control_time = {
   .counter = 0,
   .interval = 500,
   .mode = eProgramTimerModeOneShot,
   .run = false,
   .overflow = false,
   .callback = callback_control_time
};

static universal_program_timer_t* _program_timers[] = {&_work_time, &_control_time};

/**
 * @brief Initialization of shared timers
 *
 * @return true Successful initialization
 * @return false Failed initialization
 */
bool init_program_timer(void)
{
   bool ret_val = false;

   ret_val = universal_program_timer_init(_program_timers, sizeof(_program_timers) / sizeof(_program_timers[0]));

   return ret_val;
}

/**
 * @brief Work Timer
 *
 * @return drv_timer_handle_t* Pointer to the universal_program_timer_t structure
 */
universal_program_timer_t* program_timer_work_time(void)
{
   return &_work_time;
}

/**
 * @brief Control Timer
 *
 * @return drv_timer_handle_t* Pointer to the universal_program_timer_t structure
 */
universal_program_timer_t* program_timer_control_time(void)
{
   return &_control_time;
}

About

Universal program timers. Allows you to create timers without binding them to the physical timers of the microcontroller.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages