/** * \brief Reads data packet from slave without sending a stop condition when done * * Reads a data packet from the specified slave address on the I<SUP>2</SUP>C * bus without sending a stop condition when done, thus retaining ownership of * the bus when done. To end the transaction, a * \ref i2c_master_read_packet_wait "read" or * \ref i2c_master_write_packet_wait "write" with stop condition must be * performed. * * \note This will stall the device from any other operation. For * interrupt-driven operation, see \ref i2c_master_read_packet_job. * * \param[in,out] module Pointer to software module struct * \param[in,out] packet Pointer to I<SUP>2</SUP>C packet to transfer * * \return Status of reading packet. * \retval STATUS_OK The packet was read successfully * \retval STATUS_ERR_TIMEOUT If no response was given within * specified timeout period * \retval STATUS_ERR_DENIED If error on bus * \retval STATUS_ERR_PACKET_COLLISION If arbitration is lost * \retval STATUS_ERR_BAD_ADDRESS If slave is busy, or no slave * acknowledged the address */ enum status_code i2c_master_read_packet_wait_no_stop( struct i2c_master_module *const module, struct i2c_master_packet *const packet) { /* Sanity check */ Assert(module); Assert(module->hw); Assert(packet); #if I2C_MASTER_CALLBACK_MODE == true /* Check if the I2C module is busy with a job. */ if (module->buffer_remaining > 0) { return STATUS_BUSY; } #endif module->send_stop = false; return _i2c_master_read_packet(module, packet); }
/** * \brief Initiates a read packet operation without sending a STOP condition when done * * Reads a data packet from the specified slave address on the I<SUP>2</SUP>C bus without * sending a stop condition, thus retaining ownership of the bus when done. * To end the transaction, a \ref i2c_master_read_packet_wait "read" or * \ref i2c_master_write_packet_wait "write" with stop condition must be * performed. * * This is the non-blocking equivalent of \ref i2c_master_read_packet_wait_no_stop. * * \param[in,out] module Pointer to software module struct * \param[in,out] packet Pointer to I<SUP>2</SUP>C packet to transfer * * \return Status of starting reading I<SUP>2</SUP>C packet. * \retval STATUS_OK If reading was started successfully * \retval STATUS_BUSY If module is currently busy with another operation */ enum status_code i2c_master_read_packet_job_no_stop( struct i2c_master_module *const module, struct i2c_master_packet *const packet) { /* Sanity check */ Assert(module); Assert(module->hw); Assert(packet); /* Check if the I2C module is busy with a job */ if (module->buffer_remaining > 0) { return STATUS_BUSY; } /* Make sure we don't send STOP */ module->send_stop = false; /* Start reading */ return _i2c_master_read_packet(module, packet); }