The primary function of the gastrocnemius is plantarflexion of the ankle. Additionally, because it crosses the knee joint, it can assist in flexion of the knee.