Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Luiz Fernando Lavado Villa
OPALIB Quick Start
Commits
978099da
Commit
978099da
authored
Jun 10, 2021
by
Clément Foucher
Browse files
Update library as OwnTech data acquisition is now autonomous.
parent
5e7e3f1c
Changes
3
Hide whitespace changes
Inline
Side-by-side
library.json
View file @
978099da
{
"name"
:
"opalib_quick_start"
,
"version"
:
"1.
1
.0"
,
"version"
:
"1.
2
.0"
,
"description"
:
"OwnTech Power API Library Quick Start initializes all required OwnTech Power API drivers. It allows the user to define a function that will be called periodically."
,
"keywords"
:
"OwnTech Power API"
}
src/opalib_quick_start.c
View file @
978099da
...
...
@@ -24,6 +24,7 @@
/////
// OwnTech Power API includes
#include "timer.h"
#include "hrtim.h"
#include "leg.h"
...
...
@@ -32,35 +33,16 @@
/////
// Timer defines
#define TIMER6_NODELABEL DT_NODELABEL(timers6)
#define TIMER6_LABEL DT_PROP(TIMER6_NODELABEL, label)
static
const
struct
device
*
timer6
;
/////
// Pointer to the user-defined periodic task
static
void
(
*
periodic_task_ptr
)()
=
NULL
;
#define TIMER6_LABEL DT_PROP(DT_NODELABEL(timers6), label)
static
const
struct
device
*
timer6
=
NULL
;
/////
// Functions
static
void
_internal_task
()
{
// Dispatch data from the DMA buffers to per-channel buffers
data_dispatch_do_dispatch
();
// Call user-defined peroidic task
if
(
periodic_task_ptr
!=
NULL
)
periodic_task_ptr
();
}
// Public API
void
opalib_quick_start_init
(
void
(
*
periodic_task
)(),
uint32_t
task_period_us
)
{
/////
// Store user-defined task
periodic_task_ptr
=
periodic_task
;
/////
// Initialize peripherals
...
...
@@ -74,20 +56,18 @@ void opalib_quick_start_init(void (*periodic_task)(), uint32_t task_period_us)
hrtim_adc_trigger_en
(
0
,
ADC1R
,
AD13_TAC3
);
hrtim_cmp_set
(
0
,
TIMA
,
CMP3xR
,
1
);
// Timer
timer6
=
device_get_binding
(
TIMER6_LABEL
);
struct
timer_config_t
timer_cfg
=
if
(
periodic_task
!=
NULL
)
{
.
timer_enable_irq
=
1
,
.
timer
_callback
=
_internal_task
};
timer_config
(
timer6
,
&
timer_cfg
);
/////
// Initialize data dispatch
data_dispatch_init
(
);
//
///
// Launch task by starting timer
timer_start
(
timer6
,
task_period_us
);
// Configure timer
timer
6
=
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
);
}
}
src/opalib_quick_start.h
View file @
978099da
...
...
@@ -41,11 +41,15 @@ extern "C" {
/**
* @brief Library initialization function.
* This function uses Timer 6 is a user periodic
* task is to be executed.
*
* @param periodic_task Pointer to the void(void) function
* to be executed periodically.
* Can be NULL if no task has to be executed.
* @param task_period_us Period of the function in µs.
* 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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment