Skip to content

SPI API improvements proposals #5839

@anangl

Description

@anangl
  1. rx_bufs parameter (in spi_transceive and spi_transceive_async functions) could be declared as a pointer to a constant structure, as the content of any RX buffer structure is not (and shouldn't be) modified, only what its buf member points to is a subject to modification. This would allow to pass an array of RX buffers stored in flash as the parameter. Currently this is not possible without artificial typecasting.
  2. The same applies to config parameter in all functions exposed by this API. Although this structure can not be placed in flash (because of its dev member that is filled in runtime), it is not supposed to be modified inside SPI drivers, thus it should be marked as such.
  3. "EEPROM read mode" should be described (it is not a widely known feature) and I think this feature should be optional, since it may be troublesome to implement for some controllers. What would be wrong when a driver returns an error when it does not provide this option?
  4. spi_transceive and spi_transceive_async take too many parameters. This will be ineffective (at least on some architectures) as it will force placing some of them on stack. And some of these parameters are tightly coupled (like tx_bufs and tx_count), so it feels natural to pack them in structures (which will be constant, so they can be placed in flash). Then, if one direction of the transfer is not needed (in spi_read and spi_write) a single NULL instead of a pair NULL, 0 could be passed instead of a structure for this direction.
  5. I think it would be clearer if the asynchronous part was enabled not by CONFIG_POLL directly but by some config option with a more SPI related name that depends on POLL. This would also allow building only the synchronous part of the SPI driver in a system with POLL enabled (in case someone finds such fancy setup useful).

Metadata

Metadata

Assignees

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: APIChanges to public APIs

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions