Commit c1c4b423 authored by Clément Foucher's avatar Clément Foucher
Browse files

Adapt library to new HRTIM voltage mode.

Split user task init as independent function as it will be common to both modes.
parent 978099da
......@@ -27,7 +27,6 @@
#include "timer.h"
#include "hrtim.h"
#include "leg.h"
#include "data_acquisition.h"
......@@ -39,35 +38,37 @@ static const struct device* timer6 = NULL;
/////
// Public API
// Private functions
void opalib_quick_start_init(void (*periodic_task)(), uint32_t task_period_us)
static void _opalib_init_task(void (*periodic_task)(), uint32_t task_period_us)
{
/////
// Initialize peripherals
// Configure timer
timer6 = device_get_binding(TIMER6_LABEL);
struct timer_config_t timer_cfg =
{
.timer_enable_irq = 1,
.timer_callback = periodic_task
};
timer_config(timer6, &timer_cfg);
// Launch task by starting timer
timer_start(timer6, task_period_us);
}
/////
// Public API
void opalib_quick_start_init_voltage(void (*periodic_task)(), uint32_t task_period_us)
{
// ADC
data_acquisition_init();
// Leg
leg_init(true);
// HRTIM
hrtim_adc_trigger_en(0, ADC1R, AD13_TAC3);
hrtim_cmp_set(0, TIMA, CMP3xR, 1);
hrtim_init_voltage();
// User task
if (periodic_task != NULL)
{
// Configure timer
timer6 = device_get_binding(TIMER6_LABEL);
struct timer_config_t timer_cfg =
{
.timer_enable_irq = 1,
.timer_callback = periodic_task
};
timer_config(timer6, &timer_cfg);
// Launch task by starting timer
timer_start(timer6, task_period_us);
_opalib_init_task(periodic_task, task_period_us);
}
}
......@@ -40,7 +40,7 @@ extern "C" {
/**
* @brief Library initialization function.
* @brief Library initialization function for voltage mode.
* This function uses Timer 6 is a user periodic
* task is to be executed.
*
......@@ -51,7 +51,7 @@ extern "C" {
* Allowed range: 1 to 6553 µs.
* Value is ignored if first parameter is NULL.
*/
void opalib_quick_start_init(void (*periodic_task)(), uint32_t task_period_us);
void opalib_quick_start_init_voltage(void (*periodic_task)(), uint32_t task_period_us);
#ifdef __cplusplus
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment