Skip to content

Commit 7ca8634

Browse files
Merge remote-tracking branch 'origin/development' into feat/TimerDomain
2 parents c828d2c + 332e04d commit 7ca8634

24 files changed

Lines changed: 1438 additions & 889 deletions

File tree

Inc/C++Utilities/StaticVector.hpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#pragma once
2+
#include <array>
3+
#include "ErrorHandler/ErrorHandler.hpp"
4+
5+
template <typename T, size_t Capacity>
6+
class StaticVector {
7+
private:
8+
std::array<T, Capacity> data{};
9+
size_t size_ = 0;
10+
11+
public:
12+
constexpr StaticVector() = default;
13+
14+
template<typename... Args>
15+
constexpr StaticVector(Args&&... args) : data{std::forward<Args>(args)...}, size_(sizeof...(args)) {}
16+
17+
constexpr bool operator==(const StaticVector&) const = default;
18+
19+
constexpr void push_back(const T& value)
20+
{
21+
if (size_ >= Capacity)
22+
{
23+
ErrorHandler("StaticVector capacity exceeded");
24+
return;
25+
}
26+
data[size_] = value;
27+
size_++;
28+
}
29+
30+
constexpr auto begin() { return data.begin(); }
31+
constexpr auto begin() const { return data.begin(); }
32+
constexpr auto end() { return data.begin() + size_; }
33+
constexpr auto end() const { return data.begin() + size_; }
34+
35+
constexpr const std::array<T, Capacity>& get_array() const { return data; }
36+
constexpr size_t size() const { return size_; }
37+
constexpr T* get_data() { return data.data(); }
38+
constexpr const T* get_data() const { return data.data(); }
39+
constexpr T& operator[](size_t i) { return data[i]; }
40+
constexpr const T& operator[](size_t i) const { return data[i]; }
41+
constexpr bool contains(const T& value) const
42+
{
43+
for (size_t i = 0; i < size_; ++i)
44+
{
45+
if (data[i] == value)
46+
{
47+
return true;
48+
}
49+
}
50+
return false;
51+
}
52+
};
53+

Inc/HALAL/HALAL.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "HALAL/Services/FMAC/FMAC.hpp"
3838

3939
#include "HALAL/Models/MPUManager/MPUManager.hpp"
40+
#include "HALAL/Models/MPU.hpp"
4041
#include "HALAL/Services/InfoWarning/InfoWarning.hpp"
4142
#include "HALAL/Services/Watchdog/Watchdog.hpp"
4243

Inc/HALAL/Models/GPIO.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct GPIODomain {
7171
return GPIO_SPEED_FREQ_VERY_HIGH;
7272
}
7373
}
74+
// Note: AF mapping is inverted: AF0 -> 15, AF1 -> 14, ..., AF15 -> 0, it is staticly casted and inverted later
7475
enum class AlternateFunction : uint8_t {
7576
NO_AF = 20,
7677
AF0 = 15,
@@ -189,10 +190,14 @@ struct GPIODomain {
189190
if (!pin.valid_af(af)) {
190191
compile_error("Alternate function not valid for this pin");
191192
}
193+
194+
if ((mode == OperationMode::ALT_PP || mode == OperationMode::ALT_OD) && af == AlternateFunction::NO_AF) {
195+
compile_error("Alternate function must be specified for alternate modes");
196+
}
192197
}
193198

194-
template <class Ctx> consteval void inscribe(Ctx &ctx) const {
195-
ctx.template add<GPIODomain>(e, this);
199+
template <class Ctx> consteval std::size_t inscribe(Ctx &ctx) const {
200+
return ctx.template add<GPIODomain>(e, this);
196201
}
197202
};
198203

@@ -221,7 +226,7 @@ struct GPIODomain {
221226
GPIO_InitStruct.Pull = to_hal_pull(e.pull);
222227
GPIO_InitStruct.Speed = to_hal_speed(e.speed);
223228
if (e.mode == OperationMode::ALT_PP || e.mode == OperationMode::ALT_OD) {
224-
GPIO_InitStruct.Alternate = static_cast<uint32_t>(e.af);
229+
GPIO_InitStruct.Alternate = 15 - static_cast<uint32_t>(e.af); // AF mapping inversion
225230
}
226231

227232
cfgs[i].init_data = std::make_tuple(e.port, GPIO_InitStruct);

0 commit comments

Comments
 (0)