One is the phalanx pike infantry, which is naturally resistant to cavalry charge. If you want to resist the cavalry charge hard, he is the only one who can't be white except the same heavy cavalry. Besides, almost all other arms are white when charging, and the speed of white depends on the morale of your arms.
The second type is the shield spearmen, known as cavalry killers, with shields, which can resist long-range attacks to some extent. However, the operational idea of this unit is to "kill the horses at close range to a certain extent", and it is unrealistic to use them to resist the charge. Shield spearmen are called cavalry killers because their lethality and killing speed to cavalry are very terrible in melee, even if they are Goethe's team, the strongest cavalry with a price as high as 1050G.
According to your needs, there are actually several infantry that meet the requirements (cavalry is not considered here). As a matter of fact, none of them are soldiers with shields and spears ... I recommend some useful ones to you:
Dismount Davao: Gong Bing, or Gong Bing Pi's heavy infantry, evaded the cavalry's charge (you can think of it this way, in fact, he evaded it automatically, which is Gong Bing's talent of arms), so it can resist the charge, and it can break armor in melee, and it can quickly chop and re-ride in melee. Not for cavalry, but for all cold weapons. ...
Turkish new army: I won't say this. He is a BT infantryman who is born with a bonus to cavalry, but he can't resist the charge.
English longbow: The battlefield where a large number of longbows are located is the tomb of cavalry. See the Battle of Ginkul in the Hundred Years' War between Britain and France. (PS: the horse-refusing pile can be placed in an arc shape, and you can completely wrap your longbow troops with the horse-refusing pile)
If you are not satisfied with the above three extremely famous and fierce cavalry units and only want shield spearmen, the Hungarian giant shield spearmen upstairs are really the best choice. ...