Skip to content

Fixed three issues with the SPI driver for the LPC1549 platform: #413

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 1 commit into from
Jul 24, 2014

Conversation

lindvalla
Copy link
Contributor

  • The TXDATCTL register was used even if only the control signals were
    modified which caused extra data to be transmitted.

  • The RXDAT register does not only contain the received data, but also
    control information in bits 16 to 20. The old code did not mask out
    the control information and in rare cases that would cause the returned
    data to include too much information (i.e. received 0xaa as data but the
    function returned 0x300aa).

  • The LPC1549 uses a Switch Matrix (SWM) to allow any pin to have any
    function. This is not used in the old code which simply assigned
    the first instance of the SPI class to SPI0 and the second instance to
    SPI1. The third instance would result in a call to error().

    This behaviour is not at all working with real world examples where the
    SPI bus contains more than two peripherals. The third peripheral would
    cause the platform to end up in error().

    The solution is to modify the get_available_spi() function to first see
    if the MISO/MOSI/SCLK and SSEL pins are already configured for use as
    either SPI0 or SPI1. If the exact same pins are already used then the
    SPIx will be reused. If one or more pins are different then another
    SPIx will be used (or if both are alredy in use then error()). With this
    change it is now possible to do this:

    MyFlash f(D11,D12,D13); // Will use SPI0
    MyTemp t(D11,D12,D13); // Will use SPI0
    SDFileSystem s(D11,D12,D13,"sd"); // Will use SPI0
    MyDisplay d(D11,D12,D13); // Will use SPI0

    The old/existing code would have resulted in this

    MyFlash f(D11,D12,D13); // Will use SPI0
    MyTemp t(D11,D12,D13); // Will use SPI1
    SDFileSystem s(D11,D12,D13,"sd"); // error()
    MyDisplay d(D11,D12,D13); // Will never be called

* The TXDATCTL register was used even if only the control signals were
  modified which caused extra data to be transmitted.

* The RXDAT register does not only contain the received data, but also
  control information in bits 16 to 20. The old code did not mask out
  the control information and in rare cases that would cause the returned
  data to include too much information (i.e. received 0xaa as data but the
  function returned 0x300aa).

* The LPC1549 uses a Switch Matric (SWM) to allow any pin to have any
  function. This is not used in the old code which simply assigned
  the first instance of the SPI class to SPI0 and the second instance to
  SPI1. The third instance would result in a call to error().

  This behaviour is not at all working with real world examples where the
  SPI bus contains more than two peripherals. The third peripheral would
  cause the platform to end up in error().

  The solution is to modify the get_available_spi() function to first see
  if the MISO/MOSI/SCLK and SSEL pins are already configured for use as
  either SPI0 or SPI1. If the exact same pins are already used then the
  SPIx will be reused. If one or more pins are different then another
  SPIx will be used (or if both are alredy in use then error()). With this
  change it is now possible to do this:

  MyFlash      f(D11,D12,D13);      // Will use SPI0
  MyTemp       t(D11,D12,D13);      // Will use SPI0
  SDFileSystem s(D11,D12,D13,"sd"); // Will use SPI0
  MyDisplay    d(D11,D12,D13);      // Will use SPI0

  The old/existing code would have resulted in this

  MyFlash      f(D11,D12,D13);      // Will use SPI0
  MyTemp       t(D11,D12,D13);      // Will use SPI1
  SDFileSystem s(D11,D12,D13,"sd"); // error()
  MyDisplay    d(D11,D12,D13);      // Will never be called
bogdanm added a commit that referenced this pull request Jul 24, 2014
Fixed three issues with the SPI driver for the LPC1549 platform:
@bogdanm bogdanm merged commit 928b206 into ARMmbed:master Jul 24, 2014
@bogdanm
Copy link
Contributor

bogdanm commented Jul 24, 2014

Thanks a lot for the detailed explanation of your changes.

yogpan01 pushed a commit to yogpan01/mbed that referenced this pull request Jul 21, 2016
Updating circle script to using mbed test --compile
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.

2 participants