Skip to content

Commit 7adca2d

Browse files
committed
Update Zephyr MSDK Hal based on MSDK PR: analogdevicesinc/msdk#1296
1 parent 868b3f8 commit 7adca2d

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

MAX/Libraries/PeriphDrivers/Source/I3C/i3c_reva.c

+19-3
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ int MXC_I3C_RevA_Controller_Transaction(mxc_i3c_reva_regs_t *i3c, const mxc_i3c_
582582
int ret;
583583
uint8_t readCount;
584584
uint16_t remaining;
585+
uint32_t timeout;
586+
uint32_t freq;
585587

586588
if (MXC_I3C_RevA_Controller_GetState(i3c) != MXC_V_I3C_REVA_CONT_STATUS_STATE_IDLE &&
587589
MXC_I3C_RevA_Controller_GetState(i3c) != MXC_V_I3C_REVA_CONT_STATUS_STATE_SDR_NORM) {
@@ -598,10 +600,12 @@ int MXC_I3C_RevA_Controller_Transaction(mxc_i3c_reva_regs_t *i3c, const mxc_i3c_
598600
if (!req->is_i2c) {
599601
ret = MXC_I3C_RevA_EmitStart(i3c, req->is_i2c, MXC_I3C_TRANSFER_TYPE_WRITE,
600602
MXC_I3C_BROADCAST_ADDR, 0);
601-
602603
if (ret < 0) {
603604
goto err;
604605
}
606+
freq = MXC_I3C_RevA_GetPPFrequency(i3c);
607+
} else {
608+
freq = MXC_I3C_RevA_GetI2CFrequency(i3c);
605609
}
606610

607611
/* Restart with write */
@@ -612,7 +616,13 @@ int MXC_I3C_RevA_Controller_Transaction(mxc_i3c_reva_regs_t *i3c, const mxc_i3c_
612616
goto err;
613617
}
614618

615-
ret = MXC_I3C_RevA_WriteTXFIFO(i3c, req->tx_buf, req->tx_len, true, 100);
619+
/* A simple linear estimation to find a reasonable write timeout value,
620+
proportional to clock period and buffer size. Coefficient value has
621+
been found by trial-and-error.
622+
*/
623+
timeout = (uint32_t)(40 * 1000000 / freq) * req->tx_len;
624+
625+
ret = MXC_I3C_RevA_WriteTXFIFO(i3c, req->tx_buf, req->tx_len, true, timeout);
616626
if (ret < 0) {
617627
goto err;
618628
}
@@ -633,8 +643,14 @@ int MXC_I3C_RevA_Controller_Transaction(mxc_i3c_reva_regs_t *i3c, const mxc_i3c_
633643
goto err;
634644
}
635645

646+
/* A simple linear estimation to find a reasonable read timeout value,
647+
proportional to clock period and buffer size. Coefficient value has
648+
been found by trial-and-error.
649+
*/
650+
timeout = (uint32_t)(80 * 1000000 / freq) * readCount;
651+
636652
ret = MXC_I3C_RevA_ReadRXFIFO(i3c, req->rx_buf + (req->rx_len - remaining), readCount,
637-
1000);
653+
timeout);
638654
if (ret == readCount) {
639655
remaining -= readCount;
640656
} else {

MAX/msdk_sha

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1dd47b758ae4786eb6669e110e7b1bda2c10c490
1+
1d174f0be31a18c3bbe829af7fa3d774495e7046

0 commit comments

Comments
 (0)