Averaging theory for discontinuous piecewise differential systems