Skip to content
Snippets Groups Projects
Commit 1e043463 authored by Clément Foucher's avatar Clément Foucher
Browse files

HRTIM module :

- Add a function to obtain current repetition value.
- Separate Periodic Event enable from its configuration, that will be required in future changes.
parent c1bba598
No related branches found
No related tags found
No related merge requests found
...@@ -97,7 +97,7 @@ void hrtim_init_voltage_leg1_boost_leg2_buck_center_aligned(hrtim_tu_t leg1_tu, ...@@ -97,7 +97,7 @@ void hrtim_init_voltage_leg1_boost_leg2_buck_center_aligned(hrtim_tu_t leg1_tu,
void hrtim_update_adc_trig_interleaved(uint16_t new_trig, hrtim_tu_t leg1_tu, hrtim_tu_t leg2_tu); void hrtim_update_adc_trig_interleaved(uint16_t new_trig, hrtim_tu_t leg1_tu, hrtim_tu_t leg2_tu);
/** /**
* @brief Enable interrupt on repetition counter for the chosen timing unit * @brief Configure interrupt on repetition counter for the chosen timing unit
* @param tu_src timing unit which will be the source for the ISR: * @param tu_src timing unit which will be the source for the ISR:
* @arg @ref MSTR * @arg @ref MSTR
* @arg @ref TIMA * @arg @ref TIMA
...@@ -107,12 +107,26 @@ void hrtim_update_adc_trig_interleaved(uint16_t new_trig, hrtim_tu_t leg1_tu, hr ...@@ -107,12 +107,26 @@ void hrtim_update_adc_trig_interleaved(uint16_t new_trig, hrtim_tu_t leg1_tu, hr
* @arg @ref TIME * @arg @ref TIME
* @arg @ref TIMF * @arg @ref TIMF
* @param repetition value between 1 and 256 for the repetition counter: * @param repetition value between 1 and 256 for the repetition counter:
* period of the event wrt. periods of the HRTIM. * period of the event wrt. periods of the HRTIM.
* E.g. when set to 10, one event will be triggered every 10 HRTIM period. * E.g. when set to 10, one event will be triggered every 10 HRTIM period.
* @param callback Pointer to a void(void) function that will be called * @param callback Pointer to a void(void) function that will be called
* when the event is triggerred. * when the event is triggerred.
*/
void hrtim_PeriodicEvent_configure(hrtim_tu_t tu_src, uint32_t repetition, hrtim_callback_t callback);
/**
* @brief Enable interrupt on repetition counter for the chosen timing unit.
* The periodic event configuration must have been done previously.
* @param tu_src timing unit which will be the source for the ISR:
* @arg @ref MSTR
* @arg @ref TIMA
* @arg @ref TIMB
* @arg @ref TIMC
* @arg @ref TIMD
* @arg @ref TIME
* @arg @ref TIMF
*/ */
void hrtim_PeriodicEvent_en(hrtim_tu_t tu_src, uint32_t repetition, hrtim_callback_t callback); void hrtim_PeriodicEvent_en(hrtim_tu_t tu_src);
/** /**
* @brief Disable interrupt on repetition counter for the chosen timing unit * @brief Disable interrupt on repetition counter for the chosen timing unit
...@@ -143,6 +157,21 @@ void hrtim_PeriodicEvent_dis(hrtim_tu_t tu_src); ...@@ -143,6 +157,21 @@ void hrtim_PeriodicEvent_dis(hrtim_tu_t tu_src);
*/ */
void hrtim_PeriodicEvent_SetRep(hrtim_tu_t tu_src, uint32_t repetition); void hrtim_PeriodicEvent_SetRep(hrtim_tu_t tu_src, uint32_t repetition);
/**
* @brief Get the current value of the repetition counter.
* @param tu_src timing unit which will be the source for the ISR:
* @arg @ref MSTR
* @arg @ref TIMA
* @arg @ref TIMB
* @arg @ref TIMC
* @arg @ref TIMD
* @arg @ref TIME
* @arg @ref TIMF
* @return Value between 1 and 256 for the repetition counter:
* period of the event wrt. periods of the HRTIM.
*/
uint32_t hrtim_PeriodicEvent_GetRep(hrtim_tu_t tu_src);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -93,7 +93,7 @@ void hrtim_update_adc_trig_interleaved(uint16_t new_trig, hrtim_tu_t leg1_tu, hr ...@@ -93,7 +93,7 @@ void hrtim_update_adc_trig_interleaved(uint16_t new_trig, hrtim_tu_t leg1_tu, hr
} }
} }
void hrtim_PeriodicEvent_en(hrtim_tu_t tu_src, uint32_t repetition, hrtim_callback_t callback) void hrtim_PeriodicEvent_configure(hrtim_tu_t tu_src, uint32_t repetition, hrtim_callback_t callback)
{ {
/* Memorize user callback */ /* Memorize user callback */
user_callback = callback; user_callback = callback;
...@@ -102,7 +102,10 @@ void hrtim_PeriodicEvent_en(hrtim_tu_t tu_src, uint32_t repetition, hrtim_callba ...@@ -102,7 +102,10 @@ void hrtim_PeriodicEvent_en(hrtim_tu_t tu_src, uint32_t repetition, hrtim_callba
* is triggered every "repetition" number of periods. * is triggered every "repetition" number of periods.
*/ */
LL_HRTIM_TIM_SetRepetition(HRTIM1, tu_src, repetition-1); LL_HRTIM_TIM_SetRepetition(HRTIM1, tu_src, repetition-1);
}
void hrtim_PeriodicEvent_en(hrtim_tu_t tu_src)
{
LL_HRTIM_EnableIT_REP(HRTIM1, tu_src); /* Enabling the interrupt on repetition counter event*/ LL_HRTIM_EnableIT_REP(HRTIM1, tu_src); /* Enabling the interrupt on repetition counter event*/
IRQ_CONNECT(HRTIM_IRQ_NUMBER, HRTIM_IRQ_PRIO, _hrtim_callback, NULL, HRTIM_IRQ_FLAGS); IRQ_CONNECT(HRTIM_IRQ_NUMBER, HRTIM_IRQ_PRIO, _hrtim_callback, NULL, HRTIM_IRQ_FLAGS);
...@@ -123,6 +126,11 @@ void hrtim_PeriodicEvent_SetRep(hrtim_tu_t tu_src, uint32_t repetition) ...@@ -123,6 +126,11 @@ void hrtim_PeriodicEvent_SetRep(hrtim_tu_t tu_src, uint32_t repetition)
LL_HRTIM_TIM_SetRepetition(HRTIM1, tu_src, repetition-1); LL_HRTIM_TIM_SetRepetition(HRTIM1, tu_src, repetition-1);
} }
uint32_t hrtim_PeriodicEvent_GetRep(hrtim_tu_t tu_src)
{
return LL_HRTIM_TIM_GetRepetition(HRTIM1, tu_src)+1;
}
void hrtim_init_current() void hrtim_init_current()
{ {
hrtim_cm_init(); hrtim_cm_init();
......
...@@ -124,7 +124,8 @@ void scheduling_start_uninterruptible_synchronous_task() ...@@ -124,7 +124,8 @@ void scheduling_start_uninterruptible_synchronous_task()
if ( (repetition == 0) || (user_periodic_task == NULL) ) if ( (repetition == 0) || (user_periodic_task == NULL) )
return; return;
hrtim_PeriodicEvent_en(MSTR, repetition, user_periodic_task); hrtim_PeriodicEvent_configure(MSTR, repetition, user_periodic_task);
hrtim_PeriodicEvent_en(MSTR);
uninterruptibleTaskStatus = task_status_t::running; uninterruptibleTaskStatus = task_status_t::running;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment