|
| 1 | +/* |
| 2 | + * This file is part of the libopencm3 project. |
| 3 | + * |
| 4 | + * Copyright (C) 2009 Uwe Hermann <[email protected]> |
| 5 | + * Copyright (C) 2011 Stephen Caudle <[email protected]> |
| 6 | + * |
| 7 | + * This library is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Lesser General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This library is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU Lesser General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Lesser General Public License |
| 18 | + * along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +#include <libopencm3/stm32/rcc.h> |
| 22 | +#include <libopencm3/stm32/gpio.h> |
| 23 | + |
| 24 | +static void clock_setup(void) |
| 25 | +{ |
| 26 | + rcc_clock_setup_hse_3v3(&hse_25mhz_3v3[CLOCK_3V3_216MHZ]); |
| 27 | + rcc_periph_clock_enable(RCC_GPIOI); |
| 28 | +} |
| 29 | + |
| 30 | +static void gpio_setup(void) |
| 31 | +{ |
| 32 | + |
| 33 | + gpio_mode_setup(GPIOI, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO1); |
| 34 | +} |
| 35 | + |
| 36 | +int main(void) |
| 37 | +{ |
| 38 | + int i; |
| 39 | + |
| 40 | + clock_setup(); |
| 41 | + gpio_setup(); |
| 42 | + |
| 43 | + /* Blink the LED (PI1) on the board. */ |
| 44 | + while (1) { |
| 45 | + |
| 46 | + /* Using API function gpio_toggle(): */ |
| 47 | + gpio_toggle(GPIOI, GPIO1); /* LED on/off */ |
| 48 | + for (i = 0; i < 13500000; i++) { /* Wait a bit. */ |
| 49 | + __asm__("nop"); |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + return 0; |
| 54 | +} |
0 commit comments