-
Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathapp_led.cpp
More file actions
54 lines (39 loc) · 1.34 KB
/
app_led.cpp
File metadata and controls
54 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2026.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <mcal/mcal.h>
#include <util/utility/util_time.h>
namespace app { namespace led {
auto task_init() -> void;
auto task_func() -> void;
} // namespace led
} // namespace app
namespace local
{
using app_led_timer_type = util::timer<std::uint32_t>;
using app_led_tick_type = typename app_led_timer_type::tick_type;
auto app_led_timer() noexcept -> app_led_timer_type&;
constexpr app_led_tick_type app_led_delay { app_led_timer_type::seconds(app_led_tick_type{ UINT8_C(1) }) };
} // namespace local
auto local::app_led_timer() noexcept -> app_led_timer_type&
{
static app_led_timer_type local_app_led_timer { };
return local_app_led_timer;
}
auto app::led::task_init() -> void
{
local::app_led_timer().start_interval(local::app_led_delay);
mcal::led::led0().toggle();
}
auto app::led::task_func() -> void
{
auto& my_app_led_timer { local::app_led_timer() };
if(my_app_led_timer.timeout())
{
my_app_led_timer.start_interval(local::app_led_delay);
mcal::led::led0().toggle();
}
}