cpu/ezr32wg/gpio: do not clear output pin on init
This commit is contained in:
parent
be456915e9
commit
7342974b17
@ -60,17 +60,21 @@ int gpio_init(gpio_t pin, gpio_mode_t mode)
|
|||||||
GPIO_P_TypeDef *port = _port(pin);
|
GPIO_P_TypeDef *port = _port(pin);
|
||||||
uint32_t pin_pos = _pin_pos(pin);
|
uint32_t pin_pos = _pin_pos(pin);
|
||||||
|
|
||||||
|
if (mode == GPIO_IN_PD) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* enable power for the GPIO module */
|
/* enable power for the GPIO module */
|
||||||
CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
|
CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
|
||||||
|
|
||||||
/* configure the mode */
|
/* configure the mode */
|
||||||
port->MODE[pin_pos >> 3] &= ~(0xf << ((pin_pos & 0x7) * 4));
|
port->MODE[pin_pos >> 3] &= ~(0xf << ((pin_pos & 0x7) * 4));
|
||||||
port->MODE[pin_pos >> 3] |= (mode << ((pin_pos & 0x7) * 4));
|
port->MODE[pin_pos >> 3] |= (mode << ((pin_pos & 0x7) * 4));
|
||||||
/* reset output register */
|
|
||||||
port->DOUTCLR = (1 << pin_pos);
|
|
||||||
/* if input with pull-up, set the data out register */
|
/* if input with pull-up, set the data out register */
|
||||||
if (mode == GPIO_IN_PU) {
|
if (mode == GPIO_IN_PU) {
|
||||||
port->DOUTSET = (1 << pin_pos);
|
port->DOUTSET = (1 << pin_pos);
|
||||||
|
} else if (mode == GPIO_IN) {
|
||||||
|
port->DOUTCLR = (1 << pin_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user