  While CaFeO$_3$ exhibits upon cooling a metal-insulator transition linked to
charge ordering, SrFeO$_3$ and BaFeO$_3$ keep metallic behaviors down to very
low temperatures. Moreover, alkaline-earth ferrites do not seem prone to
orbital ordering in spite of the d$^4$ formal occupancy of Fe$^{4+}$. Here,
from first-principles simulations, we show that the metal-insulator transition
of CaFeO$_3$ is structurally triggered by oxygen rotation motions as in
rare-earth nickelates. This not only further clarifies why SrFeO$_3$ and
BaFeO$_3$ remain metallic but allows us to predict that an insulating
charge-ordered phase can be induced in SrFeO$_3$ from appropriate engineering
of oxygen rotation motions. Going further, we unveil the possibility to switch
from the usual charge-ordered to an orbital-ordered insulating ground state
under moderate tensile strain in CaFeO$_3$ thin films. We rationalize the
competition between charge and orbital orderings, highlighting alternative
possible strategies to produce such a change of ground state, also relevant to
manganite and nickelate compounds.
