Skip to content

Instantly share code, notes, and snippets.

@ser-mk
Last active January 13, 2019 23:22
Show Gist options
  • Save ser-mk/ad66c99b9deba4bb6e937c05d6d3920f to your computer and use it in GitHub Desktop.
Save ser-mk/ad66c99b9deba4bb6e937c05d6d3920f to your computer and use it in GitHub Desktop.
C version of led blink
// Step 1: Enable the clock to PORT B
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
// Step 2: Change PB0's mode to 0x3 (output) and cfg to 0x0 (push-pull)
GPIOC->CRH = GPIO_CRH_MODE13_0 | GPIO_CRH_MODE13_1;
// Step 3: Set PB0 high
GPIOC->BSRR = GPIO_BSRR_BS13;
// Step 4: Reset PB0 low
GPIOC->BSRR = GPIO_BSRR_BR13;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment