How to Implement I2C on Chopstx?
tomli at tomli.me
tomli at tomli.me
Thu Aug 23 19:27:48 CEST 2018
> > using a high-level HAL library
> > like STM32Cube or libopencm3, I have lots of things to learn.
>
> Well, you would need to unlearn things, perhaps.
Yes, that's right. It reminds me the experience of learning Dvorak
keyboard layout during the first two months ;-)
> > I think
> > we don't need to use interrupt or DMA to implement non-blocking asynchronous
> > I2C operation, we can block the whole firmware and perform I2C reads/writes by
> > busy-waiting and polling until we finish the job.
>
> That sounds more difficult for me. Why not simply implement the
> driver by DMA with an interrupt notification for DMA finish?
>
> Do you intend to use it connecting your board through USB? If so, USB
> protocol requires the board should respond to host.
I understand the idea now. Using DMA with an interrupt allows an "event-driven"
way of development, which is easier to manage than busy-polling in a multithreaded
environment.
> I'd suggest to read chopstx/example-usb-serial and
> chopstx/contrib/usart-stm32f103.c, as well as the Chopstx Reference
> Manual.
Thanks for your advice.
I've looked through the USART code, and noticed all the reads/writes are
threaded in a producer-consumer model with a ring buffer. Is it designed
for full-deplex opeartion?
In I2C, the protocol is half-deplex with predefined message format, so I
think it's the whole driver can be implemented with a fixed-size buffer in
a single thread. Is my understanding correct?
Happy Hacking,
Tom Li
Beijing GNU/Linux User Group
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 851 bytes
Desc: Digital signature
URL: <https://lists.gnupg.org/pipermail/gnuk-users/attachments/20180824/015a7be7/attachment.sig>
More information about the Gnuk-users
mailing list