Algorithm to rotate data

Something like this should work:

for (uint8_t i = 0; i < 4; i++)
  for (uint8_t j = 0; j < 4; j++)
    array_rotated[i][j] = array[3-j][i];

Or, for a single dimension array:

for (uint8_t i = 0; i < 4; i++)
  for (uint8_t j = 0; j < 4; j++)
    array_rotated[(i*4)+j] = array[((3-j)*4)+i];