/** * Read word from an i2c register * * @param reg Register to read from * * @throws std::invalid_argument in case of error * @return char read from register */ uint16_t readWordReg(uint8_t reg) { int x = mraa_i2c_read_word_data(m_i2c, reg); if (x == -1) { throw std::invalid_argument("Unknown error in I2c::readReg()"); } return (uint16_t) x; }
mrb_value mrb_mraa_i2c_read_word_reg(mrb_state *mrb, mrb_value self){ mraa_i2c_context i2c; mrb_int reg; uint16_t rdata; Data_Get_Struct(mrb, self, &mrb_mraa_i2c_ctx_type, i2c); mrb_get_args(mrb, "i", ®); rdata = mraa_i2c_read_word_data(i2c, reg); return mrb_fixnum_value(rdata); }
/** * Read word from an i2c register * * @param reg Register to read from * @return char read from register */ uint16_t readWordReg(uint8_t reg) { return mraa_i2c_read_word_data(m_i2c, reg); }