Skip to content

Instantly share code, notes, and snippets.

@thehans
Last active January 9, 2020 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehans/7ac8a5f5030407dd94cee5c81dbafc15 to your computer and use it in GitHub Desktop.
Save thehans/7ac8a5f5030407dd94cee5c81dbafc15 to your computer and use it in GitHub Desktop.
Example concept of setting multiple disparate pins on STM32. (updated for separate GPIOA/B/C)
GPIOB->regs->ODR ^= (((data >> 0) & 3) ^ ((GPIOB->regs->ODR >> 8) & 3)) << 8;
GPIOC->regs->ODR ^= (((data >> 2) & 7) ^ ((GPIOC->regs->ODR >>13) & 7)) <<13;
GPIOA->regs->ODR ^= (((data >> 5) & 7) ^ ((GPIOA->regs->ODR >> 0) & 7)) << 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment