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.

CC3200 Set the pin direction and mode.



HWREG(ulPort + GPIO_O_GPIO_DIR) = ((ulPinIO & 1) ?
                                                         (HWREG(ulPort + GPIO_O_GPIO_DIR) | ucPins) :
                                                         (HWREG(ulPort + GPIO_O_GPIO_DIR) & ~(ucPins)));

请问大神这句话是什么意思?

以及在GPIOPinWrite()里面的这句话HWREG(ulPort + (GPIO_O_GPIO_DATA + (ucPins << 2))) = ucVal;是什么意思。

  • HWREG 定义如下,剩下的就是给寄存器赋值嘛。

    #define HWREG(x)  (*((volatile unsigned long *)(x)))

    HWREG(ulPort + GPIO_O_GPIO_DIR) = ((ulPinIO & 1) ?(HWREG(ulPort + GPIO_O_GPIO_DIR) | ucPins) : (HWREG(ulPort + GPIO_O_GPIO_DIR) & ~(ucPins)));

    这个就是设置GPIO的方向嘛,通过判断(ulPinIO&1)来设置为输入还是输出

  • 谢谢您,那HWREG(ulPort + (GPIO_O_GPIO_DATA + (ucPins << 2))) = ucVal,ucPins为什么要左移2位呢。

    我的MAP_GPIOPinWrite(GPIOA1_BASE,0xe,0);谢谢。