Skip to content

Commit 953c489

Browse files
authored
Merge branch 'development' into feature/CAN_BCU
2 parents 8d8ca46 + ce53a8a commit 953c489

62 files changed

Lines changed: 3436 additions & 1502 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
FROM ubuntu:24.04
22

3+
ENV PATH="$PATH:/opt/st/stm32cubeclt_1.16.0/GNU-tools-for-STM32/bin:/opt/st/stm32cubeclt_1.16.0/CMake/bin:/opt/st/stm32cubeclt_1.16.0/Ninja/bin"
4+
35
# Install git, git-lfs, pip and colorama, and create workspace directory
46
RUN apt-get update && apt-get -y install git git-lfs python3-colorama cmake g++ build-essential && \
57
git lfs install
6-
8+
79
# Install cubeclt
810
RUN mkdir /temp && cd /temp && git clone https://github.com/HyperloopUPV-H8/cubeclt.git && \
911
cd cubeclt && git lfs pull && chmod +x cubeclt_1.16.0_installer.sh && \
10-
echo | LICENSE_ALREADY_ACCEPTED=1 ./cubeclt_1.16.0_installer.sh
12+
echo | LICENSE_ALREADY_ACCEPTED=1 ./cubeclt_1.16.0_installer.sh

.github/workflows/build.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build Project
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
preset:
7+
description: |
8+
'CMake preset to build the project, run `cmake --build --list-presets' to see a complete list of options'
9+
required: true
10+
type: string
11+
default: 'nucleo-debug'
12+
outputs:
13+
build-artifact:
14+
description: 'Build result artifact id for later use'
15+
value: ${{ jobs.build.outputs.build-artifact }}
16+
workflow_dispatch:
17+
inputs:
18+
preset:
19+
description: |
20+
'CMake preset to build the project, run `cmake --build --list-presets' to see a complete list of options'
21+
required: true
22+
type: string
23+
default: 'nucleo-debug'
24+
25+
jobs:
26+
build:
27+
name: Build Project
28+
runs-on: ubuntu-24.04
29+
outputs:
30+
build-artifact: ${{ steps.upload-build-artifact.outputs.artifact-id }}
31+
container:
32+
image: jmaralo/hyperloop-upv-firmware:0.3.0
33+
steps:
34+
- name: Clone Project
35+
uses: actions/checkout@v3
36+
with:
37+
submodules: recursive
38+
- name: Build
39+
run: |
40+
cmake --preset ${{ inputs.preset }} .
41+
cmake --build --preset ${{ inputs.preset }}
42+
- name: Upload Build
43+
id: upload-build-artifact
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: ${{ inputs.preset }}
47+
path: out/build/test.elf
48+
retention-days: 7
49+
compression-level: 0
50+
if-no-files-found: ignore
51+

.github/workflows/c-cpp.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Compile Checks
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.cpp'
7+
- '**.hpp'
8+
- '**.c'
9+
- '**.h'
10+
- '**.py'
11+
12+
jobs:
13+
compile-checks:
14+
name: Check project compiles
15+
strategy:
16+
matrix:
17+
preset:
18+
- nucleo-debug
19+
- nucleo-release
20+
- nucleo-relwithdebinfo
21+
- nucleo-debug-eth
22+
- nucleo-release-eth
23+
- nucleo-relwithdebinfo-eth
24+
- board-debug
25+
- board-release
26+
- board-relwithdebinfo
27+
- board-debug-eth
28+
- board-release-eth
29+
- board-relwithdebinfo-eth
30+
- simulator
31+
fail-fast: false
32+
uses: ./.github/workflows/build.yml
33+
with:
34+
preset: ${{ matrix.preset }}

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ target_compile_options(${STLIB_LIBRARY} PRIVATE
137137
$<$<COMPILE_LANGUAGE:CXX>:-Wno-inconsistent-missing-override>
138138
$<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
139139
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
140+
$<$<COMPILE_LANGUAGE:CXX>:-Wno-address-of-packed-member> # Add this line
140141
)
141142

142143
target_include_directories(${STLIB_LIBRARY} PRIVATE

CMakePresets.json

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "mcu",
66
"hidden": true,
7-
"generator": "Unix Makefiles",
7+
"generator": "Ninja",
88
"binaryDir": "${sourceDir}/out/build/${presetName}",
99
"toolchainFile": "${sourceDir}/toolchains/stm32.cmake",
1010
"installDir": "${sourceDir}/out/install/${presetName}",
@@ -16,7 +16,7 @@
1616
{
1717
"name": "sim",
1818
"hidden": true,
19-
"generator": "Unix Makefiles",
19+
"generator": "Ninja",
2020
"binaryDir": "${sourceDir}/out/build/${presetName}",
2121
"installDir": "${sourceDir}/out/install/${presetName}",
2222
"cacheVariables": {
@@ -165,5 +165,72 @@
165165
"CMAKE_BUILD_TYPE": "Debug"
166166
}
167167
}
168+
],
169+
"buildPresets": [
170+
{
171+
"name": "nucleo-debug",
172+
"displayName": "Nucleo [DBG]",
173+
"configurePreset": "nucleo-debug"
174+
},
175+
{
176+
"name": "nucleo-release",
177+
"displayName": "Nucleo [REL]",
178+
"configurePreset": "nucleo-release"
179+
},
180+
{
181+
"name": "nucleo-relwithdebinfo",
182+
"displayName": "Nucleo [RWD]",
183+
"configurePreset": "nucleo-relwithdebinfo"
184+
},
185+
{
186+
"name": "nucleo-debug-eth",
187+
"displayName": "Nucleo [DBG] [ETH]",
188+
"configurePreset": "nucleo-debug-eth"
189+
},
190+
{
191+
"name": "nucleo-release-eth",
192+
"displayName": "Nucleo [REL] [ETH]",
193+
"configurePreset": "nucleo-release-eth"
194+
},
195+
{
196+
"name": "nucleo-relwithdebinfo-eth",
197+
"displayName": "Nucleo [RWD] [ETH]",
198+
"configurePreset": "nucleo-relwithdebinfo-eth"
199+
},
200+
{
201+
"name": "board-debug",
202+
"displayName": "Board [DBG]",
203+
"configurePreset": "board-debug"
204+
},
205+
{
206+
"name": "board-release",
207+
"displayName": "Board [REL]",
208+
"configurePreset": "board-release"
209+
},
210+
{
211+
"name": "board-relwithdebinfo",
212+
"displayName": "Board [RWD]",
213+
"configurePreset": "board-relwithdebinfo"
214+
},
215+
{
216+
"name": "board-debug-eth",
217+
"displayName": "Board [DBG] [ETH]",
218+
"configurePreset": "board-debug-eth"
219+
},
220+
{
221+
"name": "board-release-eth",
222+
"displayName": "Board [REL] [ETH]",
223+
"configurePreset": "board-release-eth"
224+
},
225+
{
226+
"name": "board-relwithdebinfo-eth",
227+
"displayName": "Board [RWD] [ETH]",
228+
"configurePreset": "board-relwithdebinfo-eth"
229+
},
230+
{
231+
"name": "simulator",
232+
"displayName": "Simulator",
233+
"configurePreset": "simulator"
234+
}
168235
]
169236
}

Inc/HALAL/HALAL.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "HALALMock/Models/Packets/OrderProtocol.hpp"
6666
#include "HALALMock/Models/BoardID/BoardID.hpp"
6767
#include "HALALMock/Models/Concepts/Concepts.hpp"
68+
#include "HALALMock/Services/Logger/Logger.hpp"
6869
#endif
6970

7071
namespace HALAL {

Inc/HALAL/Services/Communication/Ethernet/UDP/DatagramSocket.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class DatagramSocket {
1515
IPV4 remote_ip;
1616
uint32_t remote_port;
1717
bool is_disconnected = true;
18-
1918
DatagramSocket();
2019
DatagramSocket(DatagramSocket&& other);
2120
DatagramSocket(IPV4 local_ip, uint32_t local_port, IPV4 remote_ip,
@@ -27,6 +26,7 @@ class DatagramSocket {
2726

2827
void reconnect();
2928

29+
3030
static void receive_callback(void* args, struct udp_pcb* udp_control_block,
3131
struct pbuf* packet_buffer,
3232
const ip_addr_t* remote_address, u16_t port);

Inc/HALALMock/Models/PinModel/Pin.hpp

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ enum OperationMode {
7171
ALTERNATIVE,
7272
};
7373

74-
enum PinState { OFF, ON };
74+
enum PinState: uint8_t { OFF, ON };
7575

76-
enum TRIGGER{
76+
enum TRIGGER: uint8_t {
7777
RISING_EDGE = 1,
7878
FAILING_EDGE = 0,
7979
BOTH_EDGES = 2
8080
};
81-
enum class PinType {
81+
enum class PinType: uint8_t {
8282
NOT_USED,
8383
DigitalOutput,
8484
DigitalInput,
@@ -95,52 +95,66 @@ enum class PinType {
9595
// TODO: Add more types
9696

9797
};
98-
struct DigitalOutput_MockPin{
98+
99+
/// In STM32H723ZG, the ADC1 and ADC2 has 16 bits as their maximum
100+
/// resolution, while the ADC3 has 12 bits. Both of them can be configured
101+
/// to has less resolution than its maximum
102+
enum class ADCResolution : uint32_t {
103+
ADC_RES_16BITS = 0x00000000,
104+
ADC_RES_14BITS = 0x00000004,
105+
ADC_RES_12BITS = 0x00000008,
106+
ADC_RES_10BITS = 0x0000000C
107+
};
108+
109+
110+
struct __attribute__((packed)) DigitalOutput_MockPin{
99111
bool state;
100112
} ;
101-
struct DigitalInput_MockPin {
113+
struct __attribute__((packed)) DigitalInput_MockPin {
102114
PinState curr_state;
103115
} ;
104-
struct PWM_MockPin {
116+
struct __attribute__((packed)) PWM_MockPin {
105117
float duty_cycle;
106118
uint32_t frequency;
107119
bool is_on;
108-
std::chrono::nanoseconds dead_time_ns;
120+
int64_t dead_time_ns;
109121
} ;
110-
struct DualPWM_MockPin{
122+
struct __attribute__((packed)) DualPWM_MockPin{
111123
float duty_cycle;
112124
uint32_t frequency;
113125
bool is_on;
114-
std::chrono::nanoseconds dead_time_ns;
126+
int64_t dead_time_ns;
115127
} ;
116-
struct ADC_MockPin{
128+
struct __attribute__((packed)) ADC_MockPin{
117129
uint16_t value;
118130
bool is_on;
131+
ADCResolution resolution;
119132
} ;
120-
struct EXTIPin_MockPin{
133+
struct __attribute__((packed)) EXTIPin_MockPin{
121134
uint32_t priority;
122135
bool is_on;
123136
bool trigger_signal;
124137
TRIGGER trigger_mode;
125138
} ;
126-
struct Encoder_MockPin{
139+
struct __attribute__((packed)) Encoder_MockPin{
127140
uint32_t count_value;
128141
bool direction;
129142
bool is_on;
130143
} ;
131-
struct InputCapure_MockPin{
144+
struct __attribute__((packed)) InputCapure_MockPin{
132145
uint8_t duty_cycle;
133146
uint32_t frequency;
147+
bool is_on;
134148
};
135-
struct FDCAN_MockPin{
136-
149+
struct __attribute__((packed)) FDCAN_MockPin{
150+
bool is_on;
137151
};
138-
struct SPI_MockPin{
152+
struct __attribute__((packed)) SPI_MockPin{
139153
bool is_on;
140154
};
141-
struct EmulatedPin {
155+
struct __attribute__((packed)) EmulatedPin {
142156
PinType type = PinType::NOT_USED; // Always check type before using the union
143-
union PinDataU {
157+
union __attribute__((packed)) PinDataU {
144158
DigitalOutput_MockPin digital_output;
145159
DigitalInput_MockPin digital_input;
146160
PWM_MockPin pwm;
@@ -197,6 +211,16 @@ struct hash<Pin> {
197211
};
198212
} // namespace std
199213

214+
namespace std {
215+
template<>
216+
struct hash<std::pair<Pin, Pin>> {
217+
std::size_t operator()(const std::pair<Pin, Pin>& p) const {
218+
std::hash<Pin> pin_hasher;
219+
return pin_hasher(p.first) ^ (pin_hasher(p.second) << 1);
220+
}
221+
};
222+
}
223+
200224
extern Pin PA0;
201225
extern Pin PA1;
202226
extern Pin PA2;

0 commit comments

Comments
 (0)