-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[hal] Support 16bit transfers for Spi #690
base: develop
Are you sure you want to change the base?
Conversation
I think half of the STM32 devices only have 8 or 16 bit transfers. Not sure the AVR has anything else but 8bit. I would only have two transfer functions: |
There's also |
ili9341 requires both, 8bit and 16bit. |
1ede21a
to
4d04969
Compare
This comment has been minimized.
This comment has been minimized.
14c9c88
to
321b0af
Compare
This comment has been minimized.
This comment has been minimized.
2170987
to
b7a28d7
Compare
b7a28d7
to
8a31467
Compare
9547524
to
173a426
Compare
Much better, thanks for fixing the SPI ISR. There was an lbuild option once to enable blocking SPI transfers for fast speeds, since walking up and down the call chain takes so long. An ISR may be a little slower, but at least its non-blocking. |
So then I'll add this to STMs non-DMA SPI as well.
|
791a345
to
c52261a
Compare
Ahhh... dreamed another great, apparent idea for the modernized versions of
...I ❤️ it, hope you too. The interfaces would be:
|
Ok, but let's focus on finishing this PR first before refactoring everything again. Also keep in mind that the advantage of using stl iterators is that the Iterator is an actual separate type that overloads operator++ etc to implement any kind of data access. This is generally a good idea, where an non-sequential buffer access can be abstracted. However, this only works generically with a template function, where this iterator type is known, and becomes difficult with an IRQ, which can be defined only once. You now need to use a function pointer or a virtual interface and then you are basically implementing the I2cTransaction that sucks a little. I also don't see a significant usability advantage of using |
I've looked into a "stringly-typed" printf-style generic transfer interface, which would probably result in a significantly more compact implementation, since it explicitly exposes a state-machine interface, uses a shared parser between all peripherals and that can be translated at compile-time into a trivially DMA-friendly representation. Here is a prototype for SoftwareI2C that worked in hardware. |
138c867
to
1f7c5c8
Compare
{ | ||
if constexpr ( SupportsBit16<SPI> ) | ||
SPI::setDataSize(SPI::DataSize::Bit16); | ||
SPI::transferBlocking16(rgb565.color, repeat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
16bit hardware detection works with constexpr and concept now. The concept is on top of ili9341_spi.hpp
for now, may be refined and moved closer to Spi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fancy shit I like! 👍👍👍👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jupp, the concepts concept is epic and i'm very grateful that I have only dived into the complex realms of templates after C++20
To continue: Containers with ContiguousIterator may return plain pointers for begin() and end(). These Containers come into question:
|
1f7c5c8
to
2800920
Compare
ebeead5
to
e143244
Compare
e143244
to
6697e6e
Compare
6697e6e
to
2bbf610
Compare
While solving #666 i've templatized
Spi::transfer(..)
.<std::unsigned_integral T>
now controls wether to send uint8_t or uint16_t.It was a small step to make it work in bit-resolution so i've changed the argument to<int Bits>
.When sending uint16_t data with 16-bit. most of these
fromBigEndian(...)
sanities, spreaded overmodm::drivers
become obsolete. Moreover there's kind of Spi-integrated 'endianess' by varying 8 and 16 bits:Transfer same data with 8 and 16 bits. No DMA for clarity
Same with DMA
For
driver::Touch2046
it's code beautyfication first hand but also good for performance.-> See 2nd commit
Sending
color::Rgb565
(uint16_t underlying) with true 16-bit Spi and getting rid of all these endianess sanities is extremely healthy fordriver::ili9341
performance-> Fixed in 3rd commit.
I've spotted lot's of endianess sanities in I2c driven devices. Gonna see if the recipe applies here too.
ToDo