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

LPC1768: Fix SPI 16-bit transfers #277

Merged
merged 7 commits into from
May 7, 2024

Conversation

multiplemonomials
Copy link
Collaborator

Summary of changes

During testing with my test shield on LPC1768, I noticed an odd issue with SPI: if I set the bus to 16-bit mode and did a transactional transfer, each byte was sent in its own 16-bit word instead of the 16-bit words going out the wire as intended. For example, if I did transfer of [0x1234, 0x5678] with SPI, the logic analyzer would see [0x0034, 0x0012, 0x0078, 0x0056].

As it turns out, this is because of a for loop in the LPC1768 spi_api that has been messed up since its inception. Regardless of what transfer width the bus was set to, it was always looping through each byte of the data and writing that byte individually to the SPI registers.

To fix this, I rewrote the for loop to use a different implementation for transfer width >8 bits. This ensures that the 16-bit words get copied correctly.

I also fixed #255 for this target by implementing spi_get_peripheral_name().

Impact of changes

Migration actions required

Documentation

None


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

CI shield SPI-basic test now passes for LPC1768

Reviewers


Base automatically changed from dev/lpc1768-static-pinmap to master May 7, 2024 07:25
@multiplemonomials multiplemonomials merged commit 1b60dda into master May 7, 2024
9 checks passed
@multiplemonomials multiplemonomials deleted the dev/lpc1768-fix-multibyte-spi branch May 7, 2024 08:00
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.

Every Mbed target should be required to implement spi_get_peripheral_name()
2 participants