sitara_depot/components/free_rtos/clock/clock.cpp

38 lines
746 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* clock.cpp
*
* Created on: 13 мар. 2023 г.
* Author: sychev
*/
#include "free_rtos/clock/clock.hpp"
bool free_rtos::Clock::init(uint32_t period_ms, Callback cbk, void * arg)
{
ClockP_Params clockParams;
ClockP_Params_init(&clockParams);
prd_ms_ = period_ms;
clockParams.timeout = ClockP_usecToTicks(prd_ms_ * 1000);
clockParams.period = clockParams.timeout;
clockParams.callback = cbk;
clockParams.args = arg;
int32_t status = ClockP_construct(&obj_, &clockParams);
return (SystemP_SUCCESS == status);
}
void free_rtos::Clock::start() {
ClockP_start(&obj_);
}
void free_rtos::Clock::stop() {
ClockP_stop(&obj_);
}
free_rtos::Clock::~Clock() {
ClockP_destruct (&obj_);
}