// experi6k.c

// test
extern void show(void);

#include <dos.h>
#include <stdio.h>
#include <bios.h>

// include header with constants
#include "const6a.h"

// include header with external prototypes
#include "extern6a.h"

enum
{
  MainMotor,
  WarningLED,
  LeftArmMotor
};

void main(void)
{
  int x;
  double ontime;

  get_port(); // get the port number and establish register locations

  // make everthing an output
  set_up_ppi(Aout_CUout_Bout_CLout);

  printf("1193180/1000 = %f\n",1193180.0/1000.0);

  set_up_new_timer(1193180.0/1000.0);

  printf("frequency = %f\n",get_frequency());

  if(!pwm(MainMotor,PA0, .003, .002))
      printf("Error setting up Warning LED = %d port select = %d\n"
	,WarningLED,PA0);

  if(!pwm(WarningLED,PA1, .03, .02))
      printf("Error setting up Main Motor = %d port select = %d\n"
	,MainMotor,PA1);

  if(!pwm(LeftArmMotor,PA2, .3, .2))
      printf("Error setting up Left Arm Motor = %d port select = %d\n"
	,LeftArmMotor,PA2);

  show();  // a little test routine in timer that shows contents of nodes

  printf("press any key to end test\n");

  getch();

  // don't forget to free memory!
  FreeOutputControl();

  portaoff();

  restore_old_timer();
}

// end experi6k.c

