MQX 4.1.1 init_gpio.c potential bug

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MQX 4.1.1 init_gpio.c potential bug

588 次查看
kubiznak_petr
Contributor V

Hi,

MQX 4.1.1 brings the following patch to the file mqx/source/bsp/twrk70f120m/init_gpio.c:

@@ -811,7 +811,11 @@

             pctl->PCR[18] = PORT_PCR_MUX(4) | PORT_PCR_ODE_MASK;

             pctl->PCR[19] = PORT_PCR_MUX(4) | PORT_PCR_ODE_MASK;

-

+            /* Enable SDA rising edge detection */

+#if BSPCFG_ENABLE_LEGACY_II2C_SLAVE

+            pctl->PCR[18] |= PORT_PCR_IRQC(0x09);

+            pctl->PCR[18] |= PORT_PCR_ISF_MASK;

+#endif

             sim->SCGC4 |= SIM_SCGC4_IIC0_MASK ;

             break;

That visually seems to me like a potential bug, even though I have not examined it thoroughly. But as there are two lines in the conditioned block, I think it was meant to configure pins 18 and 19, not twice the same pin 18. Please correct me if I am wrong.

标记 (3)
0 项奖励
回复
1 回复

353 次查看
razed11
Contributor V

That conditional is an or-equal operation. The first line is setting the IRQC field in bits 16-19 and the second is setting the ISF bit 24 for PTC18. Looks like it is to be used as an external rising-edge interrupt.

The top two lines select alt function 4 for bits 8/9 on Port C which are I2S0 functions.

0 项奖励
回复