Class polynomials attached to affine Hecke algebras were first introduced by He in [13]. They play an important role in the study of affine Deligne–Lusztig varieties. Motivated by [14], we compute the class polynomials attached to an affine Hecke algebra of type (twisted) . Using these class polynomials, we prove a conjecture of Görtz–Haines–Kottwitz–Reuman for the general linear group, unitary group, and division algebra of semisimple rank 2. Furthermore, we discuss some interesting patterns of affine Deligne–Lusztig varieties.