Skip to content
Open

DFSDM #614

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
90ca98e
add all enums needed, I hope
oganigl Jan 28, 2026
8732116
CLK finished, half way from finishing DFSDM.HPP
oganigl Feb 13, 2026
3445aa2
First total draft of dfsdm finished
oganigl Feb 27, 2026
4f13110
Merge branch 'development' into feat/DFSDM
oganigl Feb 27, 2026
fd1b967
fix some errors from the merge, mia culpa
oganigl Feb 27, 2026
894d60e
eliminate right bit shift in execution time
oganigl Feb 27, 2026
e8216f7
added some changes to compile clk
oganigl Feb 28, 2026
5cc4af8
change a bit of AF in PB0 for dfsdm_clk_out
oganigl Feb 28, 2026
27f2b93
clock works for every possible pin
oganigl Feb 28, 2026
71661b1
added a config, you're welcome Boris
oganigl Mar 1, 2026
7b07dcd
compiles let's see if it works
oganigl Mar 1, 2026
342c9a9
add buffer and callbacks in compile time
oganigl Mar 4, 2026
6c67c0c
some more changes in the dfsdm
oganigl Mar 6, 2026
12d51ca
fix some minor errors
oganigl Mar 6, 2026
691b396
add again max_instances
oganigl Mar 6, 2026
0cb2cbe
Add dma safety, not implemented yet
oganigl Mar 6, 2026
412e133
Masinstances updated to max_instances
oganigl Mar 6, 2026
22ab26d
now the callbacks works
oganigl Mar 6, 2026
0e0235b
some more more changes
oganigl Mar 7, 2026
fbfc0d6
the trigger works gg
oganigl Mar 8, 2026
574abd8
okay this might work
oganigl Mar 9, 2026
63cb9e8
okay dma works, something to look is how to allow to use the 16 entri…
oganigl Mar 14, 2026
457a791
dma tested, don't ask how, don't ask why but it works fine. Or at lea…
oganigl Mar 14, 2026
dfd5340
Robust TCP/IP Hardening (#582)
jorgesg82 Mar 2, 2026
2dfdf38
Prescaler was not initialized in init (#584)
Cantonplas Mar 4, 2026
3a12e39
Fix/scheduler timerdomain (#585)
victor-Lopez25 Mar 4, 2026
47efb88
Fixed issues with MSVC on windows in tests (#583)
victor-Lopez25 Mar 4, 2026
9cfa240
Fix: rcc_enable_timer for scheduler timer (#586)
victor-Lopez25 Mar 5, 2026
10688b5
Feat/no virtual on State Machine (#581)
Cantonplas Mar 13, 2026
b5846fd
fix(MDMA): Fix, MDMA AHBS is 32-bit only (#588)
FoniksFox Mar 15, 2026
cc4e9bc
Fix Scheduler race conditions (#591)
victor-Lopez25 Mar 15, 2026
24738ff
Max out ARR for encoder (#587)
victor-Lopez25 Mar 16, 2026
5cbb065
Hotfix/sched register b4 start (#593)
victor-Lopez25 Mar 16, 2026
21bc1b8
Change the frequency if this can be called frequency of the leds (#580)
oganigl Mar 20, 2026
1466802
Releases are back bitches (#596)
jorgesg82 Mar 20, 2026
c088c60
merge development to main
oganigl Mar 22, 2026
683b056
compiles, but not tested
oganigl Mar 25, 2026
12a4c0f
OKay tested this works fine with dma and without.
oganigl Mar 26, 2026
0e3d73b
readme version
oganigl Mar 26, 2026
8683e31
indentation done
oganigl Mar 26, 2026
9df3168
change start() to static functions
oganigl Mar 26, 2026
18705ce
add more safety
oganigl Mar 26, 2026
2ed7947
Merge branch 'development' into feat/DFSDM
oganigl Mar 29, 2026
80be128
change changeset
oganigl Mar 29, 2026
c06bd0f
Remove duplicity
oganigl Mar 29, 2026
7af2239
add indentation for 14 time
oganigl Mar 29, 2026
969f5d9
add defines for the simulator
oganigl Mar 29, 2026
7fc4709
modify stm32.cmake so everyone can use it and not only people with an…
oganigl Mar 29, 2026
50cff63
done again changes do to indentation
oganigl Mar 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changesets/dfsdm-module-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release: minor
summary: Added module dfsdm tested
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ set(HALAL_CPP_NO_ETH
${CMAKE_CURRENT_LIST_DIR}/Src/HALAL/Services/Time/RTC.cpp
${CMAKE_CURRENT_LIST_DIR}/Src/HALAL/Services/Time/Scheduler.cpp
${CMAKE_CURRENT_LIST_DIR}/Src/HALAL/Services/Watchdog/Watchdog.cpp
${CMAKE_CURRENT_LIST_DIR}/Src/HALAL/Services/DFSDM/DFSDM.cpp
)


Expand Down
2 changes: 2 additions & 0 deletions Inc/HALAL/HALAL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include "HALAL/Models/Packets/MdmaPacket.hpp"

#include "HALAL/Benchmarking_toolkit/DataWatchpointTrace/DataWatchpointTrace.hpp"

#include "HALAL/Services/DFSDM/DFSDM.hpp"
#include "HALAL/HardFault/HardfaultTrace.h"
#include "HALAL/Services/Communication/Ethernet/NewEthernet.hpp"
#ifdef STLIB_ETH
Expand Down
34 changes: 30 additions & 4 deletions Inc/HALAL/Models/DMA/DMA2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ struct DMADomain {
spi4,
spi5,
spi6,
fmac
fmac,
dfsdm_filter0,
dfsdm_filter1,
dfsdm_filter2,
dfsdm_filter3
};

enum class Stream : uint8_t {
Expand Down Expand Up @@ -98,7 +102,7 @@ struct DMADomain {
}
return nullptr;
}

static inline consteval bool shares_dma(Peripheral p) { return is_dfsdm(p); }
struct Entry {
Peripheral instance;
Stream stream;
Expand Down Expand Up @@ -217,6 +221,16 @@ struct DMADomain {

static consteval bool is_none(Peripheral instance) { return instance == Peripheral::none; }

static consteval bool is_dfsdm(Peripheral instance) {
return is_one_of(
instance,
Peripheral::dfsdm_filter0,
Peripheral::dfsdm_filter1,
Peripheral::dfsdm_filter2,
Peripheral::dfsdm_filter3
);
}

static consteval uint32_t get_Request(Peripheral instance, uint8_t i) {
if (instance == Peripheral::none)
return DMA_REQUEST_MEM2MEM;
Expand Down Expand Up @@ -272,8 +286,20 @@ struct DMADomain {
return DMA_REQUEST_FMAC_WRITE;
if (instance == Peripheral::fmac && i == 2)
return DMA_REQUEST_FMAC_READ;

if (instance == Peripheral::dfsdm_filter0) {
return DMA_REQUEST_DFSDM1_FLT0;
}
if (instance == Peripheral::dfsdm_filter1) {
return DMA_REQUEST_DFSDM1_FLT1;
}
if (instance == Peripheral::dfsdm_filter2) {
return DMA_REQUEST_DFSDM1_FLT2;
}
if (instance == Peripheral::dfsdm_filter3) {
return DMA_REQUEST_DFSDM1_FLT3;
}
compile_error("Invalid DMA request configuration");

return 0;
}

Expand Down Expand Up @@ -303,7 +329,7 @@ struct DMADomain {
static consteval uint32_t get_PeriphDataAlignment(Peripheral instance, uint8_t i) {
if (is_spi(instance) || is_i2c(instance)) {
return DMA_PDATAALIGN_BYTE;
} else if (is_none(instance)) {
} else if (is_none(instance) || (is_dfsdm(instance))) {
return DMA_PDATAALIGN_WORD;
}
return DMA_PDATAALIGN_HALFWORD;
Expand Down
34 changes: 17 additions & 17 deletions Inc/HALAL/Models/Pin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ constexpr GPIODomain::Pin PA14{A, GPIO_PIN_14, 0b1000000000000001};
constexpr GPIODomain::Pin PA15{A, GPIO_PIN_15, 0b1100111111010011};

// Port B
constexpr GPIODomain::Pin PB0{B, GPIO_PIN_0, 0b0111110011111011};
constexpr GPIODomain::Pin PB1{B, GPIO_PIN_1, 0b0111110011111011};
constexpr GPIODomain::Pin PB0{B, GPIO_PIN_0, 0b0111111011111011};
constexpr GPIODomain::Pin PB1{B, GPIO_PIN_1, 0b0111111011111011};
constexpr GPIODomain::Pin PB2{B, GPIO_PIN_2, 0b0110111110111011};
constexpr GPIODomain::Pin PB3{B, GPIO_PIN_3, 0b0111110110111011};
constexpr GPIODomain::Pin PB4{B, GPIO_PIN_4, 0b0111111110110011};
Expand All @@ -35,26 +35,26 @@ constexpr GPIODomain::Pin PB6{B, GPIO_PIN_6, 0b0111110111111111};
constexpr GPIODomain::Pin PB7{B, GPIO_PIN_7, 0b0111110111111011};
constexpr GPIODomain::Pin PB8{B, GPIO_PIN_8, 0b0110111111111111};
constexpr GPIODomain::Pin PB9{B, GPIO_PIN_9, 0b0110111111111111};
constexpr GPIODomain::Pin PB10{B, GPIO_PIN_10, 0b0111110111111111};
constexpr GPIODomain::Pin PB10{B, GPIO_PIN_10, 0b0111111111111111};
constexpr GPIODomain::Pin PB11{B, GPIO_PIN_11, 0b0111110111111011};
constexpr GPIODomain::Pin PB12{B, GPIO_PIN_12, 0b0111110111111011};
constexpr GPIODomain::Pin PB12{B, GPIO_PIN_12, 0b0111111111111011};
constexpr GPIODomain::Pin PB13{B, GPIO_PIN_13, 0b0111110111111011};
constexpr GPIODomain::Pin PB14{B, GPIO_PIN_14, 0b0111110011111011};
constexpr GPIODomain::Pin PB14{B, GPIO_PIN_14, 0b0111111011111011};
constexpr GPIODomain::Pin PB15{B, GPIO_PIN_15, 0b0111110011111011};

// Port C
constexpr GPIODomain::Pin PC0{C, GPIO_PIN_0, 0b0110110110110011};
constexpr GPIODomain::Pin PC1{C, GPIO_PIN_1, 0b0110111111111111};
constexpr GPIODomain::Pin PC0{C, GPIO_PIN_0, 0b0110111110110011};
constexpr GPIODomain::Pin PC1{C, GPIO_PIN_1, 0b0111111111111111};
constexpr GPIODomain::Pin PC2{C, GPIO_PIN_2, 0b0110111110110011};
constexpr GPIODomain::Pin PC3{C, GPIO_PIN_3, 0b0110111110110011};
constexpr GPIODomain::Pin PC3{C, GPIO_PIN_3, 0b0111111110110011};
constexpr GPIODomain::Pin PC4{C, GPIO_PIN_4, 0b0110110110111011};
constexpr GPIODomain::Pin PC5{C, GPIO_PIN_5, 0b0110110110111111};
constexpr GPIODomain::Pin PC5{C, GPIO_PIN_5, 0b0111110110111111};
constexpr GPIODomain::Pin PC6{C, GPIO_PIN_6, 0b0111110011111111};
constexpr GPIODomain::Pin PC7{C, GPIO_PIN_7, 0b0111110011111111};
constexpr GPIODomain::Pin PC8{C, GPIO_PIN_8, 0b0111110011011111};
constexpr GPIODomain::Pin PC9{C, GPIO_PIN_9, 0b0111110110111111};
constexpr GPIODomain::Pin PC10{C, GPIO_PIN_10, 0b0110111111111111};
constexpr GPIODomain::Pin PC11{C, GPIO_PIN_11, 0b0110111111111111};
constexpr GPIODomain::Pin PC11{C, GPIO_PIN_11, 0b0111111111111111};
constexpr GPIODomain::Pin PC12{C, GPIO_PIN_12, 0b0110111111011111};
constexpr GPIODomain::Pin PC13{C, GPIO_PIN_13, 0b1000000000000001};
constexpr GPIODomain::Pin PC14{C, GPIO_PIN_14, 0b1000000000000001};
Expand All @@ -64,14 +64,14 @@ constexpr GPIODomain::Pin PC15{C, GPIO_PIN_15, 0b1000000000000001};
constexpr GPIODomain::Pin PD0{D, GPIO_PIN_0, 0b0111110110011011};
constexpr GPIODomain::Pin PD1{D, GPIO_PIN_1, 0b0111110110011011};
constexpr GPIODomain::Pin PD2{D, GPIO_PIN_2, 0b1110110110011011};
constexpr GPIODomain::Pin PD3{D, GPIO_PIN_3, 0b0110110111110011};
constexpr GPIODomain::Pin PD3{D, GPIO_PIN_3, 0b0111110111110011};
constexpr GPIODomain::Pin PD4{D, GPIO_PIN_4, 0b0010110010010011};
constexpr GPIODomain::Pin PD5{D, GPIO_PIN_5, 0b0010110010010011};
constexpr GPIODomain::Pin PD6{D, GPIO_PIN_6, 0b0111110110111011};
constexpr GPIODomain::Pin PD7{D, GPIO_PIN_7, 0b0110110111111011};
constexpr GPIODomain::Pin PD6{D, GPIO_PIN_6, 0b0111111110111011};
constexpr GPIODomain::Pin PD7{D, GPIO_PIN_7, 0b0111110111111011};
constexpr GPIODomain::Pin PD8{D, GPIO_PIN_8, 0b0110110110010011};
constexpr GPIODomain::Pin PD9{D, GPIO_PIN_9, 0b0110110110010011};
constexpr GPIODomain::Pin PD10{D, GPIO_PIN_10, 0b0110110110010011};
constexpr GPIODomain::Pin PD9{D, GPIO_PIN_9, 0b0111110110010011};
constexpr GPIODomain::Pin PD10{D, GPIO_PIN_10, 0b0111110110010011};
constexpr GPIODomain::Pin PD11{D, GPIO_PIN_11, 0b0111100110110011};
constexpr GPIODomain::Pin PD12{D, GPIO_PIN_12, 0b0111110110110011};
constexpr GPIODomain::Pin PD13{D, GPIO_PIN_13, 0b0111110110110011};
Expand All @@ -83,7 +83,7 @@ constexpr GPIODomain::Pin PE0{E, GPIO_PIN_0, 0b0111110010110011};
constexpr GPIODomain::Pin PE1{E, GPIO_PIN_1, 0b0111110010011011};
constexpr GPIODomain::Pin PE2{E, GPIO_PIN_2, 0b0110110111110011};
constexpr GPIODomain::Pin PE3{E, GPIO_PIN_3, 0b0110110111110011};
constexpr GPIODomain::Pin PE4{E, GPIO_PIN_4, 0b0110110111111111};
constexpr GPIODomain::Pin PE4{E, GPIO_PIN_4, 0b0111110111111111};
constexpr GPIODomain::Pin PE5{E, GPIO_PIN_5, 0b0110110111111011};
constexpr GPIODomain::Pin PE6{E, GPIO_PIN_6, 0b0110110111111111};
constexpr GPIODomain::Pin PE7{E, GPIO_PIN_7, 0b0111110010010011};
Expand All @@ -110,7 +110,7 @@ constexpr GPIODomain::Pin PF9{F, GPIO_PIN_9, 0b0111110010111011};
constexpr GPIODomain::Pin PF10{F, GPIO_PIN_10, 0b0110110010110011};
constexpr GPIODomain::Pin PF11{F, GPIO_PIN_11, 0b0010110010010011};
constexpr GPIODomain::Pin PF12{F, GPIO_PIN_12, 0b0010010010010011};
constexpr GPIODomain::Pin PF13{F, GPIO_PIN_13, 0b0110110010110011};
constexpr GPIODomain::Pin PF13{F, GPIO_PIN_13, 0b0111110010110011};
constexpr GPIODomain::Pin PF14{F, GPIO_PIN_14, 0b0110110010110011};
constexpr GPIODomain::Pin PF15{F, GPIO_PIN_15, 0b0010110010010011};

Expand Down
69 changes: 60 additions & 9 deletions Inc/HALAL/Models/TimerDomain/TimerDomain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,32 @@ TimerXList
Basic_6 = 6,
Basic_7 = 7,
};
enum class SelectionTrigger1 : uint32_t {
Reset = TIM_TRGO_RESET,
Enable = TIM_TRGO_ENABLE,
Update = TIM_TRGO_UPDATE,
General_Compare = TIM_TRGO_OC1,
Compare_channel1 = TIM_TRGO_OC1REF,
Compare_channel2 = TIM_TRGO_OC2REF,
Compare_channel3 = TIM_TRGO_OC3REF,
Compare_channel4 = TIM_TRGO_OC4REF
};
enum class SelectionTrigger2 : uint32_t {
Reset = TIM_TRGO2_RESET,
Enable = TIM_TRGO2_ENABLE,
Update = TIM_TRGO2_UPDATE,
General_Compare = TIM_TRGO2_OC1,
Compare_channel1 = TIM_TRGO2_OC1REF,
Compare_channel2 = TIM_TRGO2_OC2REF,
Compare_channel3 = TIM_TRGO2_OC3REF,
Compare_channel4 = TIM_TRGO2_OC4REF,
Compare_channel5 = TIM_TRGO2_OC5REF,
Compare_channel6 = TIM_TRGO2_OC6REF,
Compare_channel4_R_channel6_F = TIM_TRGO2_OC4REF_RISING_OC6REF_FALLING,
Compare_channel4_R_channel6_R = TIM_TRGO2_OC4REF_RISING_OC6REF_RISING,
Compare_channel5_R_channel6_F = TIM_TRGO2_OC5REF_RISING_OC6REF_FALLING,
Compare_channel5_R_channel6_R = TIM_TRGO2_OC5REF_RISING_OC6REF_RISING
};

// Alternate functions for timers
enum class TimerAF {
Expand Down Expand Up @@ -231,10 +257,14 @@ TimerXList
TimerRequest request;
uint8_t pin_count;
std::array<TimerPin, 7> pins; /* this won't be read in Timer constructor */
SelectionTrigger1 trgo1{SelectionTrigger1::Reset};
SelectionTrigger2 trgo2{SelectionTrigger2::Reset};
};

struct Config {
uint8_t timer_idx;
SelectionTrigger1 trgo1;
SelectionTrigger2 trgo2;
};

static constexpr TIM_HandleTypeDef* hal_handles[16] = {// general purpose timers
Expand Down Expand Up @@ -468,15 +498,17 @@ TimerXList
: e(ent.name,
ent.request,
sizeof...(pinargs),
std::array<TimerPin, 7>(
{GetPinFromIdx(pinargs, 0),
GetPinFromIdx(pinargs, 1),
GetPinFromIdx(pinargs, 2),
GetPinFromIdx(pinargs, 3),
GetPinFromIdx(pinargs, 4),
GetPinFromIdx(pinargs, 5),
GetPinFromIdx(pinargs, 6)}
)),
std::array<TimerPin, 7>({
GetPinFromIdx(pinargs, 0),
GetPinFromIdx(pinargs, 1),
GetPinFromIdx(pinargs, 2),
GetPinFromIdx(pinargs, 3),
GetPinFromIdx(pinargs, 4),
GetPinFromIdx(pinargs, 5),
GetPinFromIdx(pinargs, 6),
}),
ent.trgo1,
ent.trgo2),
gpio0(GetGPIOFromIdx(pinargs, ent.request, 0)),
gpio1(GetGPIOFromIdx(pinargs, ent.request, 1)),
gpio2(GetGPIOFromIdx(pinargs, ent.request, 2)),
Expand Down Expand Up @@ -521,6 +553,8 @@ TimerXList
.request = e.request,
.pin_count = e.pin_count,
.pins = e.pins,
.trgo1 = e.trgo1,
.trgo2 = e.trgo2
};
ctx.template add<TimerDomain>(local_entry, this);
}
Expand Down Expand Up @@ -575,6 +609,8 @@ TimerXList

Config cfg = {
.timer_idx = timer_idxmap[reqint],
.trgo1 = requests[i].trgo1,
.trgo2 = requests[i].trgo2
};
cfgs[cfg_idx++] = cfg;

Expand Down Expand Up @@ -607,6 +643,8 @@ TimerXList
uint8_t reqint = remaining_32bit_timers[count_32bit_requests];
Config cfg = {
.timer_idx = timer_idxmap[reqint],
.trgo1 = requests[i].trgo1,
.trgo2 = requests[i].trgo2
};
cfgs[cfg_idx++] = cfg;

Expand Down Expand Up @@ -656,6 +694,8 @@ TimerXList
uint8_t reqint = remaining_timers[i];
Config cfg = {
.timer_idx = timer_idxmap[reqint],
.trgo1 = requests[i].trgo1,
.trgo2 = requests[i].trgo2
};
cfgs[cfg_idx++] = cfg;
}
Expand All @@ -667,6 +707,7 @@ TimerXList
struct Instance {
TIM_TypeDef* tim;
TIM_HandleTypeDef* hal_tim;
TIM_MasterConfigTypeDef master{};
uint8_t timer_idx;
};

Expand All @@ -688,6 +729,7 @@ TimerXList

TIM_HandleTypeDef* handle = hal_handles[e.timer_idx];
TIM_TypeDef* tim = cmsis_timers[e.timer_idx];

handle->Instance = tim;
handle->Init.Period = 0;
handle->Init.Prescaler = 0;
Expand Down Expand Up @@ -717,6 +759,15 @@ TimerXList
inst->tim = tim;
inst->hal_tim = handle;
inst->timer_idx = e.timer_idx;
TIM_MasterConfigTypeDef sMasterConfig = {};
sMasterConfig.MasterOutputTrigger = static_cast<uint32_t>(e.trgo1);
sMasterConfig.MasterOutputTrigger2 = static_cast<uint32_t>(e.trgo2);
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
inst->master = sMasterConfig;
if (HAL_TIMEx_MasterConfigSynchronization(inst->hal_tim, &sMasterConfig) !=
HAL_OK) {
ErrorHandler("Unable to configure master synch");
}
}
}
};
Expand Down
10 changes: 1 addition & 9 deletions Inc/HALAL/Services/ADC/ADC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,7 @@ struct ADCDomain {
ClockPrescaler prescaler = ClockPrescaler::DIV1,
uint32_t sample_rate_hz = 0
)
: ADC(
pin,
resolution,
sample_time,
prescaler,
sample_rate_hz,
peripheral,
channel
) {}
: ADC(pin, resolution, sample_time, prescaler, sample_rate_hz, peripheral, channel) {}

template <class Ctx> consteval std::size_t inscribe(Ctx& ctx) const {
const auto gpio_idx = gpio.inscribe(ctx);
Expand Down
Loading
Loading