Skip to content

Commit d379ebf

Browse files
committed
Use more standardized LED interface am6254
1 parent ea352c2 commit d379ebf

7 files changed

Lines changed: 99 additions & 81 deletions

File tree

ref_app/ref_app.vcxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,10 +1516,6 @@
15161516
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
15171517
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
15181518
</ClInclude>
1519-
<ClInclude Include="src\mcal\am6254_soc\mcal_led_am6254_soc.h">
1520-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1521-
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1522-
</ClInclude>
15231519
<ClInclude Include="src\mcal\am6254_soc\mcal_memory_progmem.h">
15241520
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
15251521
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>

ref_app/ref_app.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,9 +2895,6 @@
28952895
<ClInclude Include="src\mcal\am6254_soc\mcal_led.h">
28962896
<Filter>src\mcal\am6254_soc</Filter>
28972897
</ClInclude>
2898-
<ClInclude Include="src\mcal\am6254_soc\mcal_led_am6254_soc.h">
2899-
<Filter>src\mcal\am6254_soc</Filter>
2900-
</ClInclude>
29012898
<ClInclude Include="src\mcal\am6254_soc\mcal_spi.h">
29022899
<Filter>src\mcal\am6254_soc</Filter>
29032900
</ClInclude>

ref_app/src/mcal/am6254_soc/mcal_cpu_secure.s

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2025.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
8+
// Originally from:
9+
10+
// ***************************************************************************************
11+
// Filename : boot.s
12+
//
13+
// Core : ARM Cortex-A53
14+
//
15+
// Author : Chalandi Amine
16+
//
17+
// Owner : Chalandi Amine
18+
//
19+
// Date : 16.05.2025
20+
//
21+
// Description : multicore ARM Cortex-A53 (ARMv8-A) startup code
22+
//
23+
// ***************************************************************************************
124

225
.section .text
326
.type hw_acquire_spin_lock,@function

ref_app/src/mcal/am6254_soc/mcal_led.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,50 @@
66
//
77

88
#include <mcal_led.h>
9-
#include <mcal_led_am6254_soc.h>
9+
#include <mcal_led/mcal_led_port.h>
10+
#include <mcal_port.h>
11+
#include <mcal_reg.h>
1012

1113
auto mcal::led::led0() -> mcal::led::led_base&
1214
{
1315
using led0_port_type = mcal::port::port_pin<mcal::reg::gpio0, mcal::led::LED_1>;
1416

15-
using led0_led_type = led_am6254_soc<led0_port_type>;
17+
using led0_led_type = led_port<led0_port_type>;
1618

1719
static led0_led_type l0;
1820

1921
return l0;
2022
}
23+
24+
auto mcal::led::led1() -> mcal::led::led_base&
25+
{
26+
using led1_port_type = mcal::port::port_pin<mcal::reg::gpio0, mcal::led::LED_2>;
27+
28+
using led1_led_type = led_port<led1_port_type>;
29+
30+
static led1_led_type l1;
31+
32+
return l1;
33+
}
34+
35+
auto mcal::led::led2() -> mcal::led::led_base&
36+
{
37+
using led2_port_type = mcal::port::port_pin<mcal::reg::gpio0, mcal::led::LED_3>;
38+
39+
using led2_led_type = led_port<led2_port_type>;
40+
41+
static led2_led_type l2;
42+
43+
return l2;
44+
}
45+
46+
auto mcal::led::led3() -> mcal::led::led_base&
47+
{
48+
using led3_port_type = mcal::port::port_pin<mcal::reg::gpio0, mcal::led::LED_4>;
49+
50+
using led3_led_type = led_port<led3_port_type>;
51+
52+
static led3_led_type l3;
53+
54+
return l3;
55+
}

ref_app/src/mcal/am6254_soc/mcal_led.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@
1010

1111
#include <mcal_led/mcal_led_base.h>
1212

13+
#include <cstdint>
14+
1315
namespace mcal
1416
{
1517
namespace led
1618
{
19+
constexpr unsigned LED_1 { UINT8_C(6) };
20+
constexpr unsigned LED_2 { UINT8_C(5) };
21+
constexpr unsigned LED_3 { UINT8_C(4) };
22+
constexpr unsigned LED_4 { UINT8_C(3) };
23+
1724
auto led0() -> led_base&;
25+
auto led1() -> led_base&;
26+
auto led2() -> led_base&;
27+
auto led3() -> led_base&;
1828
}
1929
}
2030

ref_app/src/mcal/am6254_soc/mcal_led_am6254_soc.h

Lines changed: 0 additions & 64 deletions
This file was deleted.

ref_app/target/micros/am6254_soc/Code/Appli/Core/a53/main_cores.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,38 @@
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
66
//
77

8-
#include <core_macros.h>
9-
#include <mcal_led_am6254_soc.h>
8+
#include <mcal_led.h>
9+
#include <mcal_led/mcal_led_port.h>
1010

1111
#include <util/utility/util_time.h>
1212

1313
#include <cstdint>
1414

15-
extern "C" void main_core1(void);
16-
extern "C" void main_core2(void);
17-
extern "C" void main_core3(void);
15+
static auto main_core_worker(mcal::led::led_base& my_led) -> void;
1816

19-
extern "C" void main_core1(void) { using local_port_type = mcal::port::port_pin<mcal::reg::gpio0, mcal::led::LED_2>; mcal::led::led_am6254_soc<local_port_type>::main_core_worker(); }
20-
extern "C" void main_core2(void) { using local_port_type = mcal::port::port_pin<mcal::reg::gpio0, mcal::led::LED_3>; mcal::led::led_am6254_soc<local_port_type>::main_core_worker(); }
21-
extern "C" void main_core3(void) { using local_port_type = mcal::port::port_pin<mcal::reg::gpio0, mcal::led::LED_4>; mcal::led::led_am6254_soc<local_port_type>::main_core_worker(); }
17+
extern "C" auto main_core1(void) -> void;
18+
extern "C" auto main_core2(void) -> void;
19+
extern "C" auto main_core3(void) -> void;
20+
21+
extern "C" auto main_core1(void) -> void { main_core_worker(mcal::led::led1()); }
22+
extern "C" auto main_core2(void) -> void { main_core_worker(mcal::led::led2()); }
23+
extern "C" auto main_core3(void) -> void { main_core_worker(mcal::led::led3()); }
24+
25+
static auto main_core_worker(mcal::led::led_base& my_led) -> void
26+
{
27+
using local_timer_type = util::timer<std::uint64_t>;
28+
using local_tick_type = typename local_timer_type::tick_type;
29+
30+
local_timer_type led_timer(local_timer_type::seconds(local_tick_type { UINT8_C(1) }));
31+
32+
my_led.toggle();
33+
34+
for(;;)
35+
{
36+
while(!led_timer.timeout()) { asm volatile("nop"); }
37+
38+
my_led.toggle();
39+
40+
led_timer.start_interval(local_timer_type::seconds(local_tick_type { UINT8_C(1) }));
41+
}
42+
}

0 commit comments

Comments
 (0)