From 3d3ecf6331816461462b98dd61045572d54aac2b Mon Sep 17 00:00:00 2001 From: LEdoian Date: Fri, 15 Apr 2016 00:28:33 +0200 Subject: [PATCH] The code works better .gitignore was also added --- .gitignore | 5 +++++ main.c | 31 +++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3cd961a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.d +*.o +*.bin +*.elf +*.map diff --git a/main.c b/main.c index fcca58b..da26074 100644 --- a/main.c +++ b/main.c @@ -13,7 +13,8 @@ #include #include -#define DELAY 8000000 // Should be a second, or maybe not (second iff 8MHz clk, 1/3second if 24MHz clk) +//#define DELAY 8000000 // Should be a second, or maybe not (second iff 8MHz clk, 1/3second if 24MHz clk) // Too long!! +#define DELAY 400000 // This is bad -- it's a value that was found to be OK #define STM32F1 1 // Needed for libopencm3 void setup (void) { // All the blackbox code @@ -24,12 +25,6 @@ void setup (void) { // All the blackbox code gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO0); } -inline void wait (int ticks) { // This works in libopenocm3 examples - int i; - for (i=0;i 0) goto repeat; state = (direction == FORWARD ? (state + 1)%4 : (/*state+4-1*/ state+3)%4 ); - gpio_set(GPIOC, states[state]); //FIXME: This doesn't work, as it does not write 0s to unmentioned pins!! - gpio_clear(GPIOC, (GPIO8 | GPIO9) ^ states[state]); // Does this fix that? - - wait(DELAY); + gpio_set(GPIOC, states[state]); + gpio_clear(GPIOC, (GPIO8 | GPIO9) ^ states[state]); } return 0; }