This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具与软件:
在 Halcogen I2C 驱动程序代码中,i2cSend ()
void i2cSend(i2cBASE_t *i2c, uint32 length, uint8 * data) { uint32 index = i2c == i2cREG1 ? 0U : 1U; /* USER CODE BEGIN (17) */ /* USER CODE END */ if ((g_i2cTransfer_t[index].mode & (uint32)I2C_TX_INT) != 0U) { /* we are in interrupt mode */ /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */ g_i2cTransfer_t[index].data = data; /* start transmit by sending first byte */ /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */ i2c->DXR = (uint32)*g_i2cTransfer_t[index].data; /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */ g_i2cTransfer_t[index].data++; /* Length -1 since one data is written already */ g_i2cTransfer_t[index].length = (length - 1U); /* Enable Transmit Interrupt */ i2c->IMR |= (uint32)I2C_TX_INT; } else { /* send the data */ /* snipped */ } /* USER CODE BEGIN (18) */ /* USER CODE END */ }
请注意:
g_i2cTransfer_t[index].length =(length - 1u);
然后、在 ISR 中:
case 5U: /* USER CODE BEGIN (42) */ /* USER CODE END */ /* transmit */ /*SAFETYMCUSW 30 S MR:12.2,12.3 <APPROVED> "Used for data count in Transmit/Receive polling and Interrupt mode" */ if (g_i2cTransfer_t[0U].length > 0U) { i2cREG1->DXR = (uint32) *g_i2cTransfer_t[0U].data; /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */ g_i2cTransfer_t[0U].data++; g_i2cTransfer_t[0U].length--; if(g_i2cTransfer_t[0U].length == 0U) { /* Disable TX interrupt after desired data count transfered*/ i2cREG1->IMR &= (uint32)(~(uint32)I2C_TX_INT); i2cNotification(i2cREG1, (uint32)I2C_TX_INT); } } break;
请注意:
如果(g_i2cTransfer_t[0U].length > 0u)
因此,如果您发送1个字节,当 Tx 完成中断触发时,将不会调用 i2cNotification ()。
这没有太大帮助。
代码应为:
case 5U: if (g_i2cTransfer_t[0U].length > 0U) { i2cREG1->DXR = (uint32) *g_i2cTransfer_t[0U].data; /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */ g_i2cTransfer_t[0U].data++; g_i2cTransfer_t[0U].length--; } if(g_i2cTransfer_t[0U].length == 0U) { /* Disable TX interrupt after desired data count transfered*/ i2cREG1->IMR &= (uint32)(~(uint32)I2C_TX_INT); i2cNotification(i2cREG1, (uint32)I2C_TX_INT); } break;
您好、Paul、
是的、回答正确。 有一个错误、我最近在下面的主题中遇到它:
(+) RM46L852:使用 HalCoGen 构建一个非阻塞 i2c API 的建议。 -基于 Arm 的微控制器论坛-基于 Arm 的微控制器- TI E2E 支持论坛
(+) RM46L852:I2C TXRDY 中断永不触发(而 RXRDY 运行正常)-基于 Arm 的微控制器论坛-基于 Arm 的微控制器- TI E2E 支持论坛
--
谢谢。此致、
Jagadish。
哇! 它已经被告知3年多了!?
所以我们的课程是:不要信任 TI 代码:/
请注意:不信任 TI 代码:/
我们计划了对 Hercules 设备代码的刷新活动、但问题是这些设备涉及大量的安全流程。 如果我们对规范只做了很少的改动、那么我们就必须经历整个安全流程、还需要再次获得安全批准。 因此、我们现在只通过常见问题解答来记录这些问题。
您可以在 Blow FAQ 中找到所有与 Hercules 相关的错误:
(+)[常见问题解答] TMS570LC4357:Hercules 的主要常见问题解答-基于 Arm 的微控制器论坛-基于 Arm 的微控制器- TI E2E 支持论坛