What are the conditions for existence of the Fourier series expansion of a function $f\colon\mathbb{R}\to\mathbb{R}$

If $f\in L^1_\text{loc}(\mathbb{R})$, then on an interval $I=(a,b)$ we can define $$\hat{f}(n)=\frac{1}{b-a}\int_a^b f(x)e^{-2\pi inx/(b-a)}dx.$$ However, in order for the formal Fourier series $$S[f](x)=\sum_{-\infty}^{\infty} \hat{f}(n)e^{2\pi inx/(b-a)}$$ to converge we need more conditions on $f$. Kolmogorov proved in 1925 that there is $f\in L^1(0,2\pi)$ such that $S[f]$ diverges almost everywhere. In 1966 Carleson proved that $S[f]$ converges almost everywhere provided $f\in L^2(0,2\pi)$.


In addition to Carleson's theorem (stated by AD above), which gives a sufficient condition for pointwise convergence almost everywhere, one might also consider the following theorem about uniform convergence:

Suppose $f$ is periodic. Then, if $f$ is $\mathcal{C}^0$ and piecewise $\mathcal{C}^1$, $S_N(f)$ converges uniformly to $f$ on $\mathbb{R}$.