/*! Send positive acknowledge afterwards if <acknowledge> is true, else send negative one */ static status_t receive_byte(const i2c_bus *bus, uint8 *resultByte, bool acknowledge) { uint8 byte = 0; int i; // pull clock low to let slave wait for us bus->set_signals(bus->cookie, 0, 1); for (i = 7; i >= 0; i--) { bool bit; status_t status = receive_bit(bus, &bit, i == 7 ? bus->timing.byte_timeout : bus->timing.bit_timeout); if (status != B_OK) return status; byte = (byte << 1) | bit; } //SHOW_FLOW(3, "%x ", byte); *resultByte = byte; return send_bit(bus, acknowledge ? 0 : 1, bus->timing.bit_timeout); }
inline void im6402_device::receive() { int bit = 1; if (m_in_rri_func.isnull()) { bit = get_in_data_bit(); } else { bit = m_in_rri_func(); } receive_bit(bit); }
irom static i2c_error_t receive_ack(bool_t *ack) { i2c_error_t error; bool_t bit; if((state != i2c_state_address_ack_receive) && (state != i2c_state_data_send_ack_receive)) return(i2c_error_invalid_state_not_receive_ack); if((error = receive_bit(&bit)) != i2c_error_ok) return(error); *ack = !bit; return(i2c_error_ok); }
irom static i2c_error_t receive_byte(uint8_t *byte) { int current; bool_t bit; i2c_error_t error; for(*byte = 0, current = 8; current > 0; current--) { *byte <<= 1; if((error = receive_bit(&bit)) != i2c_error_ok) return(error); if(bit) *byte |= 0x01; } return(i2c_error_ok); }
void im6402_device::input_callback(UINT8 state) { int bit = (state & SERIAL_STATE_RX_DATA) ? 1 : 0; receive_bit(bit); }