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.
您好!
我想使用端口 D 和 E 的常规 GPIO 功能、通常会将该端口引脚分配给特殊功能。
如何解锁该引脚并将其用作正常的输入引脚?
我需要的示例代码
此致、
尤瓦拉伊
您好!
请参阅此常见问题解答、以解锁 GPIO 的特殊引脚。
您还可以参考 C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\GPIO_JTAG 中的示例。 下面的代码片段可以将 PC[3:0]更改为 GPIO 输入。
//
//将 PC0-3更改为 GPIO 输入。
//
HWREG (GPIO_PORTC_BASE + GPIO_O_LOCK)= GPIO_LOCK_KEY;
HWREG (GPIO_PORTC_BASE + GPIO_O_CR)= 0x01;
HWREG (GPIO_PORTC_BASE + GPIO_O_AFSEL)&= 0xFE;
HWREG (GPIO_PORTC_BASE + GPIO_O_LOCK)= GPIO_LOCK_KEY;
HWREG (GPIO_PORTC_BASE + GPIO_O_CR)= 0x02;
HWREG (GPIO_PORTC_BASE + GPIO_O_AFSEL)&= 0xFD;
HWREG (GPIO_PORTC_BASE + GPIO_O_LOCK)= GPIO_LOCK_KEY;
HWREG (GPIO_PORTC_BASE + GPIO_O_CR)= 0x04;
HWREG (GPIO_PORTC_BASE + GPIO_O_AFSEL)&= 0xfb;
HWREG (GPIO_PORTC_BASE + GPIO_O_LOCK)= GPIO_LOCK_KEY;
HWREG (GPIO_PORTC_BASE + GPIO_O_CR)= 0x08;
HWREG (GPIO_PORTC_BASE + GPIO_O_AFSEL)&= 0xf7;
HWREG (GPIO_PORTC_BASE + GPIO_O_LOCK)= GPIO_LOCK_KEY;
HWREG (GPIO_PORTC_BASE + GPIO_O_CR)= 0x00;
HWREG (GPIO_PORTC_BASE + GPIO_O_LOCK)= 0;
MAP_GPIOPinTypeGPIOInput (GPIO_PORTC_BASE、(GPIO_PIN_0 | GPIO_PIN_1 |
GPIO_PIN_2 |
GPIO_PIN_3));