A rules engine acquires sensor data from sensors applied to the heart and determines whether an electrical waveform should be applied to the heart and, if so, the type of electrical waveform. A multiphase cardiac stimulus generator generates waveforms in response to the rules engine. The electrical waveform is applied to one or more electrodes implanted in or on the heart.