Skip to content

Commit 74bac35

Browse files
committed
Clean up even more syntax
1 parent 89af454 commit 74bac35

9 files changed

Lines changed: 39 additions & 47 deletions

File tree

ref_app/src/mcal/mcal_gpt_arm_sys_tick.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2022 - 2024.
2+
// Copyright Christopher Kormanyos 2022 - 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)
@@ -8,6 +8,7 @@
88
#ifndef MCAL_GPT_ARM_SYS_TICK_2022_11_30_H
99
#define MCAL_GPT_ARM_SYS_TICK_2022_11_30_H
1010

11+
#include <cstddef>
1112
#include <cstdint>
1213
#include <limits>
1314

@@ -48,10 +49,10 @@
4849

4950
template<const std::uint32_t SysTickMHz,
5051
typename ValueType = std::uint64_t>
51-
class arm_sys_tick : private arm_sys_tick_base<SysTickMHz, ValueType, std::uint32_t, std::uint32_t>
52+
class arm_sys_tick : private arm_sys_tick_base<SysTickMHz, ValueType, std::uintptr_t, std::uint32_t>
5253
{
5354
private:
54-
using base_class_type = arm_sys_tick_base<SysTickMHz, ValueType, std::uint32_t, std::uint32_t>;
55+
using base_class_type = arm_sys_tick_base<SysTickMHz, ValueType, std::uintptr_t, std::uint32_t>;
5556

5657
using register_address_type = typename base_class_type::register_address_type;
5758
using register_value_type = typename base_class_type::register_value_type;
@@ -112,8 +113,8 @@
112113
// Return the system tick using a multiple read to ensure data consistency.
113114

114115
// Do the first read of the sys-tick counter and the sys-tick
115-
// value. Handle reverse counting for sys-tick counter, which is
116-
// counting down.
116+
// value. Also handle reverse counting for the sys-tick counter,
117+
// since this timer counts down.
117118

118119
const auto sys_tick_counter_1 =
119120
static_cast<register_value_type>
@@ -128,8 +129,8 @@
128129
const value_type sys_tick_value { my_sys_tick_value };
129130

130131
// Do the second read of the sys-tick counter and the sys-tick
131-
// value. Handle reverse counting for sys-tick counter, which is
132-
// counting down.
132+
// value. Also handle reverse counting for the sys-tick counter,
133+
// since this timer counts down.
133134

134135
const auto sys_tick_counter_2 =
135136
static_cast<register_value_type>

ref_app/src/mcal/xtensa_esp32_s3/mcal_cpu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ auto main_c1() -> void
117117
// by the core1 branch of the subroutine _start().
118118

119119
// Set the private cpu timer1 for core1.
120-
set_cpu_private_timer1(mcal::gpt::timer1_reload());
120+
set_cpu_private_timer1(mcal::gpt::detail::timer1_reload());
121121

122122
// Enable all interrupts on core1.
123123
mcal::irq::init(nullptr);
@@ -133,7 +133,7 @@ auto mcal::cpu::post_init() noexcept -> void
133133
// Note: This subroutine is called from core0.
134134

135135
// Set the private cpu timer1 for core0.
136-
set_cpu_private_timer1(mcal::gpt::timer1_reload());
136+
set_cpu_private_timer1(mcal::gpt::detail::timer1_reload());
137137

138138
// Use core0 to start the RISC-V core.
139139
Mcu_StartCoProcessorRiscV();

ref_app/src/mcal/xtensa_esp32_s3/mcal_gpt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ namespace
5454
extern "C" void __system_tick_handler()
5555
{
5656
// Reload the private timer1 for the running core.
57-
set_cpu_private_timer1(mcal::gpt::timer1_reload());
57+
set_cpu_private_timer1(mcal::gpt::detail::timer1_reload());
5858

5959
const bool is_not_core0 { (get_core_id() != std::uint32_t { UINT8_C(0) }) };
6060

6161
// Toggle the LED (on core1) or increment the 64-bit system tick (on core0).
6262

6363
if(is_not_core0) { mcal::led::led1().toggle(); }
64-
else { system_tick += mcal::gpt::timer1_max(); }
64+
else { system_tick += mcal::gpt::detail::timer1_max(); }
6565
}
6666

6767
auto mcal::gpt::init(const config_type*) -> void
@@ -79,7 +79,7 @@ auto mcal::gpt::secure::get_time_elapsed() -> mcal::gpt::value_type
7979

8080
if(gpt_is_initialized())
8181
{
82-
constexpr std::uint32_t mhz_value { (mcal::gpt::timer1_max() / UINT32_C(1000000)) };
82+
constexpr std::uint32_t mhz_value { (mcal::gpt::detail::timer1_max() / UINT32_C(1000000)) };
8383

8484
result = get_consistent_tick() / mhz_value;
8585
}

ref_app/src/mcal/xtensa_esp32_s3/mcal_gpt.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include <chrono>
1212
#include <cstdint>
1313

14-
#include <mcal/mcal_gpt_arm_sys_tick.h>
15-
1614
// Forward declaration of the util::timer template class.
1715
namespace util
1816
{
@@ -26,20 +24,18 @@
2624
{
2725
namespace detail
2826
{
29-
constexpr inline auto timer1_max () noexcept -> std::uint32_t { return UINT32_C(80000000); }
27+
constexpr inline auto timer1_max () noexcept -> std::uint32_t { return UINT32_C(80'000'000); }
3028
constexpr inline auto timer1_reload() noexcept -> std::uint32_t { return timer1_max() - UINT32_C(1); }
3129
}
3230

33-
using detail::timer1_max;
34-
using detail::timer1_reload;
35-
3631
using config_type = void;
3732
using value_type = std::uint64_t;
3833

3934
auto init(const config_type*) -> void;
4035

4136
struct secure final
4237
{
38+
private:
4339
static auto get_time_elapsed() -> value_type;
4440

4541
friend auto std::chrono::high_resolution_clock::now() noexcept -> std::chrono::high_resolution_clock::time_point;

ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_gpt.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include <chrono>
1212
#include <cstdint>
1313

14-
#include <mcal/mcal_gpt_arm_sys_tick.h>
15-
1614
// Forward declaration of the util::timer template class.
1715
namespace util
1816
{
@@ -24,15 +22,6 @@
2422
{
2523
namespace gpt
2624
{
27-
namespace detail
28-
{
29-
constexpr inline auto timer1_max () noexcept -> std::uint32_t { return UINT32_C(80000000); }
30-
constexpr inline auto timer1_reload() noexcept -> std::uint32_t { return timer1_max() - UINT32_C(1); }
31-
}
32-
33-
using detail::timer1_max;
34-
using detail::timer1_reload;
35-
3625
using config_type = void;
3726
using value_type = std::uint64_t;
3827

ref_app/target.vcxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,10 +1151,6 @@
11511151
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\crt0.cpp" />
11521152
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\crt0_init_ram.cpp" />
11531153
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\crt1.cpp" />
1154-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Appli\main.cpp" />
1155-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup\crt0.cpp" />
1156-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup\crt0_init_ram.cpp" />
1157-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup\crt1.cpp" />
11581154
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\main.cpp" />
11591155
</ItemGroup>
11601156
<ItemGroup>

ref_app/target.vcxproj.filters

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,6 @@
992992
<ClCompile Include="target\micros\xtensa_esp32_s3\startup\Std\StdLib.cpp">
993993
<Filter>micros\xtensa_esp32_s3\startup\Std</Filter>
994994
</ClCompile>
995-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Appli\main.cpp" />
996-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup\crt0.cpp" />
997-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup\crt0_init_ram.cpp" />
998-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup\crt1.cpp" />
999995
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\crt0_init_ram.cpp">
1000996
<Filter>micros\xtensa_esp32_s3_riscv_cop\startup</Filter>
1001997
</ClCompile>

ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ GCC_PREFIX := riscv-none-elf
1313

1414
GCC_VERSION := 14.2.0
1515

16-
TGT_SUFFIX = elf
16+
TGT_SUFFIX := elf
1717

1818
WARN_FLAGS :=
1919

@@ -42,7 +42,6 @@ TGT_AFLAGS = $(TGT_ALLFLAGS)
4242

4343
TGT_LDFLAGS = -nostdlib \
4444
-nostartfiles \
45-
-flto \
4645
-e _start \
4746
-Wl,-Map,$(APP).map \
4847
-T $(LINKER_DEFINITION_FILE) \
@@ -79,17 +78,29 @@ $(PATH_OBJ)/%.o : %.S
7978
# ------------------------------------------------------------------------------
8079

8180
ifeq ($(TYP_OS),WIN)
82-
OBJCOPY := $(PATH_TOOLS_CC)\$(GCC_PREFIX)-objcopy.exe
81+
OBJCOPY := $(PATH_TOOLS_CC)\$(GCC_PREFIX)-objcopy.exe
8382
else
84-
OBJCOPY := $(GCC_PREFIX)-objcopy
83+
OBJCOPY := $(GCC_PREFIX)-objcopy
8584
endif
8685

87-
PYTHON := python
86+
PYTHON := python
8887

88+
89+
BIN2ASM_FLAGS := -s ".coprocessor" \
90+
-l 16 \
91+
-g coprocessor_bin
92+
93+
94+
RULE_SPECIAL_MAKE_IMAGE_FILE_PART00 := $(ECHO) +++ creating binary $(APP).bin
8995
RULE_SPECIAL_MAKE_IMAGE_FILE_PART01 := $(OBJCOPY) $(APP).$(TGT_SUFFIX) -O binary $(APP).bin
90-
RULE_SPECIAL_MAKE_IMAGE_FILE_PART02 := $(PYTHON) $(PATH_TGT)/startup/Scripts/bin2asm.py -i $(APP).bin -o $(PATH_BIN)/coprocessor_binary.S -s ".coprocessor" -l 16 -g coprocessor_bin
91-
RULE_SPECIAL_MAKE_IMAGE_FILE_PART03 := $(PYTHON) $(PATH_TGT)/startup/Scripts/bin2asm.py -i $(APP).bin -o $(PATH_TGT)/../xtensa_esp32_s3/startup/coprocessor_binary.S -s ".coprocessor" -l 16 -g coprocessor_bin
96+
RULE_SPECIAL_MAKE_IMAGE_FILE_PART02 := $(ECHO) +++ creating assembly image as byte-array source file $(PATH_BIN)/coprocessor_binary.S
97+
RULE_SPECIAL_MAKE_IMAGE_FILE_PART03 := $(PYTHON) $(PATH_TGT)/startup/Scripts/bin2asm.py -i $(APP).bin -o $(PATH_BIN)/coprocessor_binary.S $(BIN2ASM_FLAGS)
98+
RULE_SPECIAL_MAKE_IMAGE_FILE_PART04 := $(ECHO) +++ creating assembly image as byte-array source file for xtensa_esp32_s3/startup/coprocessor_binary.S
99+
RULE_SPECIAL_MAKE_IMAGE_FILE_PART05 := $(PYTHON) $(PATH_TGT)/startup/Scripts/bin2asm.py -i $(APP).bin -o $(PATH_TGT)/../xtensa_esp32_s3/startup/coprocessor_binary.S $(BIN2ASM_FLAGS)
92100

93-
RULE_SPECIAL_MAKE_IMAGE_FILE := $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART01) \
101+
RULE_SPECIAL_MAKE_IMAGE_FILE := $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART00) \
102+
&& $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART01) \
94103
&& $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART02) \
95-
&& $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART03)
104+
&& $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART03) \
105+
&& $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART04) \
106+
&& $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART05)

ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ extern "C" auto main() -> int
8181

8282
my_pwm.set_duty(duty_table[duty_index]);
8383

84-
for(unsigned srv_idx { UINT8_C(0) }; srv_idx < unsigned { UINT16_C(16411) }; ++srv_idx)
84+
// Table[Prime[n], {n, 1900, 1905, 1}]
85+
// {16381, 16411, 16417, 16421, 16427, 16433}
86+
87+
for(unsigned srv_idx { UINT8_C(0) }; srv_idx < unsigned { UINT16_C(16'411) }; ++srv_idx)
8588
{
8689
my_pwm.service();
8790
}

0 commit comments

Comments
 (0)