stm32rcos
読み取り中…
検索中…
一致する文字列を見つけられません
timer.hpp
[詳解]
1
#pragma once
2
3
#include <cstdint>
4
#include <memory>
5
#include <type_traits>
6
7
#include <cmsis_os2.h>
8
9
namespace
stm32rcos
{
10
namespace
core
{
11
12
class
Timer
{
13
private
:
14
struct
Deleter {
15
void
operator()(osTimerId_t timer_id) { osTimerDelete(timer_id); }
16
};
17
18
using
TimerId = std::unique_ptr<std::remove_pointer_t<osTimerId_t>, Deleter>;
19
20
public
:
21
Timer
(
void
(*func)(
void
*),
void
*args, osTimerType_t type,
22
uint32_t attr_bits = 0) {
23
osTimerAttr_t attr{};
24
attr.attr_bits = attr_bits;
25
timer_id_ = TimerId{osTimerNew(func, type, args, &attr)};
26
}
27
28
bool
start
(uint32_t ticks) {
29
return
osTimerStart(timer_id_.get(), ticks) == osOK;
30
}
31
32
bool
stop
() {
return
osTimerStop(timer_id_.get()) == osOK; }
33
34
bool
is_running
() {
return
osTimerIsRunning(timer_id_.get()) == 1; }
35
36
private
:
37
TimerId timer_id_;
38
};
39
40
}
// namespace core
41
}
// namespace stm32rcos
stm32rcos::core::Timer::is_running
bool is_running()
Definition
timer.hpp:34
stm32rcos::core::Timer::stop
bool stop()
Definition
timer.hpp:32
stm32rcos::core::Timer::start
bool start(uint32_t ticks)
Definition
timer.hpp:28
stm32rcos::core::Timer::Timer
Timer(void(*func)(void *), void *args, osTimerType_t type, uint32_t attr_bits=0)
Definition
timer.hpp:21
stm32rcos::core
Definition
mutex.hpp:10
stm32rcos
Definition
mutex.hpp:9
include
stm32rcos
core
timer.hpp
構築:
1.13.2