Subversion Repositories shark

Rev

Rev 1478 | Rev 1481 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include "kernel/kern.h"
#include "drivers/shark_keyb26.h"
#include "unistd.h"

#include "servo.h"

#define N_SEND 10000

extern int tot_send;
extern int tot_rec;

int main () {

  int res, i = 0, k;

  srand(sys_gettime(NULL));

  cprintf("(Open Com2)");
  res = servo_open(COM2, 115200);
  cprintf("(Res = %d)",res);

  cprintf("(Servo Turn On 0)");
  res = servo_turn_on(COM2, 0);
  cprintf("(Res = %d)",res);

  while(i < N_SEND) {

    cprintf("(Cycle = %d)",i);

    k = rand() % 180 - 90;

    cprintf("(Set %d)",k);
    res = servo_set_angle_sec(COM2, 0, ANGLE2SEC(k,0,0));
    cprintf("(Res = %d)",res);

    cprintf("(Get)");
    res = servo_get_angle_sec(COM2, 0);
    cprintf("(Res = %d)",res);

    i++;

  }

  servo_close(COM2);

  sys_end();

  return 0;

}