Mercurial > public > ostc4
comparison Small_CPU/Src/RTE_FlashAccess.c @ 571:91a8f9893e68
Reactivate compass parameter stored in NVM:
The calibration parameters are stored in NVM but the automatic restore function during startup was no longer active. As result the compass needed to be calibration after every RTE update. In addition compass HW was detected at every startup causing some i2c "trouble" because of adressing not available devices. The compass HW info is now stored together with the calibration parameters to avoid i2C problems.
author | Ideenmodellierer |
---|---|
date | Wed, 25 Nov 2020 20:16:20 +0100 |
parents | 5f11787b4f42 |
children |
comparison
equal
deleted
inserted
replaced
570:701ead8dddab | 571:91a8f9893e68 |
---|---|
73 //uint8_t BFA_eraseSectorsAll(void); | 73 //uint8_t BFA_eraseSectorsAll(void); |
74 uint8_t BFA_FindLastDataBlockAndSetAddress(void); | 74 uint8_t BFA_FindLastDataBlockAndSetAddress(void); |
75 | 75 |
76 /* Exported functions --------------------------------------------------------*/ | 76 /* Exported functions --------------------------------------------------------*/ |
77 | 77 |
78 uint8_t BFA_readLastDataBlock(uint32_t *dataArray4) | 78 uint8_t BFA_readLastDataBlock(tfull32 *dataArray4) |
79 { | 79 { |
80 uint8_t answer; | 80 uint8_t answer; |
81 | 81 |
82 answer = BFA_FindLastDataBlockAndSetAddress(); | 82 answer = BFA_FindLastDataBlockAndSetAddress(); |
83 if(answer != BFA_OK) | 83 if(answer != BFA_OK) |
84 return answer; | 84 return answer; |
85 | 85 |
86 dataArray4[0] = *(__IO uint32_t*)(Address + 0); | 86 dataArray4[0].Full32 = *(__IO uint32_t*)(Address + 0); |
87 dataArray4[1] = *(__IO uint32_t*)(Address + 4); | 87 dataArray4[1].Full32 = *(__IO uint32_t*)(Address + 4); |
88 dataArray4[2] = *(__IO uint32_t*)(Address + 8); | 88 dataArray4[2].Full32 = *(__IO uint32_t*)(Address + 8); |
89 dataArray4[3] = *(__IO uint32_t*)(Address + 12); | 89 dataArray4[3].Full32 = *(__IO uint32_t*)(Address + 12); |
90 return BFA_OK; | 90 return BFA_OK; |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 uint8_t BFA_writeDataBlock(const uint32_t *dataArray4) | 94 uint8_t BFA_writeDataBlock(const tfull32 *dataArray4) |
95 { | 95 { |
96 uint8_t answer; | 96 uint8_t answer; |
97 uint32_t dataTest[4]; | 97 uint32_t dataTest[4]; |
98 uint32_t StartAddress; | 98 uint32_t StartAddress; |
99 | 99 |
126 | 126 |
127 StartAddress = Address; | 127 StartAddress = Address; |
128 HAL_FLASH_Unlock(); | 128 HAL_FLASH_Unlock(); |
129 for(int i=0;i<4;i++) | 129 for(int i=0;i<4;i++) |
130 { | 130 { |
131 answer = HAL_FLASH_Program(TYPEPROGRAM_WORD, Address, dataArray4[i]); | 131 answer = HAL_FLASH_Program(TYPEPROGRAM_WORD, Address, dataArray4[i].Full32); |
132 Address = Address + 4; | 132 Address = Address + 4; |
133 } | 133 } |
134 HAL_FLASH_Lock(); | 134 HAL_FLASH_Lock(); |
135 Address = StartAddress; // back to start of this data set (for reading etc.) | 135 Address = StartAddress; // back to start of this data set (for reading etc.) |
136 return answer; | 136 return answer; |
137 } | 137 } |
138 | 138 uint16_t BFA_calc_Block_Checksum(const tfull32 *dataArray4) |
139 { | |
140 uint16_t checksum = 0; | |
141 uint8_t loop = 0; | |
142 uint16_t* p_data = (uint16_t*)dataArray4; | |
143 | |
144 for (loop = 0; loop < 6; loop++) // calc checksum across first 6 words */ | |
145 { | |
146 checksum += *p_data; | |
147 } | |
148 return checksum; | |
149 } | |
139 | 150 |
140 /* Private functions ---------------------------------------------------------*/ | 151 /* Private functions ---------------------------------------------------------*/ |
141 /* | 152 /* |
142 uint8_t BFA_eraseSectorsAll(void) | 153 uint8_t BFA_eraseSectorsAll(void) |
143 { | 154 { |