mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: targets/TARGET_NUVOTON/TARGET_M451/pinmap.c
- Revision:
- 188:bcfe06ba3d64
- Parent:
- 149:156823d33999
--- a/targets/TARGET_NUVOTON/TARGET_M451/pinmap.c Thu Sep 06 13:40:20 2018 +0100 +++ b/targets/TARGET_NUVOTON/TARGET_M451/pinmap.c Thu Nov 08 11:46:34 2018 +0000 @@ -55,29 +55,38 @@ GPIO_T *gpio_base = NU_PORT_BASE(port_index); uint32_t mode_intern = GPIO_MODE_INPUT; - + switch (mode) { - case PullUp: + case InputOnly: mode_intern = GPIO_MODE_INPUT; break; - - case PullDown: - case PullNone: - // NOTE: Not support - return; - - case PushPull: + + case PushPullOutput: mode_intern = GPIO_MODE_OUTPUT; break; - + case OpenDrain: mode_intern = GPIO_MODE_OPEN_DRAIN; break; - - case Quasi: + + case QuasiBidirectional: mode_intern = GPIO_MODE_QUASI; break; + + default: + /* H/W doesn't support separate configuration for input pull mode/direction. + * We expect upper layer would have translated input pull mode/direction + * to I/O mode */ + return; } - + GPIO_SetMode(gpio_base, 1 << pin_index, mode_intern); + + /* Invalid combinations of PinMode/PinDirection + * + * We assume developer would avoid the following combinations of PinMode/PinDirection + * which are invalid: + * 1. InputOnly/PIN_OUTPUT + * 2. PushPullOutput/PIN_INPUT + */ }