From 8263b120c26f7a7bbe52972e59b8f30063faafff Mon Sep 17 00:00:00 2001 From: Ayoub Farah Hassan <afarahhass@laas.fr> Date: Wed, 18 Jan 2023 08:44:00 +0000 Subject: [PATCH] Adding functions to initialize interrupt on repetition counter event This commit add three functions to implement interrupt on HRTIM repetition counter event. --- .../zephyr/public_api/hrtim.h | 38 +++++++++++++++++++ .../zephyr/src/hrtim_common.c | 17 +++++++++ 2 files changed, 55 insertions(+) diff --git a/zephyr/modules/owntech_hrtim_driver/zephyr/public_api/hrtim.h b/zephyr/modules/owntech_hrtim_driver/zephyr/public_api/hrtim.h index da28726..0fc1781 100644 --- a/zephyr/modules/owntech_hrtim_driver/zephyr/public_api/hrtim.h +++ b/zephyr/modules/owntech_hrtim_driver/zephyr/public_api/hrtim.h @@ -92,7 +92,45 @@ void hrtim_init_voltage_leg1_boost_leg2_buck(hrtim_tu_t leg1_tu, hrtim_tu_t leg2 void hrtim_init_voltage_leg1_boost_leg2_buck_center_aligned(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 + * @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); + +/** + * @brief Disable interrupt on repetition counter for the chosen timing unit + * @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_dis(hrtim_tu_t tu_src); +/** + * @brief Change the repetition counter value to control the ISR interrupt + * @param repetion value between 0 and 255 for 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 + */ +void hrtim_PeriodicEvent_SetRep(uint32_t repetition, hrtim_tu_t tu_src); #ifdef __cplusplus } diff --git a/zephyr/modules/owntech_hrtim_driver/zephyr/src/hrtim_common.c b/zephyr/modules/owntech_hrtim_driver/zephyr/src/hrtim_common.c index f3b1d17..ca9d88f 100644 --- a/zephyr/modules/owntech_hrtim_driver/zephyr/src/hrtim_common.c +++ b/zephyr/modules/owntech_hrtim_driver/zephyr/src/hrtim_common.c @@ -77,6 +77,23 @@ 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) +{ + LL_HRTIM_TIM_SetRepetition(HRTIM1, tu_src , 9); /* We initialize the ISR interrupt frequency + to 1/10 of the switching frequency first */ + + LL_HRTIM_EnableIT_REP(HRTIM1, tu_src); /* Enabling the interrupt on repetition counter event*/ +} + +void hrtim_PeriodicEvent_dis(hrtim_tu_t tu_src) +{ + LL_HRTIM_DisableIT_REP(HRTIM1, tu_src); /* Disabling the interrupt on repetition counter event*/ +} + +void hrtim_PeriodicEvent_SetRep(uint32_t repetition, hrtim_tu_t tu_src) +{ + LL_HRTIM_TIM_SetRepetition(HRTIM1, tu_src , repetition); +} void hrtim_init_current() { -- GitLab