Found the problem. It doesn't work with DMA. I made some small fix related to disabling DMA and it works. I suppose DMA isn't configured properly.
Giovanni, I think it has sense to add those changes to repo.
Code: Select all
diff --git a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
index 57ee6db..10d29cc 100644
--- a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
+++ b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
@@ -941,7 +941,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmarx);
+#endif^M
return MSG_TIMEOUT;
}
@@ -955,7 +957,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmarx);
+#endif^M
}
return msg;
@@ -1041,8 +1045,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif^M
return MSG_TIMEOUT;
}
@@ -1056,8 +1062,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif^M
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial/os/hal/ports/STM32/LLD/I2Cv1$ git diff hal_i2c_lld.c > hal_i2c_lld^C
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial/os/hal/ports/STM32/LLD/I2Cv1$ Giovanni^C
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial/os/hal/ports/STM32/LLD/I2Cv1$
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$ git diff hal_i2^C
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$ git diff os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
diff --git a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
index 57ee6db..10d29cc 100644
--- a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
+++ b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
@@ -941,7 +941,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmarx);
+#endif^M
return MSG_TIMEOUT;
}
@@ -955,7 +957,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmarx);
+#endif^M
}
return msg;
@@ -1041,8 +1045,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif^M
return MSG_TIMEOUT;
}
@@ -1056,8 +1062,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA^M
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif^M
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$ git diff os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c > hal_i2c_lld.patch
rluchyshyn@rluchyshynHP:~/Src/VVG/chibios_commercial$
cat hal_i2c_lld.patch
diff --git a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
index 57ee6db..10d29cc 100644
--- a/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
+++ b/os/hal/ports/STM32/LLD/I2Cv1/hal_i2c_lld.c
@@ -941,7 +941,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA
dmaStreamDisable(i2cp->dmarx);
+#endif
return MSG_TIMEOUT;
}
@@ -955,7 +957,9 @@ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA
dmaStreamDisable(i2cp->dmarx);
+#endif
}
return msg;
@@ -1041,8 +1045,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* If the system time went outside the allowed window then a timeout
condition is returned.*/
if (!osalTimeIsInRangeX(osalOsGetSystemTimeX(), start, end)) {
+#if STM32_I2C_USE_DMA
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif
return MSG_TIMEOUT;
}
@@ -1056,8 +1062,10 @@ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
/* Waits for the operation completion or a timeout.*/
msg = osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
if (msg != MSG_OK) {
+#if STM32_I2C_USE_DMA
dmaStreamDisable(i2cp->dmatx);
dmaStreamDisable(i2cp->dmarx);
+#endif
}
return msg;