A viable model for inflation driven by a torsion function in a Friedmann background is presented. The scalar spectral index in the interval $0.92lesssim n_{s}lesssim 0.97$ is obtained in order to satisfy the initial conditions for inflation. The post inflationary phase is also studied, and the analytical solutions obtained for scale factor and energy density generalizes that ones for a matter dominated universe, indicating just a small deviation from the standard model evolution. The same kind of torsion function used also describes satisfactorily the recent acceleration of the universe, which could indicate a possible unification of different phases, apart form specific constants.