diff --git a/drivers/gpio.c b/drivers/gpio.c index be603b4..5ef4cd1 100644 --- a/drivers/gpio.c +++ b/drivers/gpio.c @@ -48,7 +48,7 @@ void gpio_configure(enum GpioPort port, enum GpioPin pin_mask, } } regs->PORTS[port].CRL.word &= ~(0xF * mask); - regs->PORTS[port].CRL.word |= (config << 2) | (mode << 0) * mask; + regs->PORTS[port].CRL.word |= ((config << 2) | (mode << 0)) * mask; //clear config for selected port, then apply new config, 8 last pins mask = 0; @@ -61,7 +61,7 @@ void gpio_configure(enum GpioPort port, enum GpioPin pin_mask, } } regs->PORTS[port].CRH.word &= ~(0xF * mask); - regs->PORTS[port].CRH.word |= (config << 2) | (mode << 0) * mask; + regs->PORTS[port].CRH.word |= ((config << 2) | (mode << 0)) * mask; } void gpio_reset(enum GpioPort port, enum GpioPin pin_mask) @@ -85,3 +85,4 @@ bool gpio_read(enum GpioPort port, enum GpioPin pin_mask) //--local functions------------------------------------------------------------- + diff --git a/drivers/gpio.h b/drivers/gpio.h index 9e5c2a5..7a12484 100644 --- a/drivers/gpio.h +++ b/drivers/gpio.h @@ -55,8 +55,9 @@ enum GpioPin { }; /** - * Available modes for a pin. To have a pin in both modes simultaneously, see - * push-pull configuration in input mode + * Available modes for a pin. To have a pin in both modes simultaneously, use + * push-pull configuration in input mode but note that the power may be + * limited */ enum GpioMode { GPIO_MODE_INPUT = 0, @@ -66,7 +67,7 @@ enum GpioMode { }; /** - * Available configurations for a pin. Some configurations onlly apply in input + * Available configurations for a pin. Some configurations only apply in input * mode (denoted "IN") while others only apply in output mode (denoted "OUT") */ enum GpioConfig { @@ -115,3 +116,4 @@ bool gpio_read(enum GpioPort port, enum GpioPin pin_mask); #endif //_RCC_H_ +