The Wigner function formalism is applied in describing the charge dynamics of an ultrasmall tunnel junction and (normal or superconducting) single-electron transistors. Master equations for the Wigner function of both cases, the single-electron tunnel junction and the single-electron transistor, are obtained in the semiclassical approximation. The obtained master equations include quasiparticle tunneling, quasiparticle-pair interference tunneling, and Cooper-pair tunneling. For the normal tunnel junction or the normal single-electron transistor, the master equations for the Wigner function are reduced to the master equations for the classical probability density of the so-called orthodox theory.