mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: targets/TARGET_NUVOTON/TARGET_NANO100/pinmap.c
- Revision:
- 188:bcfe06ba3d64
- Parent:
- 174:b96e65c34a4d
--- a/targets/TARGET_NUVOTON/TARGET_NANO100/pinmap.c Thu Sep 06 13:40:20 2018 +0100 +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/pinmap.c Thu Nov 08 11:46:34 2018 +0000 @@ -44,30 +44,35 @@ uint32_t port_index = NU_PINNAME_TO_PORT(pin); GPIO_T *gpio_base = NU_PORT_BASE(port_index); - uint32_t mode_intern = GPIO_PMD_INPUT; - + uint32_t mode_intern; + switch (mode) { - case PullUp: + case InputOnly: mode_intern = GPIO_PMD_INPUT; break; - - case PullDown: - case PullNone: - // NOTE: Not support - return; - - case PushPull: + + case PushPullOutput: mode_intern = GPIO_PMD_OUTPUT; break; - + case OpenDrain: mode_intern = GPIO_PMD_OPEN_DRAIN; break; - case Quasi: - // NOTE: Not support - 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 + */ }