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