stm32fxx_STURamRun.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "stm32fxx_STUlib.h"
  2. /**
  3. * @brief Initializes the pointer to the RAM for the run-time
  4. * transparent functional test.
  5. * @param : None
  6. * @retval : None
  7. */
  8. void STU_RamRunInit(void)
  9. {
  10. /* start address of the test has to be aligned to 16 address range */
  11. pRunTimeRamChk = (uint32_t *)((uint32_t)CLASS_B_START & 0xFFFFFFFCuL);
  12. pRunTimeRamChkInv = (uint32_t *)(uint32_t)(~(uint32_t)pRunTimeRamChk);
  13. }
  14. /* ---------------------------------------------------------------------------*/
  15. /**
  16. * @brief This function verifies that 4 words of RAM are functional,
  17. * overlapping) using the walkpat algorithm.
  18. * @param : None
  19. * @retval : STU_TestStatus (TEST_RUNNING, CLASS_C_DATA_FAIL,
  20. * TEST_FAILURE, TEST_OK)
  21. */
  22. STU_TestStatus STU_RamRun(void)
  23. {
  24. STU_TestStatus result = TEST_RUNNING;
  25. /* Check Class C var integrity */
  26. if ((((uint32_t)pRunTimeRamChk) ^ ((uint32_t)pRunTimeRamChkInv)) == 0xFFFFFFFFuL)
  27. {
  28. if (pRunTimeRamChk >= CLASS_B_END)
  29. {
  30. /*------------- March test applied on the RAM Buffer itself --------------- */
  31. if (STU_RamWalkpatStep(&aRunTimeRamBuf[0], &aRunTimeRamBuf[0]) == 1)
  32. {
  33. /* All the RAM test is completed successfully */
  34. result = TEST_OK;
  35. }
  36. else /* Buffer is not functional */
  37. {
  38. result = TEST_FAILURE;
  39. }
  40. /* Init next cycle of the transparent RAM test starting from the begin of the Class B area */
  41. pRunTimeRamChk = CLASS_B_START;
  42. pRunTimeRamChkInv = ((uint32_t *)~((uint32_t)CLASS_B_START));
  43. }
  44. else
  45. { /* ------------- RAM test applied on Class B data area ------------------ */
  46. /* !!! Application has to ensure that no write or read operation
  47. is performed within Class B RAM area during this test !!! */
  48. if (STU_RamWalkpatStep(pRunTimeRamChk, &aRunTimeRamBuf[0]) == 1)
  49. {
  50. /* Prepare next Row Transparent RAM test */
  51. pRunTimeRamChk += RT_RAM_BLOCKSIZE - (2u * RT_RAM_BLOCK_OVERLAP);
  52. pRunTimeRamChkInv = (uint32_t *)(uint32_t)(~(uint32_t)pRunTimeRamChk);
  53. }
  54. else
  55. {
  56. result = TEST_FAILURE; /* Word line under test was not functional */
  57. }
  58. }
  59. }
  60. else /* Class C error on pRunTimeRamChk */
  61. {
  62. result = CLASS_C_DATA_FAIL;
  63. }
  64. return (result);
  65. }
  66. /**********************END OF FILE***********************************/