/*
  L298 -- access L298 H-bridge using connections on schip's HBsw board...
  		  including transistor switches
  This code is in some domain.
 */
#ifndef L298_h
#define L298_h

#include "Arduino.h"

//#define HBSWboard	// The original board with L298 & trans switches
					//  otherwise the HBlite board
					//  with slightly different pin usage

// define pins to which transistors are attached --
// may be used as digital or analog PWM outputs,
//  but note that PWM on TRSWB,C pins 5,6 interact with TMR0 tick timer
//  and that PWM on TRSWA,D pins 3,11 use TMR2, used by Tone library
#define TRSWA	  3	// transistor A
#define TRSWB	  5	// transistor B
#define TRSWC	  6	// transistor C
#define TRSWD	 11	// transistor D
#define LED		 13	// onboard LED, just for convenience

// define pins to which L298 is attached --
//  PWM on Aen,Ben pins 12,10 use TMR1
#define HBA_dir	 12	// channel A direction
#define HBA_en	  9	// channel A enable/PWM
#ifdef HBSWboard
#define HBB_dir	  8	// channel B direction on HBSW
#else // HBlite
#define HBB_dir	 11	// channel B direction on HBlite
#endif
#define HBB_en	 10	// channel B enable/PWM

// externs from this library
class L298
{
  public:
	L298();		// constructor to initialize stuff and nonsense
	void runFwd(uint8_t motor, uint8_t speed);
	void runBkd(uint8_t motor, uint8_t speed);
	void setSpeed(uint8_t motor, uint8_t speed);
	void stop(uint8_t motor);
};

class Trsw
{
  public:
	  Trsw();
	  void timedON( uint8_t tnum, uint16_t ticks );
};

#endif //L298_h
