// Reads a 16-bit adc_code from LTC2943
int8_t LTC2943_read_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
// The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
{
  int32_t ack;

  ack = i2c_read_word_data(i2c_address, adc_command, adc_code);

  return(ack);
}
예제 #2
0
// Reads a 12-bit adc_code from LTC2992
int8_t LTC2992_read_12_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
// The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
{
  // Use union type defined in Linduino.h to combine two uint8_t's (8-bit unsigned integers) into one uint16_t (unsigned 16-bit integer)
  // Then, shift by 4 bits and return in *adc_code
  int32_t ack;

  ack = i2c_read_word_data(i2c_address, adc_command, adc_code);

  *adc_code >>= 4;
  return ack;
}
예제 #3
0
파일: ecmd.c 프로젝트: Wiiilmaa/ethersex
int16_t parse_cmd_i2c_read_word_data(char *cmd, char *output, uint16_t len)
{
	uint8_t cadr;
	uint8_t dadr;
	sscanf_P(cmd, PSTR("%u %u"), &cadr, &dadr);
	if (cadr < 7 || cadr > 127)
		return ECMD_ERR_PARSE_ERROR;
	uint16_t val = i2c_read_word_data(cadr, dadr);
#ifdef ECMD_MIRROR_REQUEST
		return ECMD_FINAL(snprintf_P(output, len, PSTR("i2c rwd %d %d 0x%02X"), cadr, dadr, val));
#else
		return ECMD_FINAL(snprintf_P(output, len, PSTR("0x%02X"), val));
#endif
}