Page 1 of 1

RMT Periperhal rmt translator set context?

Posted: Fri May 26, 2023 10:52 pm
by Xylopyrographer
Can anyone explain, for the RMT peripheral, what the function:

rmt_translator_set_context()

does?
  1. It is needed to transmit data using the RMT controller?
  2. How does it interact with the other RMT functions and structures?
Many thanks.

Re: RMT Periperhal rmt translator set context?

Posted: Sat May 27, 2023 11:48 am
by MicroController
rmt_translator_set_context can be used to set a "user context" for a specific RMT channel. This means that the void* you pass as the user context can be used for anything your custom translator callback may need as "contextual" information to perform its job. In the callback, you'd then use rmt_translator_get_context to retrieve the pointer/value you previously set for the channel that is currently calling your translator.

So,
It is needed to transmit data using the RMT controller?
No.
How does it interact with the other RMT functions and structures?
It doesn't.
It just allows you to use the same translator function for different channels at the same time and perform the translation according to different contexts you set for different channels, i.e. it allows the translator to be stateful w.r.t. each channel. If your translator callback doesn't need this kind of context information you can just ignore the set_context and get_context functions.

Re: RMT Periperhal rmt translator set context?

Posted: Sat May 27, 2023 3:00 pm
by Xylopyrographer
Thank-you for the awesome answer. Very much appreciated. Have a great one :) .