  We obtain a large deviation function for the stationary measures of twisted
Brownian motions associated to the Lagrangians
$L_{\lambda}(p,v)=\frac{1}{2}g_{p}(v,v)- \lambda\omega_{p}(v)$, where $g$ is a
$C^{\infty}$ Riemannian metric in a compact surface $(M,g)$ with nonpositive
curvature, $\omega$ is a closed 1-form such that the Aubry-Mather measure of
the Lagrangian $L(p,v)=\frac{1}{2}g_{p}(v,v)-\omega_{p}(v)$ has support in a
unique closed geodesic $\gamma$; and the curvature is negative at every point
of $M$ but at the points of $\gamma$ where it is zero. We also assume that the
Aubry set is equal to the Mather set. The large deviation function is of
polynomial type, the power of the polynomial function depends on the way the
curvature goes to zero in a neighborhood of $\gamma$. This results has
interesting counterparts in one-dimensional dynamics with indifferent fixed
points and convex billiards with flat points in the boundary of the billiard. A
previous estimate by N. Anantharaman of the large deviation function in terms
of the Peierl's barrier of the Aubry-Mather measure is crucial for our result.
