2018-03-06 07:07:29 +00:00
|
|
|
/* based on example from https://github.com/satoshinm/pill_blink */
|
|
|
|
|
2018-03-07 16:06:25 +00:00
|
|
|
#include "bluepill.h"
|
|
|
|
#define LED_PIN 13
|
|
|
|
|
2018-03-06 07:07:29 +00:00
|
|
|
static inline void
|
|
|
|
delay(unsigned long ms)
|
|
|
|
{
|
|
|
|
for (unsigned long i = 0; i < ms; ++i) __asm__("nop");
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
led_off() {
|
2018-03-07 16:06:25 +00:00
|
|
|
clear_pin(GPIO_C, LED_PIN);
|
2018-03-06 07:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
led_on() {
|
2018-03-07 16:06:25 +00:00
|
|
|
set_pin(GPIO_C, LED_PIN);
|
2018-03-06 07:07:29 +00:00
|
|
|
}
|
|
|
|
|
2018-03-08 03:50:01 +00:00
|
|
|
void
|
2018-03-08 00:58:06 +00:00
|
|
|
main(void)
|
|
|
|
{
|
2018-03-07 16:06:25 +00:00
|
|
|
*RCC |= (1 << 4); /* enable port C clock */
|
|
|
|
output_mode(GPIO_C, LED_PIN, OUTPUT_GPP, OUTPUT_MAX_2MHZ);
|
2018-03-08 03:50:01 +00:00
|
|
|
led_on();
|
2018-03-06 07:07:29 +00:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
led_off();
|
|
|
|
delay(1000000);
|
|
|
|
led_on();
|
|
|
|
delay(100000);
|
|
|
|
led_off();
|
|
|
|
delay(100000);
|
|
|
|
led_on();
|
|
|
|
delay(100000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|