diff --git a/STM32F4/cores/maple/io.h b/STM32F4/cores/maple/io.h index aeaf0fd..14546b8 100644 --- a/STM32F4/cores/maple/io.h +++ b/STM32F4/cores/maple/io.h @@ -121,7 +121,7 @@ void pinMode(uint8 pin, WiringPinMode mode); * @param value Either LOW (write a 0) or HIGH (write a 1). * @see pinMode() */ -void digitalWrite(uint8 pin, uint8 value); +void digitalWrite(uint8 pin, uint16 value); /** * Read a digital value from a pin. The pin must have its mode set to diff --git a/STM32F4/cores/maple/libmaple/gpio.h b/STM32F4/cores/maple/libmaple/gpio.h index dcf1151..3083247 100644 --- a/STM32F4/cores/maple/libmaple/gpio.h +++ b/STM32F4/cores/maple/libmaple/gpio.h @@ -60,10 +60,12 @@ static inline afio_exti_port gpio_exti_port(const gpio_dev *dev) { * @param val If true, set the pin. If false, reset the pin. */ static inline void gpio_write_pin(uint8_t pin, uint16 val) { + uint16_t bit = BIT(pin&0x0F); + gpio_reg_map *regs = (PIN_MAP[pin].gpio_device)->regs; if (val) { - (PIN_MAP[pin].gpio_device)->regs->BSRRL = BIT(pin&0x0F); + regs->BSRRL = bit; } else { - (PIN_MAP[pin].gpio_device)->regs->BSRRH = BIT(pin&0x0F); + regs->BSRRH = bit; } } @@ -71,10 +73,18 @@ static inline void gpio_set_pin(uint8_t pin) { (PIN_MAP[pin].gpio_device)->regs->BSRRL = BIT(pin&0x0F); } +static inline void gpio_set_dev_bit(const gpio_dev * dev, uint8_t bit) { + dev->regs->BSRRL = BIT(bit); +} + static inline void gpio_clear_pin(uint8_t pin) { (PIN_MAP[pin].gpio_device)->regs->BSRRH = BIT(pin&0x0F); } +static inline void gpio_clear_dev_bit(const gpio_dev * dev, uint8_t bit) { + dev->regs->BSRRH = BIT(bit); +} + /** * Determine whether or not a GPIO pin is set. * diff --git a/STM32F4/cores/maple/wirish_digital.cpp b/STM32F4/cores/maple/wirish_digital.cpp index 4769051..4630da7 100644 --- a/STM32F4/cores/maple/wirish_digital.cpp +++ b/STM32F4/cores/maple/wirish_digital.cpp @@ -73,14 +73,14 @@ void pinMode(uint8 pin, WiringPinMode mode) { } gpio_set_mode(pin, outputMode); - +/* if (PIN_MAP[pin].timer_device != NULL) { - /* Enable/disable timer channels if we're switching into or - * out of PWM. */ + // Enable/disable timer channels if we're switching into or out of PWM. timer_set_mode(PIN_MAP[pin].timer_device, PIN_MAP[pin].timer_channel, pwm ? TIMER_PWM : TIMER_DISABLED); } +*/ }