summaryrefslogtreecommitdiff
path: root/ucoo/utils
diff options
context:
space:
mode:
authorNicolas Schodet2015-04-20 16:31:13 +0200
committerNicolas Schodet2019-10-07 00:44:50 +0200
commit2b6317815bf86c80047c5d3b42602f81b8c21d01 (patch)
tree1dff127e53988fc781357400a024a8de853b9a7f /ucoo/utils
parent9901e49f990b7e1ab9646295999fc5544e388f1d (diff)
Update to new libopencm3 version
- remove f4/ from include directory - rename some SysTick registers - rename APB freq variables
Diffstat (limited to 'ucoo/utils')
-rw-r--r--ucoo/utils/delay.arm.cc30
-rw-r--r--ucoo/utils/test/test_delay.cc4
2 files changed, 17 insertions, 17 deletions
diff --git a/ucoo/utils/delay.arm.cc b/ucoo/utils/delay.arm.cc
index 294f5ea..3c66d0d 100644
--- a/ucoo/utils/delay.arm.cc
+++ b/ucoo/utils/delay.arm.cc
@@ -26,7 +26,7 @@
#include <algorithm>
#include <libopencm3/cm3/systick.h>
-#include <libopencm3/stm32/f4/rcc.h>
+#include <libopencm3/stm32/rcc.h>
namespace ucoo {
@@ -36,21 +36,21 @@ delay_us (int us)
// Horrible hack: there is no record of the current systick speed, make
// guesses based on APB2 clock. Also, suppose that frequency is a multiple
// of 1 MHz (to avoid 64 bit division).
- int systick_mhz = rcc_ppre2_frequency / (4 * 1000000);
+ int systick_mhz = rcc_apb2_frequency / (4 * 1000000);
int cycles = systick_mhz * us;
- STK_CTRL = 0;
+ STK_CSR = 0;
// Loop several times if cycles is too big for the systick timer. Some
// nanoseconds are lost every second, I can live with that, it simplifies
// code.
while (cycles)
{
int loop_cycles = std::min (1 << 24, cycles);
- STK_LOAD = loop_cycles - 1;
- STK_VAL = 0;
- STK_CTRL = STK_CTRL_ENABLE;
- while (!(STK_CTRL & STK_CTRL_COUNTFLAG))
+ STK_RVR = loop_cycles - 1;
+ STK_CVR = 0;
+ STK_CSR = STK_CSR_ENABLE;
+ while (!(STK_CSR & STK_CSR_COUNTFLAG))
;
- STK_CTRL = 0;
+ STK_CSR = 0;
cycles -= loop_cycles;
}
}
@@ -61,16 +61,16 @@ delay_ns (int ns)
// Horrible hack: there is no record of the current hclock speed, make
// guesses based on APB2 clock. Also, suppose that frequency is a multiple
// of 1 MHz (to avoid 64 bit division).
- int hclock_mhz = rcc_ppre2_frequency / (1000000 / 2);
+ int hclock_mhz = rcc_apb2_frequency / (1000000 / 2);
int cycles = (hclock_mhz * ns + 999) / 1000;
- STK_CTRL = 0;
+ STK_CSR = 0;
// Loop once, ns is supposed to be small.
- STK_LOAD = cycles - 1;
- STK_VAL = 0;
- STK_CTRL = STK_CTRL_CLKSOURCE_AHB | STK_CTRL_ENABLE;
- while (!(STK_CTRL & STK_CTRL_COUNTFLAG))
+ STK_RVR = cycles - 1;
+ STK_CVR = 0;
+ STK_CSR = STK_CSR_CLKSOURCE_AHB | STK_CSR_ENABLE;
+ while (!(STK_CSR & STK_CSR_COUNTFLAG))
;
- STK_CTRL = 0;
+ STK_CSR = 0;
}
} // namespace ucoo
diff --git a/ucoo/utils/test/test_delay.cc b/ucoo/utils/test/test_delay.cc
index 90a53e5..0894d79 100644
--- a/ucoo/utils/test/test_delay.cc
+++ b/ucoo/utils/test/test_delay.cc
@@ -24,8 +24,8 @@
#include "ucoo/utils/delay.hh"
#include "ucoo/arch/arch.hh"
-#include <libopencm3/stm32/f4/rcc.h>
-#include <libopencm3/stm32/f4/gpio.h>
+#include <libopencm3/stm32/rcc.h>
+#include <libopencm3/stm32/gpio.h>
int
main (int argc, const char **argv)