system_target.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. ******************************************************************************
  3. * @file system_target.c
  4. * @author Application Team
  5. * @version V1.1.0
  6. * @date 2019-10-28
  7. * @brief system source file.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. ******************************************************************************
  12. */
  13. #include "target.h"
  14. #define NVR_REGINFOCOUNT1 (0x80400)
  15. #define NVR_REGINFOBAKOFFSET (0x100)
  16. /**
  17. * @brief Setup the microcontroller system
  18. * @note This function should be used only after reset.
  19. * @param None
  20. * @retval None
  21. */
  22. void SystemInit(void)
  23. {
  24. uint32_t i,nCount,nValue,nAddress,nChecksum;
  25. nCount = *(__IO uint32_t *)NVR_REGINFOCOUNT1;
  26. nChecksum = nCount;
  27. nChecksum = ~nChecksum;
  28. if(nChecksum != *(__IO uint32_t *)(NVR_REGINFOCOUNT1+4))
  29. {
  30. nCount = *(__IO uint32_t *)(NVR_REGINFOCOUNT1+NVR_REGINFOBAKOFFSET);
  31. nChecksum = nCount;
  32. nChecksum = ~nChecksum;
  33. if(nChecksum != *(__IO uint32_t *)(NVR_REGINFOCOUNT1+NVR_REGINFOBAKOFFSET+4))
  34. {
  35. while(1);
  36. }
  37. }
  38. for(i=0; i<nCount; i++)
  39. {
  40. nAddress = *(__IO uint32_t *)(NVR_REGINFOCOUNT1+8+i*12);
  41. nValue = *(__IO uint32_t *)(NVR_REGINFOCOUNT1+12+i*12);
  42. nChecksum = nAddress + nValue;
  43. nChecksum = ~nChecksum;
  44. if(nChecksum != *(__IO uint32_t *)(NVR_REGINFOCOUNT1+16+i*12))
  45. {
  46. nAddress = *(__IO uint32_t *)(NVR_REGINFOCOUNT1+NVR_REGINFOBAKOFFSET+8+i*12);
  47. nValue = *(__IO uint32_t *)(NVR_REGINFOCOUNT1+NVR_REGINFOBAKOFFSET+12+i*12);
  48. nChecksum = nAddress + nValue;
  49. nChecksum = ~nChecksum;
  50. if(nChecksum != *(__IO uint32_t *)(NVR_REGINFOCOUNT1+NVR_REGINFOBAKOFFSET+16+i*12))
  51. {
  52. while(1);
  53. }
  54. }
  55. if((nAddress>=0x40014800) && (nAddress<=0x40015000))
  56. {
  57. RTC_WriteRegisters(nAddress, &nValue, 1);
  58. }
  59. else
  60. {
  61. *(__IO uint32_t *)(nAddress) = nValue;
  62. }
  63. }
  64. }
  65. /**
  66. * @brief Initializes registers.
  67. * @param None
  68. * @retval None
  69. */
  70. void SystemUpdate(void)
  71. {
  72. }
  73. /*********************************** END OF FILE ******************************/