Skip to content

Commit 04cf037

Browse files
committed
digital IO write optimizations for 16bit parallel display types
- digitalWrite value increased to 16 bit width - added IO device bit access functions - removed PWM enable/disable from pinMode()
1 parent b8afde0 commit 04cf037

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

STM32F4/cores/maple/io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void pinMode(uint8 pin, WiringPinMode mode);
121121
* @param value Either LOW (write a 0) or HIGH (write a 1).
122122
* @see pinMode()
123123
*/
124-
void digitalWrite(uint8 pin, uint8 value);
124+
void digitalWrite(uint8 pin, uint16 value);
125125

126126
/**
127127
* Read a digital value from a pin. The pin must have its mode set to

STM32F4/cores/maple/libmaple/gpio.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,31 @@ static inline afio_exti_port gpio_exti_port(const gpio_dev *dev) {
6060
* @param val If true, set the pin. If false, reset the pin.
6161
*/
6262
static inline void gpio_write_pin(uint8_t pin, uint16 val) {
63+
uint16_t bit = BIT(pin&0x0F);
64+
gpio_reg_map *regs = (PIN_MAP[pin].gpio_device)->regs;
6365
if (val) {
64-
(PIN_MAP[pin].gpio_device)->regs->BSRRL = BIT(pin&0x0F);
66+
regs->BSRRL = bit;
6567
} else {
66-
(PIN_MAP[pin].gpio_device)->regs->BSRRH = BIT(pin&0x0F);
68+
regs->BSRRH = bit;
6769
}
6870
}
6971

7072
static inline void gpio_set_pin(uint8_t pin) {
7173
(PIN_MAP[pin].gpio_device)->regs->BSRRL = BIT(pin&0x0F);
7274
}
7375

76+
static inline void gpio_set_dev_bit(const gpio_dev * dev, uint8_t bit) {
77+
dev->regs->BSRRL = BIT(bit);
78+
}
79+
7480
static inline void gpio_clear_pin(uint8_t pin) {
7581
(PIN_MAP[pin].gpio_device)->regs->BSRRH = BIT(pin&0x0F);
7682
}
7783

84+
static inline void gpio_clear_dev_bit(const gpio_dev * dev, uint8_t bit) {
85+
dev->regs->BSRRH = BIT(bit);
86+
}
87+
7888
/**
7989
* Determine whether or not a GPIO pin is set.
8090
*

STM32F4/cores/maple/wirish_digital.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ void pinMode(uint8 pin, WiringPinMode mode) {
7373
}
7474

7575
gpio_set_mode(pin, outputMode);
76-
76+
/*
7777
if (PIN_MAP[pin].timer_device != NULL) {
78-
/* Enable/disable timer channels if we're switching into or
79-
* out of PWM. */
78+
// Enable/disable timer channels if we're switching into or out of PWM.
8079
timer_set_mode(PIN_MAP[pin].timer_device,
8180
PIN_MAP[pin].timer_channel,
8281
pwm ? TIMER_PWM : TIMER_DISABLED);
8382
}
83+
*/
8484
}
8585

8686

0 commit comments

Comments
 (0)