comparison OtherSources/data_central_mini.c @ 1048:493a5903ec20 GasConsumption

Merge with 9d9d506a82d3162b6b2323819cc08652887d7dd4 (Bootloader)
author Ideenmodellierer
date Sat, 15 Nov 2025 19:29:44 +0100
parents 7801c5d8a562
children
comparison
equal deleted inserted replaced
1047:6fb16ca39125 1048:493a5903ec20
109 } 109 }
110 110
111 111
112 uint32_t CRC_CalcBlockCRC_moreThan768000(uint32_t *buffer1, uint32_t *buffer2, uint32_t words) 112 uint32_t CRC_CalcBlockCRC_moreThan768000(uint32_t *buffer1, uint32_t *buffer2, uint32_t words)
113 { 113 {
114 cm_t crc_model; 114 cm_t crc_model;
115 uint32_t word_to_do; 115 uint32_t word_to_do;
116 uint8_t byte_to_do; 116 uint8_t byte_to_do;
117 int i; 117 int i;
118
119 uint32_t wordCnt = 0;
118 120
119 // Values for the STM32F generator. 121 // Values for the STM32F generator.
120 122
121 crc_model.cm_width = 32; // 32-bit CRC 123 crc_model.cm_width = 32; // 32-bit CRC
122 crc_model.cm_poly = 0x04C11DB7; // CRC-32 polynomial 124 crc_model.cm_poly = 0x04C11DB7; // CRC-32 polynomial
125 crc_model.cm_refot = FALSE; // Final result is not bit-reversed 127 crc_model.cm_refot = FALSE; // Final result is not bit-reversed
126 crc_model.cm_xorot = 0x00000000; // Final result XOR'ed with this 128 crc_model.cm_xorot = 0x00000000; // Final result XOR'ed with this
127 129
128 cm_ini(&crc_model); 130 cm_ini(&crc_model);
129 131
130 while (words--) 132 do
131 { 133 {
132 // The STM32F10x hardware does 32-bit words at a time!!! 134 // The STM32F10x hardware does 32-bit words at a time!!!
133 if(words > (768000/4)) 135 if(wordCnt >= (768000/4))
134 word_to_do = *buffer2++; 136 word_to_do = *buffer2++;
135 else 137 else
136 word_to_do = *buffer1++; 138 word_to_do = *buffer1++;
137 139
138 // Do all bytes in the 32-bit word. 140 // Do all bytes in the 32-bit word.
157 word_to_do >>= 8; 159 word_to_do >>= 8;
158 } 160 }
159 161
160 cm_nxt(&crc_model, byte_to_do); 162 cm_nxt(&crc_model, byte_to_do);
161 } 163 }
162 } 164 wordCnt++;
165 } while (wordCnt != words);
163 166
164 // Return the final result. 167 // Return the final result.
165 168
166 return (cm_crc(&crc_model)); 169 return (cm_crc(&crc_model));
167 } 170 }