Add CMSIS bluepill blink.

This commit is contained in:
2018-12-29 07:05:25 -08:00
parent f4645e0598
commit 1969718a5a
6 changed files with 149 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#include "stm32f1xx.h"
#define LEDPORT (GPIOC)
#define LED1 (13)
#define ENABLE_GPIO_CLOCK (RCC->APB2ENR |= RCC_APB2ENR_IOPCEN)
#define _MODER CRH
#define GPIOMODER (GPIO_CRH_MODE13_0)
void
ms_delay(int ms)
{
while (ms-- > 0) {
volatile int x=500;
while (x-- > 0)
__asm("nop");
}
}
// Alternates blue and green LEDs quickly
int
main(void)
{
ENABLE_GPIO_CLOCK; // enable the clock to GPIO
LEDPORT->_MODER |= GPIOMODER; // set pins to be general purpose output
for (;;) {
ms_delay(500);
LEDPORT->ODR ^= (1<<LED1); // toggle diodes
}
return 0;
}