I want to add an cmps03 [
http://www.robot-electronics.co.uk/htm/cmps3tech.htm -- doc] and i dont know with what to start, in pic16f877 it's look simple and easy.
Ideally I would if someone explains me how to implement it on the black-fin like an function for firmware , I have an C code [
http://www.robot-electronics.co.uk/files/cmps03_lcd03.c ] shows how to initialize the compass and how to read, if someone could help me with an idea or something more than I'm very much obliged. Thank you.
[ code ]
unsigned int get_cmps03(void)
{
unsigned int bearing;
SEN = 1; // send start bit
while(SEN); // and wait for it to clear
ACKDT = 0; // acknowledge bit
SSPIF = 0;
SSPBUF = CMPS03_ADDR; // cmps03 I2C address
while(!SSPIF); // wait for interrupt
SSPIF = 0; // then clear it.
SSPBUF = 2; // address of register to read from - high byte of result
while(!SSPIF); //
SSPIF = 0; //
RSEN = 1; // send repeated start bit
while(RSEN); // and wait for it to clear
SSPIF = 0; //
SSPBUF = CMPS03_ADDR+1; // cmps03 I2C address - with read bit set
while(!SSPIF); // wait for interrupt
SSPIF = 0; // then clear it.
RCEN = 1; // start receiving
while(!STAT_BF); // wait for high byte of bearing
bearing = SSPBUF<<8; // and get it
ACKEN = 1; // start acknowledge sequence
while(ACKEN); // wait for ack. sequence to end
RCEN = 1; // start receiving
while(!STAT_BF); // wait for low byte of bearing
bearing += SSPBUF; // and get it
ACKDT = 1; // not acknowledge for last byte
ACKEN = 1; // start acknowledge sequence
while(ACKEN); // wait for ack. sequence to end
PEN = 1; // send stop bit
while(PEN); //
return bearing;
}