#include "PrForceSensorJr3ISA.h"
#include "PrJr3ForceISADefn.h"
#include <sys/mman.h>
#include <sys/neutrino.h>

PrForceSensorJr3ISA::PrForceSensorJr3ISA() : PrForceSensorJr3() {
    // Enable permissions for I/O access
    ThreadCtl( _NTO_TCTL_IO, 0 );
    mmap_device_io( PR_JR3_ISA_ADDR_SPACE_SIZE, PR_JR3_ISA_BASE_ADDR );

    PrForceSensorJr3::initialize();
}

unsigned short 
PrForceSensorJr3ISA::readJr3( int addr ) {
    hwIO().output2B( PR_JR3_ISA_BASE_ADDR, addr );
    delay();
    return hwIO().input2B( PR_JR3_ISA_BASE_ADDR + 2 );
}

void
PrForceSensorJr3ISA::writeJr3( int addr, int data ) {
    hwIO().output2B( PR_JR3_ISA_BASE_ADDR, addr );
    delay();
    hwIO().output2B( PR_JR3_ISA_BASE_ADDR + 2, data );
}

void
PrForceSensorJr3ISA::delay( void ) {
    int j;
    int k = 0;
    for ( j = 0; j < 2; j++ )
        k++;
}
