Skip to content

Commit 02671d4

Browse files
committed
Get ref_app and benches running am6254
1 parent 7243451 commit 02671d4

23 files changed

Lines changed: 455 additions & 184 deletions

ref_app/ref_app.vcxproj

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,14 +1488,26 @@
14881488
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
14891489
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
14901490
</ClInclude>
1491+
<ClInclude Include="src\mcal\am6254_soc\mcal_benchmark.h">
1492+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1493+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1494+
</ClInclude>
14911495
<ClInclude Include="src\mcal\am6254_soc\mcal_cpu.h">
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_eep.h">
1500+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1501+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1502+
</ClInclude>
14951503
<ClInclude Include="src\mcal\am6254_soc\mcal_gpt.h">
14961504
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
14971505
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
14981506
</ClInclude>
1507+
<ClInclude Include="src\mcal\am6254_soc\mcal_irq.h">
1508+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1509+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1510+
</ClInclude>
14991511
<ClInclude Include="src\mcal\am6254_soc\mcal_led.h">
15001512
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
15011513
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
@@ -1504,6 +1516,26 @@
15041516
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
15051517
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
15061518
</ClInclude>
1519+
<ClInclude Include="src\mcal\am6254_soc\mcal_memory_progmem.h">
1520+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1521+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1522+
</ClInclude>
1523+
<ClInclude Include="src\mcal\am6254_soc\mcal_port.h">
1524+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1525+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1526+
</ClInclude>
1527+
<ClInclude Include="src\mcal\am6254_soc\mcal_pwm.h">
1528+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1529+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1530+
</ClInclude>
1531+
<ClInclude Include="src\mcal\am6254_soc\mcal_ser.h">
1532+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1533+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1534+
</ClInclude>
1535+
<ClInclude Include="src\mcal\am6254_soc\mcal_spi.h">
1536+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
1537+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
1538+
</ClInclude>
15071539
<ClInclude Include="src\mcal\am6254_soc\mcal_wdg.h">
15081540
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
15091541
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>

ref_app/ref_app.vcxproj.filters

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,6 +2895,30 @@
28952895
<ClInclude Include="src\mcal\am6254_soc\mcal_led_am6254_soc.h">
28962896
<Filter>src\mcal\am6254_soc</Filter>
28972897
</ClInclude>
2898+
<ClInclude Include="src\mcal\am6254_soc\mcal_spi.h">
2899+
<Filter>src\mcal\am6254_soc</Filter>
2900+
</ClInclude>
2901+
<ClInclude Include="src\mcal\am6254_soc\mcal_eep.h">
2902+
<Filter>src\mcal\am6254_soc</Filter>
2903+
</ClInclude>
2904+
<ClInclude Include="src\mcal\am6254_soc\mcal_irq.h">
2905+
<Filter>src\mcal\am6254_soc</Filter>
2906+
</ClInclude>
2907+
<ClInclude Include="src\mcal\am6254_soc\mcal_port.h">
2908+
<Filter>src\mcal\am6254_soc</Filter>
2909+
</ClInclude>
2910+
<ClInclude Include="src\mcal\am6254_soc\mcal_pwm.h">
2911+
<Filter>src\mcal\am6254_soc</Filter>
2912+
</ClInclude>
2913+
<ClInclude Include="src\mcal\am6254_soc\mcal_ser.h">
2914+
<Filter>src\mcal\am6254_soc</Filter>
2915+
</ClInclude>
2916+
<ClInclude Include="src\mcal\am6254_soc\mcal_benchmark.h">
2917+
<Filter>src\mcal\am6254_soc</Filter>
2918+
</ClInclude>
2919+
<ClInclude Include="src\mcal\am6254_soc\mcal_memory_progmem.h">
2920+
<Filter>src\mcal\am6254_soc</Filter>
2921+
</ClInclude>
28982922
</ItemGroup>
28992923
<ItemGroup>
29002924
<None Include="src\util\STL\algorithm">
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2014 - 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_BENCHMARK_2014_04_16_H
9+
#define MCAL_BENCHMARK_2014_04_16_H
10+
11+
#include <cstdint>
12+
#include <mcal_port.h>
13+
14+
namespace mcal
15+
{
16+
namespace benchmark
17+
{
18+
typedef mcal::port::port_pin<2U> benchmark_port_type;
19+
}
20+
}
21+
22+
#endif // MCAL_BENCHMARK_2014_04_16_H
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2007 - 2022.
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_EEP_2018_12_15_H_
9+
#define MCAL_EEP_2018_12_15_H_
10+
11+
#include <cstdint>
12+
13+
namespace mcal
14+
{
15+
namespace eep
16+
{
17+
using config_type = void;
18+
using address_type = std::uint32_t;
19+
20+
inline void init(const config_type*) { }
21+
22+
inline void write(const address_type addr, const std::uint8_t data) { static_cast<void>(addr); static_cast<void>(data); }
23+
inline std::uint8_t read (const address_type addr) { static_cast<void>(addr); return UINT8_C(0); }
24+
}
25+
}
26+
27+
#endif // MCAL_EEP_2018_12_15_H_

ref_app/src/mcal/am6254_soc/mcal_gpt.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2007 - 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+
18
#include <mcal_gpt.h>
29

310
#include <core_macros.h>
411

12+
void mcal::gpt::init(const config_type*) { }
13+
514
mcal::gpt::value_type mcal::gpt::secure::get_time_elapsed()
615
{
716
// Get the system tick from the system counter register.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2007 - 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_IRQ_2010_04_10_H
9+
#define MCAL_IRQ_2010_04_10_H
10+
11+
namespace mcal
12+
{
13+
namespace irq
14+
{
15+
using config_type = void;
16+
17+
inline void init(const config_type*) { }
18+
19+
inline void enable_all () { /* TBD enable/disable fiqs/irqs for this arch. */ }
20+
inline void disable_all() { /* TBD enable/disable fiqs/irqs for this arch. */ }
21+
}
22+
}
23+
24+
#endif // MCAL_IRQ_2010_04_10_H

ref_app/src/mcal/am6254_soc/mcal_led.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2024.
2+
// Copyright Christopher Kormanyos 2007 - 2025.
33
// Distributed under the Boost Software License,
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
66
//
77

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

1111
auto mcal::led::led0() -> mcal::led::led_base&
1212
{
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>;
13+
using led0_led_type = led_am6254_soc<LED_1>;
1914

2015
static led0_led_type l0;
2116

ref_app/src/mcal/am6254_soc/mcal_led_am6254_soc.h

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

8+
// Parts of this file originate from the file Mcal/Gpio/led.h in:
9+
// https://github.com/Chalandi/Baremetal_TI_AM6254_multicore_nosdk
10+
811
#ifndef MCAL_LED_AM6254_SOC_2025_08_04_H
912
#define MCAL_LED_AM6254_SOC_2025_08_04_H
1013

@@ -13,49 +16,17 @@
1316
#include <util/utility/util_time.h>
1417

1518
#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)
19+
#include <type_Traits>
5420

5521
namespace mcal
5622
{
5723
namespace led
5824
{
25+
constexpr unsigned LED_1 { UINT8_C(6) };
26+
constexpr unsigned LED_2 { UINT8_C(5) };
27+
constexpr unsigned LED_3 { UINT8_C(4) };
28+
constexpr unsigned LED_4 { UINT8_C(3) };
29+
5930
template<typename VoidClass>
6031
class led_am6254_soc_base : public mcal::led::led_boolean_state_base
6132
{
@@ -72,60 +43,89 @@
7243
base_class_type::toggle();
7344
}
7445

46+
static constexpr std::uint32_t PADCFG_CTRL0_CFG0_PADCONFIG3 { UINT32_C(0x000F400C) };
47+
static constexpr std::uint32_t PADCFG_CTRL0_CFG0_PADCONFIG4 { UINT32_C(0x000F4010) };
48+
static constexpr std::uint32_t PADCFG_CTRL0_CFG0_PADCONFIG5 { UINT32_C(0x000F4014) };
49+
static constexpr std::uint32_t PADCFG_CTRL0_CFG0_PADCONFIG6 { UINT32_C(0x000F4018) };
50+
51+
static constexpr std::uint32_t GPIO_DIR01 { UINT32_C(0x00600010) };
52+
static constexpr std::uint32_t GPIO_OUT_DATA01 { UINT32_C(0x00600014) };
53+
static constexpr std::uint32_t GPIO_SET_DATA01 { UINT32_C(0x00600018) };
54+
static constexpr std::uint32_t GPIO_CLR_DATA01 { UINT32_C(0x0060001C) };
55+
7556
private:
76-
static const bool is_init;
57+
static const volatile bool is_init;
58+
59+
using local_void_class = VoidClass;
60+
61+
static_assert(std::is_same<local_void_class, void>::value, "Error: The template parameter must be of type void.");
62+
63+
#if defined(__GNUC__)
64+
__attribute__((noinline,used))
65+
#endif
66+
static auto LED_INIT() -> bool
67+
{
68+
*reinterpret_cast<volatile std::uint32_t*>(PADCFG_CTRL0_CFG0_PADCONFIG3) &= static_cast<std::uint32_t>(~(UINT32_C(1) << 21U));
69+
*reinterpret_cast<volatile std::uint32_t*>(PADCFG_CTRL0_CFG0_PADCONFIG4) &= static_cast<std::uint32_t>(~(UINT32_C(1) << 21U));
70+
*reinterpret_cast<volatile std::uint32_t*>(PADCFG_CTRL0_CFG0_PADCONFIG5) &= static_cast<std::uint32_t>(~(UINT32_C(1) << 21U));
71+
*reinterpret_cast<volatile std::uint32_t*>(PADCFG_CTRL0_CFG0_PADCONFIG6) &= static_cast<std::uint32_t>(~(UINT32_C(1) << 21U));
72+
*reinterpret_cast<volatile std::uint32_t*>(GPIO_CLR_DATA01) |= UINT32_C(0x78);
73+
*reinterpret_cast<volatile std::uint32_t*>(GPIO_OUT_DATA01) &= static_cast<std::uint32_t>(~(UINT32_C(0x78)));
74+
*reinterpret_cast<volatile std::uint32_t*>(GPIO_DIR01) &= static_cast<std::uint32_t>(~(UINT32_C(0x78)));
75+
76+
return true;
77+
}
7778
};
7879

7980
template<typename VoidClass>
80-
const bool led_am6254_soc_base<VoidClass>::is_init = []() { LED_INIT(); return true; }();
81+
const volatile bool led_am6254_soc_base<VoidClass>::is_init { LED_INIT() };
8182

82-
template<const int LED_ID>
83+
template<const unsigned LED_ID>
8384
class led_am6254_soc final : public mcal::led::led_am6254_soc_base<void>
8485
{
86+
private:
87+
using base_class_type = led_am6254_soc_base<void>;
88+
89+
static constexpr auto local_led_id() noexcept -> unsigned { return LED_ID; }
90+
8591
public:
8692
led_am6254_soc() noexcept = default;
8793

8894
~led_am6254_soc() override = default;
8995

9096
auto toggle() -> void override
9197
{
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-
}
98+
((base_class_type::state_is_on()) ? LED_OFF() : LED_ON());
10299

103100
base_class_type::toggle();
104101
}
105-
};
106102

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>;
103+
static auto main_core_worker() -> void
104+
{
105+
using local_timer_type = util::timer<std::uint64_t>;
106+
using local_tick_type = typename local_timer_type::tick_type;
107+
using local_led_type = led_am6254_soc<local_led_id()>;
113108

114-
led_type my_led;
109+
local_led_type my_led { };
115110

116-
timer_type led_timer(timer_type::seconds(1U));
111+
local_timer_type led_timer(local_timer_type::seconds(local_tick_type { UINT8_C(1) }));
117112

118-
my_led.toggle();
113+
my_led.toggle();
119114

120-
for(;;)
121-
{
122-
while(!led_timer.timeout()) { asm volatile("nop"); }
115+
for(;;)
116+
{
117+
while(!led_timer.timeout()) { asm volatile("nop"); }
123118

124-
my_led.toggle();
119+
my_led.toggle();
125120

126-
led_timer.start_interval(timer_type::seconds(1U));
121+
led_timer.start_interval(local_timer_type::seconds(local_tick_type { UINT8_C(1) }));
122+
}
127123
}
128-
}
124+
125+
private:
126+
auto LED_ON () noexcept -> void { *reinterpret_cast<volatile std::uint32_t*>(base_class_type::GPIO_SET_DATA01) |= static_cast<std::uint32_t>(UINT32_C(1) << local_led_id()); *reinterpret_cast<volatile std::uint32_t*>(base_class_type::GPIO_OUT_DATA01) |= static_cast<std::uint32_t>(UINT32_C(1) << local_led_id()); }
127+
auto LED_OFF() noexcept -> void { *reinterpret_cast<volatile std::uint32_t*>(base_class_type::GPIO_CLR_DATA01) |= static_cast<std::uint32_t>(UINT32_C(1) << local_led_id()); *reinterpret_cast<volatile std::uint32_t*>(base_class_type::GPIO_OUT_DATA01) &= static_cast<std::uint32_t>(~static_cast<std::uint32_t>(UINT32_C(1) << local_led_id())); }
128+
};
129129
} // namespace led
130130
} // namespace mcal
131131

0 commit comments

Comments
 (0)