diff options
author | Alexander Krutwig <alexander.krutwig@embedded-brains.de> | 2016-08-10 10:32:39 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-08-18 08:56:45 +0200 |
commit | fea392a35017c332d035b6fff3aeeb841402cc11 (patch) | |
tree | 4a5090def9d4c694748af38f470c5609492d4eaf | |
parent | psxtests: Adjust sporadic server tests (diff) | |
download | rtems-fea392a35017c332d035b6fff3aeeb841402cc11.tar.bz2 |
bsp/atsam: Add timeout to QSPI send command
-rw-r--r-- | c/src/lib/libbsp/arm/atsam/libraries/libchip/source/qspi.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/c/src/lib/libbsp/arm/atsam/libraries/libchip/source/qspi.c b/c/src/lib/libbsp/arm/atsam/libraries/libchip/source/qspi.c index fd9de3ae8a..c80d0dd53a 100644 --- a/c/src/lib/libbsp/arm/atsam/libraries/libchip/source/qspi.c +++ b/c/src/lib/libbsp/arm/atsam/libraries/libchip/source/qspi.c @@ -590,6 +590,7 @@ QspidStatus_t QSPI_SendCommand(Qspid_t *pQspid, uint8_t const KeepCfg) QspiInstFrame_t *const pFrame = pQspid->pQspiFrame; QspiMemCmd_t pCommand = pQspid->qspiCommand; QspidStatus_t Status = QSPI_UNKNOWN_ERROR; + uint32_t timeout = 15000; if (pFrame->InstFrame.bm.bAddrEn) QSPI_SetInstAddr(pQspid->pQspiHw, pFrame->Addr); @@ -600,7 +601,21 @@ QspidStatus_t QSPI_SendCommand(Qspid_t *pQspid, uint8_t const KeepCfg) memory_sync(); - while (!(pQspid->pQspiHw->QSPI_SR & QSPI_SR_INSTRE)); + /* + * FIXME: Timeout has been introduced due to a problem that was detected + * when QSPI_SR_INSTRE was not detected and the function is stuck in an + * endless loop. This is still an open issue. + * peripheral clock: 50Mhz -> 20 ns period time. + * timeout: set to 15000 loop cycles => 300000 ns. + * with loop instructions, the delay increases to 1ms altogether. + */ + while (!(pQspid->pQspiHw->QSPI_SR & QSPI_SR_INSTRE) && timeout > 0) { + --timeout; + } + + if (timeout == 0) { + Status = QSPI_WRITE_ERROR; + } // poll CR reg to know status if instruction has end if (!KeepCfg) |