denchetmatthoi
Trứng gà
Cho em hỏi về GPIODirModeSet. Trong bài giảng có 2 ví dụ nhỏ
1.Cấu hình PinPF1 làm output và xuất gtri mức 1
//PortF Enable
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//Config GPIO PF1 as an Output
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
//Write value
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0xFF);
2.Cấu hình PinPF4 làm input và đọc giá trị
//Enable PortF
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//Config Pin PF4 as a digital input, 2mA drive, pull -up resistor
GPIODirModeSet(GPIO_PORTF_BASE, SW1|SW2, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(GPIO_PORTF_BASE, SW1|SW2, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
//Read PF4
read=GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_4);
Tại sao trong ví dụ 1 thì không cần dùng tới GPIODirModeSet còn ví dụ 2 thì vẫn dùng bình thường
Em cám ơn nhìu
1.Cấu hình PinPF1 làm output và xuất gtri mức 1
//PortF Enable
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//Config GPIO PF1 as an Output
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
//Write value
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0xFF);
2.Cấu hình PinPF4 làm input và đọc giá trị
//Enable PortF
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
//Config Pin PF4 as a digital input, 2mA drive, pull -up resistor
GPIODirModeSet(GPIO_PORTF_BASE, SW1|SW2, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(GPIO_PORTF_BASE, SW1|SW2, GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
//Read PF4
read=GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_4);
Tại sao trong ví dụ 1 thì không cần dùng tới GPIODirModeSet còn ví dụ 2 thì vẫn dùng bình thường

Em cám ơn nhìu
