#include <ezusb.h>
#include <ezregs.h>

#include "ltc1594.h"

#include "timer.h"

#define set_up()    (OUTC |=  0x10)
#define set_down()  (OUTC &= ~0x10)
#define set_pulse() {set_up();set_down();}

void mag_init()
{
  PORTCCFG &= ~0x10;
  OEC |= 0x10;
 
  ltc1594_init();
}

void mag_read()
{
  /*int ch, count;
  
  if( !(EPIO[IN4BUF_ID].cntrl & bmEPBUSY) ){  // Is the IN4BUF available,
    count = 0;
    IN4BUF[count++] = (global_ms >> 24) & 0xFF;
    IN4BUF[count++] = (global_ms >> 16) & 0xFF;
    IN4BUF[count++] = (global_ms >> 8) & 0xFF;
    IN4BUF[count++] = global_ms & 0xFF;
    for(ch = 0; ch < 3; ch++){
      u16 mag = ltc1594_read(ch);
      IN4BUF[count++] = (mag >> 8) & 0xFF;
      IN4BUF[count++] = mag & 0xFF;
    }
    EPIO[IN4BUF_ID].bytes = count;
  }*/
  
  // SET/RESET
  set_pulse();
}

