mlx90614s. , ( , bcm2835 ).
"" Slaveaddress, = 0x2E (EEPROMAccess | SMBusAddressReg) data = 0x0000 ( ). "" 0x00 factory 0x5a ( - - ).
, = 0x005b, factory 0x5a 0x5b, Power Off Reset (POR), ( 0x5b) i2cdetect.
uint8_t memWriteI2C16(uint8_t SlaveAddress, uint8_t command, uint16_t data)
{
unsigned char arr[5];
uint8_t status;
arr[0] = SlaveAddress<<1;
arr[1] = command;
arr[2] = *((uint8_t *)(&data));
arr[3] = *((uint8_t *)(&data)+1);
arr[4] = crc8(&arr[0],4)&0xFF;
bcm2835_i2c_setSlaveAddress(SlaveAddress);
status = bcm2835_i2c_write (&arr[1], 4);
bcm2835_delay(5);
return (status);
}
CRC8:
uint8_t crc8(const void *vptr, int len)
{
const uint8_t *data = vptr;
unsigned crc = 0;
int i, j;
for (j = len; j; j--, data++) {
crc ^= (*data << 8);
for(i = 8; i; i--) {
if (crc & 0x8000)
crc ^= (0x1070 << 3);
crc <<= 1;
}
}
return (uint8_t)(crc >> 8);
}
: mlx90614, factory PWM. mlx90614 factory PWM I2C RPi2 i2cdetect I2C . mlx90614 bcm2835. , mlx90614 PWM-, SCL 2 . :
uint8_t mlx90614SMBusInit()
{
uint8_t SCL1 = 3;
uint8_t SCL0 = 1;
uint8_t SCL;
SCL = SCL1;
bcm2835_gpio_fsel(SCL, BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_write(SCL ,LOW);
bcm2835_delay( 3);
bcm2835_gpio_write(SCL ,HIGH);
return (1);
}
. , pwmctrl mlx90614 eeprom ( pwm SDA OpenDrain). , = 0x22 (.. EEPROMAccess | PWMCTRLAddressRegister), pwmctrl 0x0200 ( 020 ...). Reset (POR), SMBus ( I2C). Mlx90614 - ...