Skip to content

Commit feadd0f

Browse files
committed
Start adption of blinky LED-object
1 parent d86529d commit feadd0f

File tree

4 files changed

+6205
-63700
lines changed

4 files changed

+6205
-63700
lines changed

ref_app/src/mcal/r7fa4m1ab/mcal_led.cpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,44 @@
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
66
//
77

8+
#include "R7FA4M1AB.h"
9+
810
#include <mcal_led.h>
911
#include <mcal_led/mcal_led_port.h>
1012

11-
mcal::led::led_base& mcal::led::led0()
13+
class led_minima_blinky : public mcal::led::led_boolean_state_base
1214
{
13-
using led0_port_type = mcal::port::port_pin<UINT32_C(5)>;
15+
public:
16+
led_minima_blinky()
17+
{
18+
/* configure pin P111 as output */
19+
/* disable register write protection for PFS*/
20+
PMISC->PWPR.bit.B0WI = 0;
21+
PMISC->PWPR.bit.PFSWE = 1;
22+
23+
/* output low */
24+
PFS->P111PFS.bit.PODR = 0;
25+
26+
/* configure the pin as output */
27+
PFS->P111PFS.bit.PDR = 1;
28+
}
29+
30+
~led_minima_blinky() override = default;
1431

15-
using led0_led_type = mcal::led::led_port<led0_port_type>;
32+
auto toggle() noexcept -> void override
33+
{
34+
using base_class_type = led_boolean_state_base;
35+
36+
// Toggle the LED.
37+
PFS->P111PFS.bit.PODR ^= 1;
38+
39+
base_class_type::toggle();
40+
}
41+
};
42+
43+
mcal::led::led_base& mcal::led::led0()
44+
{
45+
using led0_led_type = led_minima_blinky;
1646

1747
static led0_led_type l0;
1848

ref_app/target/micros/r7fa4m1ab/make/r7fa4m1ab_files.gmk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ FILES_TGT = $(PATH_APP)/mcal/mcal_gcc_cxx_completion \
1818
$(PATH_TGT)/startup/int_vect \
1919
$(PATH_APP)/mcal/$(TGT)/mcal_cpu \
2020
$(PATH_APP)/mcal/$(TGT)/mcal_gpt \
21+
$(PATH_APP)/mcal/$(TGT)/mcal_led \
2122
$(PATH_APP)/mcal/$(TGT)/mcal_osc \
2223
$(PATH_APP)/mcal/$(TGT)/mcal_port \
2324
$(PATH_APP)/mcal/$(TGT)/mcal_wdg \

ref_app/target/micros/r7fa4m1ab/startup/Code/Appli/main.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,31 @@
1515
1616
******************************************************************************************/
1717

18-
//-----------------------------------------------------------------------------------------
19-
// Includes
20-
//-----------------------------------------------------------------------------------------
21-
#include <cstdint>
22-
18+
#include <mcal_led.h>
2319
#include <util/utility/util_time.h>
2420

25-
#include "R7FA4M1AB.h"
26-
21+
#include <cstdint>
2722

2823
extern "C" void mcal_gpt_init(void);
2924

3025
int main(void);
3126

3227
int main(void)
3328
{
34-
/* configure pin P111 as output */
35-
/* disable register write protection for PFS*/
36-
PMISC->PWPR.bit.B0WI = 0;
37-
PMISC->PWPR.bit.PFSWE = 1;
38-
39-
/* output low */
40-
PFS->P111PFS.bit.PODR = 0;
41-
42-
/* configure the pin as output */
43-
PFS->P111PFS.bit.PDR = 1;
44-
45-
/* Set the LED on */
46-
PFS->P111PFS.bit.PODR ^= 1;
47-
4829
mcal_gpt_init();
4930

5031
using local_timer_type = util::timer<std::uint32_t>;
5132

33+
mcal::led::led0().toggle();
34+
5235
local_timer_type blinky_timer { local_timer_type::seconds(UINT8_C(1)) };
5336

5437
/* endless loop */
5538
while(1)
5639
{
5740
if(blinky_timer.timeout())
5841
{
59-
PFS->P111PFS.bit.PODR ^= 1;
42+
mcal::led::led0().toggle();
6043

6144
blinky_timer.start_interval(local_timer_type::seconds(UINT8_C(1)));
6245
}

0 commit comments

Comments
 (0)