//#include <stdio.h>
#include <vectors.h>
#include <serial.h>
#include <isrdecl.h>  /* initialize interrupts */
#include <motor5.h>

#include <misc11.h>

unsigned char analog(unsigned char port) {
    ADCTL=port;		/* Address the selected channel */
    while((ADCTL & 0x80) != 0x80); /* Wait for A/D to finish */
    return(ADR1);		/* Return analog value */
}

void main(int k, char** argv) {
  int i, index, PW;
 
  init_motor();
  
  INIT_SERIAL;
/*  INIT_ANALOG; */

LOOP:
  CLEAR_SCREEN;
  HOME_POSITION;
  
  for(i = 0; i < NUM_MOTOR; i++) {
    printf("PA%d = %u\n", (i+3), motorPW[i]);
  }
  
  printf("\nIndex (0-4 ==> PA3-PA7): ");
  index = read_int();

  printf("Pulse Width: ");

  PW = read_int();
  motor(index, PW);

goto LOOP;
}
