Tuning non-Markovianity by spin-dynamics control