![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
LIGHT2
Diff: I2C_AS5510/I2C_AS5510.cpp
- Revision:
- 17:1865016ca2e7
- Parent:
- 0:51c43836c1d7
--- a/I2C_AS5510/I2C_AS5510.cpp Mon Sep 02 13:32:33 2019 +0000 +++ b/I2C_AS5510/I2C_AS5510.cpp Tue Sep 03 11:59:55 2019 +0000 @@ -3,18 +3,18 @@ void look_for_hardware_i2c() { - pc.printf("\r\n\n\n"); - pc.printf("Note I2C address 0x1C used by FXOS8700CQ 3-axis accelerometer and 3-axis magetometer\r\n"); - pc.printf("Start hardware search..... \r\n"); + //pc.printf("\r\n\n\n"); + //pc.printf("Note I2C address 0x1C used by FXOS8700CQ 3-axis accelerometer and 3-axis magetometer\r\n"); + //pc.printf("Start hardware search..... \r\n"); int count = 0; for (int address=12; address<256; address+=2) { if (!i2c.write(address, NULL, 0)) { // 0 returned is OK - pc.printf(" - I2C device found at address 0x%02X\n\r", address >>1); + //pc.printf(" - I2C device found at address 0x%02X\n\r", address >>1); count++; } } - pc.printf("%d devices found \n\r", count); + //pc.printf("%d devices found \n\r", count); } void init_as5510(int i2c_address) @@ -23,8 +23,8 @@ char idata[2]; int result=0; - pc.printf("\r\n"); - pc.printf("Start AS5510 init.. \r\n"); + //pc.printf("\r\n"); + //pc.printf("Start AS5510 init.. \r\n"); i2c_adrs= (i2c_address << 1); // AS5510 Slave address lsb= 0 for write @@ -37,15 +37,15 @@ idata[0]=0x0B; // Register for Sensitivity idata[1]=0x00; // Byte result= i2c.write(i2c_adrs, idata, 2, 0); // Now write_sensitivity - if (result != 0) pc.printf("No ACK bit! (09)\n\r"); +// if (result != 0) pc.printf("No ACK bit! (09)\n\r"); //----------- Operation mode selection------------------------ idata[0]=0x02; // 0x02 address setup register for operation, speed, polarity idata[1]=0x04; // Normal Operation, Slow mode (1), NORMAL Polarity (0), Power Up (0) result= i2c.write(i2c_adrs, idata, 2, 0); // Now write_operation - if (result != 0) pc.printf("No ACK bit! (11)\n\r"); +// if (result != 0) pc.printf("No ACK bit! (11)\n\r"); - pc.printf("AS5510 init done\r\n"); + //pc.printf("AS5510 init done\r\n"); } @@ -59,7 +59,7 @@ // First, now Write pointer to register 0x00---------------------------- adrss= (i2c_address << 1); // AS5510 Slave address lsb= 0 for write oresult= i2c.write(adrss, 0x00, 1, 0); // write one byte - if (oresult != 0) pc.printf("No ACK bit! (33)\n\r"); + if (oresult != 0) //pc.printf("No ACK bit! (33)\n\r"); // Second, now Read register 0x00 and 0x01-------------------------------- memset(off_data, 0, sizeof(off_data)); @@ -96,4 +96,5 @@ msb= rx_data[1]&0x03; // need only 2 low bits og MSB value = ((msb & 0x03)<<8) + lsb; // pc.printf("I2C adres= 0x%02X, Magnetic Field => msb= 0x%02X, lsb= 0x%02X, decimal 10-bit value = %u \r\n ", i2c_address, rx_data[0],rx_data[1], value); + } \ No newline at end of file