-
-
Save MayaPosch/1a1c93c6113a28d8cda40f2799431ce7 to your computer and use it in GitHub Desktop.
STM32 GPIO output F0/4/7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t pin2 = pin * 2; | |
instance.regs->MODER &= ~(0x3 << pin2); | |
instance.regs->MODER |= (0x1 << pin2); | |
instance.regs->PUPDR &= ~(0x3 << pin2); | |
if (pupd == GPIO_PULL_UP) { | |
instance.regs->PUPDR |= (0x1 << pin2); | |
} | |
else if (pupd == GPIO_PULL_DOWN) { | |
instance.regs->PUPDR |= (0x2 << pin2); | |
} | |
if (type == GPIO_PUSH_PULL) { | |
instance.regs->OTYPER &= ~(0x1 << pin); | |
} | |
else if (type == GPIO_OPEN_DRAIN) { | |
instance.regs->OTYPER |= (0x1 << pin); | |
} | |
if (speed == GPIO_LOW) { | |
instance.regs->OSPEEDR &= ~(0x3 << pin2); | |
} | |
else if (speed == GPIO_MID) { | |
instance.regs->OSPEEDR &= ~(0x3 << pin2); | |
instance.regs->OSPEEDR |= (0x1 << pin2); | |
} | |
else if (speed == GPIO_HIGH) { | |
instance.regs->OSPEEDR &= ~(0x3 << pin2); | |
instance.regs->OSPEEDR |= (0x3 << pin2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment