Correct the F3 examples hardfaults in rare cases, correct style

This commit is contained in:
Frantisek Burian
2014-01-01 13:41:33 +01:00
committed by Piotr Esden-Tempski
parent 3efd9f8675
commit 72c1a29779
7 changed files with 286 additions and 296 deletions

View File

@@ -23,46 +23,23 @@
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
void gpio_setup(void)
static void gpio_setup(void)
{
/* Enable GPIOE clock. */
/* Manually: */
// RCC_AHB1ENR |= RCC_AHB1ENR_IOPDEN;
/* Using API functions: */
rcc_peripheral_enable_clock(&RCC_AHBENR, RCC_AHBENR_IOPEEN);
/* Set GPIO12 (in GPIO port E) to 'output push-pull'. */
/* Manually: */
//GPIOE_CRH = (GPIO_CNF_OUTPUT_PUSHPULL << (((8 - 8) * 4) + 2));
//GPIOE_CRH |= (GPIO_MODE_OUTPUT_2_MHZ << ((8 - 8) * 4));
/* Using API functions: */
gpio_mode_setup(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12);
}
int main(void)
{
int i;
int i;
gpio_setup();
/* Blink the LED (PC8) on the board. */
while (1) {
/* Manually: */
// GPIOD_BSRR = GPIO12; /* LED off */
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
// __asm__("nop");
// GPIOD_BRR = GPIO9; /* LED on */
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
// __asm__("nop");
/* Using API functions gpio_set()/gpio_clear(): */
//gpio_set(GPIOE, GPIO9); /* LED off */
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
// __asm__("nop");
//gpio_clear(GPIOE, GPIO9); /* LED on */
// for (i = 0; i < 1000000; i++) /* Wait a bit. */
// __asm__("nop");
/* Using API function gpio_toggle(): */
gpio_toggle(GPIOE, GPIO12); /* LED on/off */
for (i = 0; i < 2000000; i++) /* Wait a bit. */