On 06/03/2019 03:56 PM, Martin Hundebøll wrote:
On 29/05/2019 18.46, Denis Kenzior wrote:
>> // off
>> l_gpio_writer_set(line, lines, 0);
>> // on
>> l_gpio_writer_set(line, lines, 1);
>> // many
>> l_gpio_writer_setv(line, 1, lines);
> That looks fine to me.
While working at implementing this, I realized that the kernel API
requires setting all lines at once, so I guess we have to settle with:
l_gpio_writer_set(struct l_gpio_writer *, uint32_t, uint32_t);
And bail out if the number of values doesn't match the number of lines
passed when creating the writer.
I think this is fine for the first iteration. But one thing occurs to
me is that since we have exclusive access to the GPIO for writing, we
still can support the vararg or offset variation by simply storing all
the values we set into the GPIO and maintain/buffer the values
persistently. So if the user provides just a single value out of N,
then we just update that value and set the whole thing in its entirety.
This can lead to a bit nicer API where you can simply do:
l_gpio_writer_set(writer, "gpio_line_label", value);
With the above, we can safely drop the whole set_one / get_one and use
the much nicer form above.