Page 1 of 2

I2S documentation

Posted: Wed Aug 12, 2015 3:15 pm
by king2
Hi!

I'm relatively new to ChibiOS, and new to ChibiOS 3.x, so please forgive me my newbie questions.

Now I'm trying to use STM32F429 with UDA1380 codec via I2S and I have found no documentation about how to do this. Yes, I know about auto-made documentation, but I have not found nor examples suitable for using, neither best practices docs.

In example (STM32F4xx/I2S) I have found some config, and some exchange process from I2S chip to MCU, but I cannot found complete docs, how to configure I2S, and what is I2SConfig (ok, second param in documentation is tx_buffer, but it is i2s_rx_buf in example).
So, it is for receiving audio or for sending?

Why palSetPadMode is called after I2S was started? Is it mistake, or it does not matter, or there are some reasons to do it this way?

It calls i2sStartExchange() function, and i2sStopExchange() when pressing a button, and, as I understand, i2sStartExchange() does exchange till i2sStopExchange() will be called. But what is i2sStartExchangeContinuous() then?

There is i2scallback() function in example that does nothing, so is it for receiving or sending or both?
What does this example, at least?!

I2SConfig have first 'mode' field. In documentation I have found that it is 'I2S mode selection' and reference to header file (ok, mode is i2smode_t).Yet another click on it and we know that it is have uint32_t type. OK, but what should I put here? Which variants? What does mean every variant? What important I have to know to use each of them (do not forget to call function doWhatINeedSuccessfully() after i2sStart(), for example :))?

Sorry for so many questions, may be there is a some hidden documentation pages, where I can found answers?
It is not for I2S only, but for other subsystems too..

Thank you in advance!

Re: I2S documentation

Posted: Wed Aug 12, 2015 3:29 pm
by Giovanni
Hi,

The I2S driver is very new so it is possible there are problems in the demo, I will review it.

About the reason for many of your questions, the answer would not be in the documentation but in the STM32 Reference Manual. For example regarding programming the pins after starting the driver, it is done this way to avoid glitches on the outputs, before starting the driver I2S/SPI clocks are disabled.

There is no i2sStartExchangeContinuous() just i2sStartExchange(), are you sure we are talking of the same thing?

Giovanni

Re: I2S documentation

Posted: Wed Aug 12, 2015 3:37 pm
by king2
Thanks for answering me!

I have updated my question, sorry, I will repeat it here:
I2SConfig have first 'mode' field. In documentation I have found that it is 'I2S mode selection' and reference to header file (ok, mode is i2smode_t).Yet another click on it and we know that it is have uint32_t type. OK, but what should I put here? Which variants? What does mean every variant? What important I have to know to use each of them (do not forget to call function doWhatINeedSuccessfully() after i2sStart(), for example :))?

I think I cannot found such answers in STM32 documentation, because it is about ChibiOS. Maybe it does mean some modes, desribed in STM32 documentation, but ok, I can think that it is mode that I should set before starting I2S, but which constants are related to it in ChibiOS?

What about i2sStartExchangeContinuous() - I have found it at http://chibios.sourceforge.net/docs/hal ... river.html ('referenced by i2sstate_t I2SDriver::state' section).

Have ChibiOS some more complex documentation except auto-generated one?

Thanks!

Re: I2S documentation

Posted: Wed Aug 12, 2015 3:47 pm
by king2
Wow. I just realized that I have referenced you at 2.5.1 documentation.
And I cannot find I2SDriver in 3.0.1 documentation.. :(

Re: I2S documentation

Posted: Wed Aug 12, 2015 3:53 pm
by Giovanni
Hi,

The documentation is extracted by the source code, if in doubt open i2s_lld.c/h and read :)

Anyway: http://chibios.sourceforge.net/docs3/ha ... _i2_s.html

Giovanni

Re: I2S documentation

Posted: Wed Aug 12, 2015 4:00 pm
by king2
Wow, you are wizard, how you did it? :)
There is no links to HAL from left menu of documentation page!

I got your point of view about documentation - best documentation is sources. :)

p.s. I'm blind dumb idiot! I missed that 3.0.0 HAL is third link on the page, just between 1.0.0 and 2.6.9 links :)

Re: I2S documentation

Posted: Wed Aug 12, 2015 4:20 pm
by Giovanni
Good point, I will add direct links to the documents from the menu on the left. It is not immediately obvious where it is.

Giovanni

Re: I2S documentation

Posted: Fri Aug 14, 2015 10:03 am
by Bendix
Since we're already talking about I2S documentation ... how do you configure the I2S MCLK frequency?
I didn't have a chance to try it out myself and play around with it yet, but I can't find any hints in the documentation.
Also, is MCLK output enabled by default?
Needless to say, I'm new to ChibiOS aswell ...

Re: I2S documentation

Posted: Fri Aug 14, 2015 10:49 am
by Giovanni
Hi,

This kind of details (configuration) are found in the STM32 Reference Manual, the HAL just initialize things in the way you specify in mcuconf.h, the meaning of those settings are STM32-specific.

Giovanni

Re: I2S documentation

Posted: Fri Aug 14, 2015 11:01 am
by king2
No, MCLK is not configured by default.
You should initialize I2S driver configuration, and tell that you want additional values to be set to registers.

For example:

Code: Select all

    // last parameter is MCKOE (0x0200) + divider (16KHz stereo / 16 bit)
    static const I2SConfig i2scfg2 = { i2s_tx_buf, NULL, I2S_BUF_SIZE, i2scallback_out, 0, 0x0200 | 13 };
    i2sStart(&I2SD2, &i2scfg2);