In reading the DMA code and tracking it in the datasheet, I noticed that the trigger setup is misleading. Specifically,
Normally, a class function is assumed to work primarily within its own object, so a function that says to trigger on another channel's activity or completion suggests that I can have a wide fan-out of multiple other transfers triggered from that same activity or completion, simply by passing the same DMA management object to all of them:
Effectively, "I should watch this other channel, while it has no idea." And in fact I did design a complex structure around that ability before I noticed that it wouldn't work.
But the hardware actually has the trigger going the opposite direction: a minor or major loop completion triggers one other channel. And indeed the trigger setup functions work primarily on the object that is passed to them instead of on their own. Effectively, "Hey you, trigger me."
So what I think should exist is simply a swap between the passed objects and their own. Effectively, "I should trigger this other channel." And possibly a note against calling it multiple times to create a fan-out:
What's the difference beyond semantics? The assumption that only the function's
I can see why the existing functions are how they are - the HardwareEvents and Continuous triggers have that same mentality and the hardware does seem to work that way for them - and it doesn't add anything technical to have both - it's just swapping two pointers and then un-swapping them by how the function is called - but I think it would reduce some confusion to encourage the second and eventually deprecate the first.
triggerAtTransfersOf and triggerAtCompletionOf.Normally, a class function is assumed to work primarily within its own object, so a function that says to trigger on another channel's activity or completion suggests that I can have a wide fan-out of multiple other transfers triggered from that same activity or completion, simply by passing the same DMA management object to all of them:
C++:
channel_B.triggerAtCompletionOf(TCD_A);
channel_C.triggerAtCompletionOf(TCD_A);
channel_D.triggerAtCompletionOf(TCD_A);
//etc.
But the hardware actually has the trigger going the opposite direction: a minor or major loop completion triggers one other channel. And indeed the trigger setup functions work primarily on the object that is passed to them instead of on their own. Effectively, "Hey you, trigger me."
So what I think should exist is simply a swap between the passed objects and their own. Effectively, "I should trigger this other channel." And possibly a note against calling it multiple times to create a fan-out:
C++:
TCD_A.triggerOneChannelAtCompletion(channel_B);
TCD_A.triggerOneChannelAtCompletion(channel_C);
TCD_A.triggerOneChannelAtCompletion(channel_D);
//etc.
What's the difference beyond semantics? The assumption that only the function's
this object is affected. In the first example, the possibility of a large fan-out feels far more contractual than in the second. Especially since the second can explicitly say OneChannel with a double-singular.I can see why the existing functions are how they are - the HardwareEvents and Continuous triggers have that same mentality and the hardware does seem to work that way for them - and it doesn't add anything technical to have both - it's just swapping two pointers and then un-swapping them by how the function is called - but I think it would reduce some confusion to encourage the second and eventually deprecate the first.