Skip to content

Commit 7243451

Browse files
committed
Continue adapting am6254
1 parent 79ce760 commit 7243451

13 files changed

Lines changed: 260 additions & 236 deletions

File tree

ref_app/ref_app.vcxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@
265265
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
266266
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
267267
</ClCompile>
268+
<ClCompile Include="src\mcal\am6254_soc\mcal_led.cpp">
269+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
270+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
271+
</ClCompile>
268272
<ClCompile Include="src\mcal\atmega2560\mcal_cpu.cpp">
269273
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
270274
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
@@ -1492,6 +1496,14 @@
14921496
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
14931497
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
14941498
</ClInclude>
1499+
<ClInclude Include="src\mcal\am6254_soc\mcal_led.h">
1500+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1501+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1502+
</ClInclude>
1503+
<ClInclude Include="src\mcal\am6254_soc\mcal_led_am6254_soc.h">
1504+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1505+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1506+
</ClInclude>
14951507
<ClInclude Include="src\mcal\am6254_soc\mcal_wdg.h">
14961508
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
14971509
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>

ref_app/ref_app.vcxproj.filters

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,9 @@
12731273
<ClCompile Include="src\mcal\am6254_soc\mcal_gpt.cpp">
12741274
<Filter>src\mcal\am6254_soc</Filter>
12751275
</ClCompile>
1276+
<ClCompile Include="src\mcal\am6254_soc\mcal_led.cpp">
1277+
<Filter>src\mcal\am6254_soc</Filter>
1278+
</ClCompile>
12761279
</ItemGroup>
12771280
<ItemGroup>
12781281
<ClInclude Include="src\math\calculus\derivative.h">
@@ -2886,6 +2889,12 @@
28862889
<ClInclude Include="src\mcal\am6254_soc\mcal_cpu.h">
28872890
<Filter>src\mcal\am6254_soc</Filter>
28882891
</ClInclude>
2892+
<ClInclude Include="src\mcal\am6254_soc\mcal_led.h">
2893+
<Filter>src\mcal\am6254_soc</Filter>
2894+
</ClInclude>
2895+
<ClInclude Include="src\mcal\am6254_soc\mcal_led_am6254_soc.h">
2896+
<Filter>src\mcal\am6254_soc</Filter>
2897+
</ClInclude>
28892898
</ItemGroup>
28902899
<ItemGroup>
28912900
<None Include="src\util\STL\algorithm">
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2007 - 2024.
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+
#include <mcal_led.h>
9+
#include <mcal_led/mcal_led_port.h>
10+
11+
auto mcal::led::led0() -> mcal::led::led_base&
12+
{
13+
using led0_port_type = mcal::port::port_pin<std::uint8_t,
14+
std::uint8_t,
15+
mcal::reg::portb,
16+
UINT8_C(5)>;
17+
18+
using led0_led_type = mcal::led::led_port<led0_port_type>;
19+
20+
static led0_led_type l0;
21+
22+
return l0;
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2007 - 2024.
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+
#ifndef MCAL_LED_2010_09_14_H
9+
#define MCAL_LED_2010_09_14_H
10+
11+
#include <mcal_led/mcal_led_base.h>
12+
13+
namespace mcal
14+
{
15+
namespace led
16+
{
17+
auto led0() -> led_base&;
18+
}
19+
}
20+
21+
#endif // MCAL_LED_2010_09_14_H
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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+
#ifndef MCAL_LED_AM6254_SOC_2025_08_04_H
9+
#define MCAL_LED_AM6254_SOC_2025_08_04_H
10+
11+
#include <mcal_led/mcal_led_boolean_state_base.h>
12+
13+
#include <util/utility/util_time.h>
14+
15+
#include <cstdint>
16+
17+
#define PADCFG_CTRL0_CFG0_PADCONFIG3 UINT32_C(0x000F400C)
18+
#define PADCFG_CTRL0_CFG0_PADCONFIG4 UINT32_C(0x000F4010)
19+
#define PADCFG_CTRL0_CFG0_PADCONFIG5 UINT32_C(0x000F4014)
20+
#define PADCFG_CTRL0_CFG0_PADCONFIG6 UINT32_C(0x000F4018)
21+
22+
#define GPIO_DIR01 UINT32_C(0x00600010)
23+
#define GPIO_OUT_DATA01 UINT32_C(0x00600014)
24+
#define GPIO_SET_DATA01 UINT32_C(0x00600018)
25+
#define GPIO_CLR_DATA01 UINT32_C(0x0060001C)
26+
27+
#define LED_1 6
28+
#define LED_2 5
29+
#define LED_3 4
30+
#define LED_4 3
31+
32+
#define LED_INIT() do{ \
33+
*(volatile uint32_t*)(PADCFG_CTRL0_CFG0_PADCONFIG3) &= ~((uint32_t)1ul <<21); \
34+
*(volatile uint32_t*)(PADCFG_CTRL0_CFG0_PADCONFIG4) &= ~((uint32_t)1ul <<21); \
35+
*(volatile uint32_t*)(PADCFG_CTRL0_CFG0_PADCONFIG5) &= ~((uint32_t)1ul <<21); \
36+
*(volatile uint32_t*)(PADCFG_CTRL0_CFG0_PADCONFIG6) &= ~((uint32_t)1ul <<21); \
37+
*(volatile uint32_t*)(GPIO_DIR01) &= ~((uint32_t)0x78ul); \
38+
*(volatile uint32_t*)(GPIO_CLR_DATA01) |= 0x78; \
39+
*(volatile uint32_t*)(GPIO_OUT_DATA01) &= ~((uint32_t)0x78ul); \
40+
}while(0)
41+
42+
#define LED_ON(x) do{*(volatile uint32_t*)(GPIO_SET_DATA01) |= (1ul << x); *(volatile uint32_t*)(GPIO_OUT_DATA01) |= (1ul << x);}while(0)
43+
#define LED_OFF(x) do{*(volatile uint32_t*)(GPIO_CLR_DATA01) |= (1ul << x); *(volatile uint32_t*)(GPIO_OUT_DATA01) &= (uint32_t)(~(uint32_t)(1ul << x));}while(0)
44+
45+
#define LED_1_ON() LED_ON(LED_1)
46+
#define LED_2_ON() LED_ON(LED_2)
47+
#define LED_3_ON() LED_ON(LED_3)
48+
#define LED_4_ON() LED_ON(LED_4)
49+
50+
#define LED_1_OFF() LED_OFF(LED_1)
51+
#define LED_2_OFF() LED_OFF(LED_2)
52+
#define LED_3_OFF() LED_OFF(LED_3)
53+
#define LED_4_OFF() LED_OFF(LED_4)
54+
55+
namespace mcal
56+
{
57+
namespace led
58+
{
59+
template<typename VoidClass>
60+
class led_am6254_soc_base : public mcal::led::led_boolean_state_base
61+
{
62+
public:
63+
~led_am6254_soc_base() override = default;
64+
65+
protected:
66+
led_am6254_soc_base() noexcept = default;
67+
68+
auto toggle() -> void override
69+
{
70+
using base_class_type = led_boolean_state_base;
71+
72+
base_class_type::toggle();
73+
}
74+
75+
private:
76+
static const bool is_init;
77+
};
78+
79+
template<typename VoidClass>
80+
const bool led_am6254_soc_base<VoidClass>::is_init = []() { LED_INIT(); return true; }();
81+
82+
template<const int LED_ID>
83+
class led_am6254_soc final : public mcal::led::led_am6254_soc_base<void>
84+
{
85+
public:
86+
led_am6254_soc() noexcept = default;
87+
88+
~led_am6254_soc() override = default;
89+
90+
auto toggle() -> void override
91+
{
92+
using base_class_type = led_am6254_soc_base<void>;
93+
94+
if(base_class_type::state_is_on())
95+
{
96+
LED_OFF(LED_ID);
97+
}
98+
else
99+
{
100+
LED_ON(LED_ID);
101+
}
102+
103+
base_class_type::toggle();
104+
}
105+
};
106+
107+
template<const int LED_ID>
108+
static void main_core_worker(void)
109+
{
110+
using timer_type = util::timer<std::uint64_t>;
111+
112+
using led_type = led_am6254_soc<LED_ID>;
113+
114+
led_type my_led;
115+
116+
timer_type led_timer(timer_type::seconds(1U));
117+
118+
my_led.toggle();
119+
120+
for(;;)
121+
{
122+
while(!led_timer.timeout()) { asm volatile("nop"); }
123+
124+
my_led.toggle();
125+
126+
led_timer.start_interval(timer_type::seconds(1U));
127+
}
128+
}
129+
} // namespace led
130+
} // namespace mcal
131+
132+
#endif // MCAL_LED_AM6254_SOC_2025_08_04_H

ref_app/target.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,6 @@
11991199
<Text Include="target\micros\bcm2835_raspi_b\startup\SD_CARD\PiZero\config.txt" />
12001200
</ItemGroup>
12011201
<ItemGroup>
1202-
<ClInclude Include="target\micros\am6254_soc\Code\Mcal\Gpio\my_led.h" />
12031202
<ClInclude Include="target\micros\am6254_soc\Code\Mcal\SysTickTimer\SysTickTimer.h" />
12041203
<ClInclude Include="target\micros\am6254_soc\Code\Startup\Core\a53\core_macros.h" />
12051204
<ClInclude Include="target\micros\am6254_soc\Code\Startup\Core\a53\gic-500.h" />

ref_app/target.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,6 @@
322322
<Filter Include="micros\am6254_soc\Code\Mcal\SysTickTimer">
323323
<UniqueIdentifier>{75aa46d5-c890-44e1-bf1b-e294be531ee8}</UniqueIdentifier>
324324
</Filter>
325-
<Filter Include="micros\am6254_soc\Code\Mcal\Gpio">
326-
<UniqueIdentifier>{464c3a7e-dc2f-4c17-912d-a3ccbd91ccfa}</UniqueIdentifier>
327-
</Filter>
328325
<Filter Include="micros\am6254_soc\Code\Startup">
329326
<UniqueIdentifier>{0fb41c05-2289-4721-980a-786b1026a315}</UniqueIdentifier>
330327
</Filter>
@@ -1101,9 +1098,6 @@
11011098
<ClInclude Include="target\micros\xtensa_esp32_s3\startup\Std\core-isa.h">
11021099
<Filter>micros\xtensa_esp32_s3\startup\Std</Filter>
11031100
</ClInclude>
1104-
<ClInclude Include="target\micros\am6254_soc\Code\Mcal\Gpio\my_led.h">
1105-
<Filter>micros\am6254_soc\Code\Mcal\Gpio</Filter>
1106-
</ClInclude>
11071101
<ClInclude Include="target\micros\am6254_soc\Code\Mcal\SysTickTimer\SysTickTimer.h">
11081102
<Filter>micros\am6254_soc\Code\Mcal\SysTickTimer</Filter>
11091103
</ClInclude>

ref_app/target/micros/am6254_soc/Code/Appli/Core/a53/main.c

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
#include <stdbool.h>
1212
#include <stdint.h>
1313

14-
void timer_isr(void);
14+
#if defined(__GNUC__)
15+
#define ATTRIBUTE_USED __attribute__((used,noinline))
16+
#else
17+
#define ATTRIBUTE_USED
18+
#endif
1519

1620
extern uint32_t GetActiveCoreId(void);
1721

@@ -20,10 +24,23 @@ extern void main_core1(void);
2024
extern void main_core2(void);
2125
extern void main_core3(void);
2226

23-
#if defined(__GNUC__)
24-
__attribute__((used,noinline))
25-
#endif
26-
static void main_init(const uint32_t ActiveCore);
27+
ATTRIBUTE_USED void timer_isr(void);
28+
ATTRIBUTE_USED void main_x(void);
29+
ATTRIBUTE_USED static void main_init(const uint32_t ActiveCore);
30+
31+
void main_x(void)
32+
{
33+
const uint32_t ActiveCore = GetActiveCoreId();
34+
35+
// Move the core initialization functions into main_init().
36+
main_init(ActiveCore);
37+
38+
if (ActiveCore == UINT32_C(0)) { main_core0(); } // TBD: Run the normal ref_app coop-scheduler in core0.
39+
else if(ActiveCore == UINT32_C(1)) { main_core1(); }
40+
else if(ActiveCore == UINT32_C(2)) { main_core2(); }
41+
else if(ActiveCore == UINT32_C(3)) { main_core3(); }
42+
else { for(;;) { __asm volatile("nop"); } }
43+
}
2744

2845
static void main_init(const uint32_t ActiveCore)
2946
{
@@ -76,37 +93,6 @@ static void main_init(const uint32_t ActiveCore)
7693
ARM64_WRITE_SYSREG(CNTPS_CTL_EL1, 1);
7794
}
7895

79-
//----------------------------------------------------------------------------------------
80-
/// \brief
81-
///
82-
/// \descr
83-
///
84-
/// \param
85-
///
86-
/// \return
87-
//----------------------------------------------------------------------------------------
88-
void main(void)
89-
{
90-
const uint32_t ActiveCore = GetActiveCoreId();
91-
92-
// Move the core initialization functions into main_init().
93-
main_init(ActiveCore);
94-
95-
if (ActiveCore == UINT32_C(0)) { main_core0(); } // TBD: Run the normal ref_app coop-scheduler in core0.
96-
else if(ActiveCore == UINT32_C(1)) { main_core1(); }
97-
else if(ActiveCore == UINT32_C(2)) { main_core2(); }
98-
else if(ActiveCore == UINT32_C(3)) { main_core3(); }
99-
}
100-
101-
//----------------------------------------------------------------------------------------
102-
/// \brief
103-
///
104-
/// \descr
105-
///
106-
/// \param
107-
///
108-
/// \return
109-
//----------------------------------------------------------------------------------------
11096
void timer_isr(void)
11197
{
11298
static uint32_t cpt[4] = {0u};

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

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
#include <core_macros.h>
9-
#include <my_led.h>
9+
#include <mcal_led_am6254_soc.h>
1010

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

@@ -17,30 +17,7 @@ extern "C" void main_core1(void);
1717
extern "C" void main_core2(void);
1818
extern "C" void main_core3(void);
1919

20-
template<const int LED_ID>
21-
void main_core_worker(void)
22-
{
23-
using timer_type = util::timer<std::uint64_t>;
24-
25-
using led_type = my_led<LED_ID>;
26-
27-
led_type led;
28-
29-
timer_type led_timer(timer_type::seconds(1U));
30-
31-
led.toggle();
32-
33-
for(;;)
34-
{
35-
while(!led_timer.timeout()) { asm volatile("nop"); }
36-
37-
led.toggle();
38-
39-
led_timer.start_interval(timer_type::seconds(1U));
40-
}
41-
}
42-
43-
extern "C" void main_core0(void) { main_core_worker<LED_1>(); }
44-
extern "C" void main_core1(void) { main_core_worker<LED_2>(); }
45-
extern "C" void main_core2(void) { main_core_worker<LED_3>(); }
46-
extern "C" void main_core3(void) { main_core_worker<LED_4>(); }
20+
extern "C" void main_core0(void) { mcal::led::main_core_worker<LED_1>(); }
21+
extern "C" void main_core1(void) { mcal::led::main_core_worker<LED_2>(); }
22+
extern "C" void main_core2(void) { mcal::led::main_core_worker<LED_3>(); }
23+
extern "C" void main_core3(void) { mcal::led::main_core_worker<LED_4>(); }

0 commit comments

Comments
 (0)