Skip to content

Commit f11d28f

Browse files
committed
Merge branch 'FW-301/Execute_Code_gen_on_cmake' of https://github.com/Hyperloop-UPV/template-project
2 parents 79732e3 + 3f6ea0a commit f11d28f

6 files changed

Lines changed: 16 additions & 52 deletions

File tree

Core/Inc/Code_generation/Packet_generation/DataTemplate.hpp

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,7 @@ class DataPackets{
1919
{{packet.name}} = new HeapPacket(static_cast<uint16_t>({{packet.id}}){% if packet.variables %}, {% for variable in packet.variables %}&{{variable.name}}{% if not loop.last %}, {% endif %}{% endfor %}{% endif %});
2020
}
2121
{% endfor -%}
22-
23-
private:
24-
25-
{% set sending_count = sending_packets|length %}
26-
{% if sending_count <= 32 %}
27-
using FlagsType = uint32_t;
28-
#define CTZ_FUNC __builtin_ctz
29-
{% elif sending_count <= 64 %}
30-
using FlagsType = uint64_t;
31-
#define CTZ_FUNC __builtin_ctzll
32-
{% else %}
33-
#error "Too many sending tasks (>64)"
34-
{% endif %}
35-
36-
inline static volatile FlagsType send_flags{0};
37-
38-
{% for packet in sending_packets %}
39-
static void send_task_{{loop.index0}}() {
40-
{% if packet.name is string -%}
41-
DataPackets::{{packet.socket}}->send_packet(*DataPackets::{{packet.name}});
42-
{% else %}
43-
{% for name in packet.name -%}
44-
DataPackets::{{packet.socket}}->send_packet(*DataPackets::{{name}});
45-
{% endfor -%}
46-
{%- endif %}
47-
}
48-
{% endfor %}
49-
50-
using SendAction = void(*)();
51-
static inline SendAction send_actions[] = {
52-
{% for packet in sending_packets %}
53-
send_task_{{loop.index0}},
54-
{% endfor %}
55-
};
56-
22+
5723
public:
5824
{%for packet in packets -%}
5925
inline static HeapPacket *{{packet.name}}{nullptr};
@@ -82,20 +48,20 @@ class DataPackets{
8248

8349
{%- for packet in sending_packets %}
8450
Scheduler::register_task({% if packet.period_type == "ms" %}{{ (packet.period*1000)|round|int }}{% else %}{{ packet.period|round|int }}{% endif %}, +[](){
85-
DataPackets::send_flags |= (static_cast<FlagsType>(1) << {{loop.index0}});
51+
{% if packet.name is string -%}
52+
if(DataPackets::{{packet.name}}){
53+
DataPackets::{{packet.socket}}->send_packet(*DataPackets::{{packet.name}});
54+
}
55+
{% else %}
56+
{% for name in packet.name -%}
57+
if(DataPackets::{{name}}){
58+
DataPackets::{{packet.socket}}->send_packet(*DataPackets::{{name}});
59+
}
60+
{% endfor -%}
61+
{%- endif %}
8662
}); {%- endfor %}
8763
}
8864

89-
static void update()
90-
{
91-
while(DataPackets::send_flags) {
92-
uint8_t index = CTZ_FUNC(DataPackets::send_flags);
93-
DataPackets::send_flags &= ~(static_cast<FlagsType>(1) << index);
94-
if (index < {{sending_count}}) {
95-
DataPackets::send_actions[index]();
96-
}
97-
}
98-
}
9965

10066

10167
};

Core/Inc/Communications/Packets/.gitignore

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Core/Src/PCU/Comms/Comms.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,3 @@ void Comms::start()
8787

8888
}
8989

90-
void Comms::update()
91-
{
92-
DataPackets::update();
93-
}

Core/Src/PCU/PCU.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ void PCU::update()
8989
CurrentSensors::zeroing();
9090
}
9191

92+
//Control updates:
9293
if(flag_update_speed_control)
9394
{
9495
flag_update_speed_control=false;

Core/Src/Runes/generated_metadata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
extern "C"{
66
const char DESCRIPTION[255] __attribute__((section(".metadata_pool")))=
77
"****************" // placeholder for beggining
8-
"20260204T183122" // DateTime using ISO-8601 format
8+
"20260204T195355" // DateTime using ISO-8601 format
99
" " // alignment
1010
"98e5b96e" // STLIB commit
1111
"--------" // ADJ commit
12-
"21bf8d5e" // Board commit
12+
"79732e36" // Board commit
1313
// the '=' is used for unparsing
1414
;
1515
}

0 commit comments

Comments
 (0)