2020-07-06 04:57 AM
Hello,
I need to calculate checksum over a struct I have defined. Can anyone please help me with this?
The data is structured as below:
typedef struct eeprom_struct {
// char serial_number[5];
float detector_comp_ch0;
float detector_comp_ch1;
float detector_comp_ch2;
float detector_comp_ch3;
float detector_comp_ch4;
float detector_comp_ch5;
float detector_comp_ch6;
float detector_comp_ch7;
char serial_number[14];
uint checksum;
} eeprom_struct;
I know this is not directly related to STM32 MCUs, but I really need to solve this, and could not get an answer anywhere else.
Thank you in advance for your help.
Best regards,
Vouria
Solved! Go to Solution.
2020-07-08 02:11 PM
This all seems like mundane C coding,
uint sum32(int size, uint8_t *ptr)
{
uint sum = 0;
while(size--) sum += *ptr++; // sum bytes over buffer
return(sum);
}