Stability analysis and controller synthesis for a class of piecewise smooth systems