/* Testprogramm zum Ansprechen des CMPS03 Kompassmoduls von Devantech Das Programm nutzt den I2C-Treiber aus der Datei i2c_hb_expbrd.ic. Die Datei "i2c_hb_expbrd.ic" muss im gleichen Verzeichnis liegen. Author: Thomas Krause URL: www.krause.robotik.de URL2: www.robotik-ag.de eMail: info@krause-robotik.de eMail: thomas.krause@s1998.tu-chemnitz.de Date: Germany 04.01.2005 */ #use "i2c_hb_expbrd.ic" void kalibrieren() { printf("\n Norden press start!"); start_press(); i2c_write_2byte(192, 15, 255); //in Register 15 den Wert 255 schreiben --> Kalibrier printf("\n Osten press start!"); start_press(); i2c_write_2byte(192, 15, 255); //in Register 15 den Wert 255 schreiben --> Kalibrier printf("\n Sueden press start!"); start_press(); i2c_write_2byte(192, 15, 255); //in Register 15 den Wert 255 schreiben --> Kalibrier printf("\n Westen press start!"); start_press(); i2c_write_2byte(192, 15, 255); //in Register 15 den Wert 255 schreiben --> Kalibrier printf("\nKalib. fertig!"); } void main() { int test; // init I2C bus i2c_init(); kalibrieren(); while(!stop_button()) { // write one byte to the device with the adress 192 i2c_write_byte(192,2); // receive two byte(16 bit) from the device with the adress 192 from register 2 and 1 test = i2c_receive_2byte(192); printf("\n %d ", test); sleep(0.1); } }