Skip to content

add SPI migration guide #766

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

Merged
merged 5 commits into from
Feb 19, 2019
Merged

add SPI migration guide #766

merged 5 commits into from
Feb 19, 2019

Conversation

ithinuel
Copy link
Member

Add SPI HAL API migration guide

@@ -0,0 +1,133 @@
<h2 id="spi-port">Serial Peripheral Interface (SPI)</h2>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ithinuel : This is a HAL API doc & not a user facing API doc, correct? If so, could you please add a line in the introduction that this is only for the HAL..thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the target porting guide. All chapter that live here relate to the hal layer.
The other guides don't have any warning about that.
Should this be added to all other guides too ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ithinuel . In that case, the warning is not required. Thank you.

- `spi_free()` disables the peripheral clock.
- `spi_format()` sets :
- the number of bits per symbol
- the mode :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnotherButler : Seems to be a md formatting issue here.. mode 0 isn't being treated as a bullet point..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in next commit.


- `spi_get_module()` returns the `SPIName` unique identifier to the peripheral associated to this SPI channel.
- `spi_get_capabilities()` fills the given `spi_capabilities_t` instance
- `spi_get_capabilities()` should consider the `ssel` pin when evaluation the `support_slave_mode` capability.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SSEL pin may have different names for each target (SSEL, NCS etc).. how will this be handled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual name of the value does not matter much as what's considered by the spi_get_capabilities is the argument that's passed to it.

- `spi_format()` updates the configuration of the peripheral except the baud rate generator.
- `spi_frequency()` sets the frequency to use during the transfer.
- `spi_frequency()` returns the actual frequency that will be used.
- `spi_frequency()` updates the baud rate generator leaving other configurations unchanged.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why format() should leave baud rate generator un-touched? And the frequency() should only configure the baud rate generator? Can we have format() setting everything and frequency() change "only" the baud rate gen along with the other 2 functions above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the responsibility of spi_format is only to configure the format of the frames. Changing the baudrate generator in spi_format could be considered as a side effect as it overlaps with the dedicated method spi_frequency.

The choice of having two functions was made during the RFC process because the format is very unlikely to change during the lifetime of a spi instance while the frequency is likely to be raised after the first few exchanges with the slave peripheral.

A target must also define these elements:

- `#define SPI_COUNT (xxxxxU)`.
The number of SPI peripheral available on the device.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be helpful to provide the filename where this should be added..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have declared in PeripheralNames.h in the reference implementation but is it THE best place ?
I looked sensible to me as the driver includes hal/spi_api.h that in turn includes PeripheralNames.h.

What do you think about it ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ithinuel : Yes, I was referring to PeripheralNames.h . Can you maybe add a note in this line to add the number of peripherals there?

Copy link
Contributor

@ashok-rao ashok-rao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ithinuel .. LGTM!

@AnotherButler
Copy link
Contributor

@c1728p9 Is this ready for my review?

@c1728p9
Copy link
Contributor

c1728p9 commented Nov 13, 2018

@AnotherButler yeah, this is ready

Amanda Butler added 2 commits January 2, 2019 14:11
Copy edit file, mostly for agreement, formatting and spelling.
Add space to fix formatting.
@AnotherButler
Copy link
Contributor

Query: It looks like the Doxygen links don't work - Does that mean this is the first time we're using this feature branch? Do I need to create it?

@AnotherButler
Copy link
Contributor

ping @c1728p9

@c1728p9
Copy link
Contributor

c1728p9 commented Jan 18, 2019

@AnotherButler I think it is. Yes, please create it


You can read more about the test cases:

[![View code](https://www.mbed.com/embed/?type=library)](http://os.mbed.com/docs/development/feature-hal-spec-spi-doxy/group__hal__spi__tests.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've generated the branch, and the SPI class link earlier in the doc works. However, this one doesn't. Could you please look into it?

@AnotherButler AnotherButler merged commit 9512c56 into ARMmbed:development Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants