hi guys Can you explain the code below for me ? the three segments display :
the longest string of 1’s
the longest string of 0’s.
the longest alternating 1’s and 0’s.
the results are displayed on 7 segment displays called HEX0,....HEX6 on a chip with the addresses as shown in the link
Capture — imgbb.com
#define HEX3_HEX0_BASE 0x10000020
#define HEX7_HEX4_BASE 0x10000030
char seg7[10] = {0b00111111, 0b00000110, 0b01011011, 0b01001111, 0b01100110,
0b01101101, 0b01111101, 0b00000111, 0b01111111, 0b01100111}; /* first number to display 0,second1,2,3.....9*/
/* display count of number of 1's */
for (i = 0; long_1s > 9; i++)
long_1s -= 10;
*HEX3_HEX0_ptr = seg7[i] << 8;
*HEX3_HEX0_ptr |= seg7[long_1s];
/* display count of number of 0's */
for (i = 0; long_0s > 9; i++)
long_0s -= 10;
*HEX3_HEX0_ptr |= seg7[i] << 24;
*HEX3_HEX0_ptr |= seg7[long_0s] << 16;
/* display count of number of alternating 1's and 0's */
for (i = 0; long_alt > 9; i++)
long_alt -= 10;
*HEX7_HEX4_ptr = seg7[i] << 8;
*HEX7_HEX4_ptr |= seg7[long_alt];