/* Perform one write transaction. 
This writes all data in  */
static int mcux_i3c_do_one_xfer_write(I3C_Type *base, uint8_t *buf, uint8_t buf_sz, bool no_ending)
/* Perform one write transaction. 
This writes all data in  */
static int mcux_i3c_do_one_xfer_write(I3C_Type *base, uint8_t *buf, uint8_t buf_sz, bool no_ending)
{
	int offset = 0;
	int remaining = buf_sz;
	int ret = 0;
	while (remaining > 0) {
		ret = reg32_poll_timeout(&base->MDATACTRL, I3C_MDATACTRL_TXFULL_MASK, 0,
					 0, 10, 1000);
		if (ret == -ETIMEDOUT) {
			goto one_xfer_write_out;
		}
		if ((remaining > 1) || no_ending) {
			base->MWDATAB = (uint32_t)buf[offset];
		} else {
			base->MWDATABE = (uint32_t)buf[offset];
		}
		offset += 1;
		remaining -= 1;
	}
	ret = offset;
one_xfer_write_out:
	return ret;
}