Skip to content

Nuvoton: Fix issues with SPI #6466

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
Apr 16, 2018
Merged

Conversation

ccli8
Copy link
Contributor

@ccli8 ccli8 commented Mar 27, 2018

Description

This PR includes fixes with SPI for Nuvoton targets.

Target

  • NUMAKER_PFM_NUC472
  • NUMAKER_PFM_M453
  • NUMAKER_PFM_M487
  • NUMAKER_PFM_NANO130

Update

  1. Introduce SPI_ENABLE_SYNC/SPI_DISABLE_SYNC to simplify SPI enable/disable control.
  2. Use vector rather than SPI enable bit to judge if asynchronous transfer is on-going (spi_active).
  3. Fix SPI DMA transfer.
  4. Refine SPI code.

Pull request type

[x] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

ccli8 added 4 commits March 26, 2018 10:34
1. Disable unnecessary TX/RX threshold interrupts to avoid potential trap in DMA transfer
2. Start TX/RX DMA transfer simultaneously to fit H/W spec and avoid potential RX FIFO overflow issue
1. Remove dead code
2. Remove space in empty lines
3. Fix compile warnings
4. Fix some comments
* user shall clear the SPIEN (SPIx_CTL[0]) and confirm the SPIENSTS (SPIx_STATUS[15]) is 0
* (by SPI_DISABLE_SYNC here).
*/
__STATIC_INLINE void SPI_ENABLE_SYNC(SPI_T *spi_base)
Copy link
Contributor

Choose a reason for hiding this comment

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

static inline should do the job here (all compilers)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xc0170 Could you give more details?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xc0170 I don't know your point. Could you explain it?

Copy link
Contributor

Choose a reason for hiding this comment

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

static inline should do the job. I believe this macro comes from CMSIS that is also valid so no biggy

Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to update your PR , let us know. We shall trigger CI asap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xc0170 Yes, __STATIC_INLINE comes from CMSIS. I won't make change about it. Just trigger CI.

* To fix it, we don't enable SPI TX/RX threshold interrupts but keep SPI vector handler set to be called
* in PDMA TX/RX transfer done interrupt handlers (spi_dma_handler_tx/spi_dma_handler_rx).
*/
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove these, we should not leave #if 0 in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xc0170 I removed #if 0 in 571e890.

* To fix it, we don't enable SPI TX/RX threshold interrupts but keep SPI vector handler set to be called
* in PDMA TX/RX transfer done interrupt handlers (spi_dma_handler_tx/spi_dma_handler_rx).
*/
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

same as previously for #if 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xc0170 Same as above for #if 0.

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 11, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Apr 11, 2018

Build : SUCCESS

Build number : 1721
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6466/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Apr 11, 2018

@mbed-ci
Copy link

mbed-ci commented Apr 12, 2018

@ccli8
Copy link
Contributor Author

ccli8 commented Apr 16, 2018

@0xc0170 @cmonr Ready to merge?

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 16, 2018

@0xc0170 @cmonr Ready to merge?

Yes, should be integrated today during gatekeeping

@cmonr cmonr merged commit f73415e into ARMmbed:master Apr 16, 2018
@ccli8 ccli8 deleted the nuvoton_fix_spi branch April 17, 2018 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants