Skip to content
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

feat(Examples,PeriphDrivers)!: Add SPI v2 Target Transaction functions #662

Merged
merged 97 commits into from
Oct 2, 2023

Conversation

sihyung-maxim
Copy link
Contributor

@sihyung-maxim sihyung-maxim commented Jul 11, 2023

Description

  • Added Target Transaction feature to SPI v2 drivers.
  • Updated SPI_MasterSlave example for MAX78002 to use SPI v2 drivers. (Showcases SPI v2 working with the previous SPI API).
  • Created SPI_ControllerTarget example for MAX78002 to demo the new Controller/Target features on SPI v2.
  • Fixed DMA burst size to correspond with TX/RX Threshold as per design requirements. (Threshold + 1 = DMA burst size).
  • Blocking SPI controller (L. Master) transaction function is no longer interrupt-driven.
  • Clarification: The controller (master) callback function is called within the interrupt handler at the end of the transaction (unlike RevA1).
  • Fixed AI87 NewHaven touchscreen support.
  • Default SPI build to SPI v1.
  • Reverted mxc_spi_req_t struct to old names.
  • Removed SW_DRV TS Control Scheme. Too much overhead and complexity.

Breaking change because there are functional differences with the interrupt handling between the previous SPI API and SPI v2 even if the function prototypes remain the same.

Estimated Timing Averages from function call to start of transaction:

SYSCLK = IPO

SPI v2

Before Excess SPI Instance Check/Asserts Removal:

  • ~30us - non-DMA Controller Transaction
  • ~19us - DMA Controller Transaction

After Excess SPI Instance Check/Asserts Removal:

  • ~27us - non-DMA Controller Transaction
  • ~16us - DMA Controller Transaction

SPI v1

  • ~57us - non-DMA Master Transaction
  • ~135us - DMA Master Transaction

Final Overhead Improvement:

  • ~52% non-DMA transaction
  • ~88% DMA transaction

Library Size:

Before Excess SPI Instance Check/Asserts Removal
image

After Excess SPI Instance Check/Asserts Removal
image

Tests:

  • Running Controller/Target transaction functions on two different SPI instances on the same board.
  • Running Controller/Target transaction functions on two different boards (one as a controller and one as a target).

Checklist Before Requesting Review

  • PR Title follows correct guidelines.
  • Description of changes and all other relevant information.
  • (Optional) Link any related Github issues using a keyword
  • (Optional) Provide info on any relevant functional testing/validation. For API changes or significant features, this is not optional.

@sihyung-maxim
Copy link
Contributor Author

sihyung-maxim commented Jul 11, 2023

For consistency, should I rename the SPI_MasterSlave example to SPI_ControllerTarget?

@sihyung-maxim
Copy link
Contributor Author

/clang-format-run

@sihyung-maxim
Copy link
Contributor Author

Also, I just copy-pasted the porting guide/README from the SPI example to the SPI_MasterSlave. I am not sure if this is good enough, so please review it and let me know if it's enough for a user to follow.

@sihyung-maxim
Copy link
Contributor Author

For consistency, should I rename the SPI_MasterSlave example to SPI_ControllerTarget?

I renamed it.

@sihyung-maxim sihyung-maxim changed the title feat(PeriphDrivers): Add SPI v2 Target Transaction functions feat(Examples,PeriphDrivers): Add SPI v2 Target Transaction functions Jul 11, 2023
@sihyung-maxim sihyung-maxim changed the title feat(Examples,PeriphDrivers): Add SPI v2 Target Transaction functions feat(Examples,PeriphDrivers)!: Add SPI v2 Target Transaction functions Jul 11, 2023
@sihyung-maxim
Copy link
Contributor Author

For consistency, should I rename the SPI_MasterSlave example to SPI_ControllerTarget?

I renamed it.

Another idea. Should I leave the SPI_MasterSlave example using the SPI v2 Master/Slave functions to show the functional changes between the previous SPI API and SPI v2?

@sihyung-maxim
Copy link
Contributor Author

/clang-format-run

@sihyung-maxim
Copy link
Contributor Author

/clang-format-run

@sihyung-maxim
Copy link
Contributor Author

/clang-format-run

@sihyung-maxim
Copy link
Contributor Author

The SW_DRV TS control scheme made the driver too complex while still attempting to be backward compatible with SPI v1. It has lost the ease of usability at that point, so I elected to entirely remove support for that control scheme.

@sihyung-maxim
Copy link
Contributor Author

/clang-format-run

@sihyung-maxim
Copy link
Contributor Author

Ready for review, at the surface everything seems to be working but will do more testing in the morning just to be safe.

@sihyung-maxim sihyung-maxim merged commit 57cc6af into main Oct 2, 2023
8 checks passed
@sihyung-maxim sihyung-maxim deleted the dev/spi_target branch October 2, 2023 14:38
EricB-ADI pushed a commit that referenced this pull request Nov 21, 2023
…arget mode functionality (#662)

Co-authored-by: sihyung-maxim <[email protected]>
Co-authored-by: Jake Carter <[email protected]>
Co-authored-by: Jake Carter <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Change This issue or pull request involves a change to the current MSDK API MAX78002 Related to the MAX78002 (AI87) Needs Review
Projects
None yet
3 participants