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

Integrate scheduling API as a module.

parent fd429280
......@@ -10,5 +10,4 @@
[env]
lib_deps=
peripherals = https://gitlab.laas.fr/owntech/power-api/opalib-peripherals.git
control_pid = https://gitlab.laas.fr/owntech/power-api/opalib-control-pid.git
# control_pid = https://gitlab.laas.fr/owntech/power-api/opalib-control-pid.git
if(CONFIG_OWNTECH_SCHEDULING)
# Select directory to add to the include path
zephyr_include_directories(./public_api)
# Define the current folder as a Zephyr library
zephyr_library()
# Select source files to be compiled
zephyr_library_sources(
public_api/Scheduling.cpp
)
endif()
config OWNTECH_SCHEDULING
bool "Enable OwnTech sceduling"
default y
depends on OWNTECH_TIMER_DRIVER
name: owntech_scheduling
build:
cmake: zephyr
kconfig: zephyr/Kconfig
/*
* Copyright (c) 2022 LAAS-CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGLPV2.1
*/
/**
* @date 2022
* @author Clément Foucher <clement.foucher@laas.fr>
*/
// OwnTech Power API
#include "timer.h"
// Current class header
#include "Scheduling.h"
/////
// Local variables
static const struct device* timer6 = NULL;
/////
// Public object to interact with the class
Scheduling scheduling;
/////
// Public API
void Scheduling::controlTaskInit(void (*periodic_task)(), uint32_t task_period_us)
{
if (periodic_task != NULL)
{
// Configure timer
timer6 = device_get_binding(TIMER6_DEVICE);
struct timer_config_t timer_cfg = {0};
timer_cfg.timer_enable_irq = 1;
timer_cfg.timer_irq_callback = periodic_task;
timer_cfg.timer_irq_t_usec = task_period_us;
timer_config(timer6, &timer_cfg);
}
}
void Scheduling::controlTaskLaunch()
{
timer_start(timer6);
}
/*
* Copyright (c) 2022 LAAS-CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGLPV2.1
*/
/**
* @date 2022
* @author Clément Foucher <clement.foucher@laas.fr>
*/
#ifndef SCHEDULING_H_
#define SCHEDULING_H_
#include <stdint.h>
/////
// Static class definition
class Scheduling
{
public:
/**
* @brief Library initialization function.
* This function uses Timer 6 to execute the periodic
* user task.
*
* @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 controlTaskInit(void (*periodic_task)(), uint32_t task_period_us);
/**
* @brief Begins the periodic run of the task.
*/
void controlTaskLaunch();
};
/////
// Public object to interact with the class
extern Scheduling scheduling;
#endif // SCHEDULING_H_
......@@ -38,4 +38,5 @@ CONFIG_ASSERT=y
#CONFIG_OWNTECH_DATA_ACQUISITION=n
#CONFIG_OWNTECH_DAC_DRIVER=n
#CONFIG_OWNTECH_COMPARATOR_DRIVER=n
#OWNTECH_HARDWARE_CONFIGURATION=n
#CONFIG_OWNTECH_HARDWARE_CONFIGURATION=n
#CONFIG_OWNTECH_SCHEDULING=n
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