diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-02-18 23:01:57 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-02-18 23:01:57 +0100 |
commit | 38f0e84d3b5da56c1441f2f779246ccf7b23d5c4 (patch) | |
tree | 9fdb70ca1393ca8de11b11e751feb12c36afb8d3 /src/arch/lm4f120h5qr-stellaris/arch.cc | |
parent | b3cea73a75cb46e39ed7c7e6f765fc842a40fabf (diff) |
add minimal LM4F120H5QR (LM4F120XL Stellaris Launchpad) support
Diffstat (limited to 'src/arch/lm4f120h5qr-stellaris/arch.cc')
-rw-r--r-- | src/arch/lm4f120h5qr-stellaris/arch.cc | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/arch/lm4f120h5qr-stellaris/arch.cc b/src/arch/lm4f120h5qr-stellaris/arch.cc new file mode 100644 index 0000000..c87af2f --- /dev/null +++ b/src/arch/lm4f120h5qr-stellaris/arch.cc @@ -0,0 +1,79 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "arch.h" + +#ifdef TIMER_S +#include "driver/uptime.h" +#endif + +extern "C" { +#include "lm4f_cpp_wrapper.h" +}; + +#ifdef __acweaving +#define __delay_cycles(x) +#endif + +void Arch::setup(void) +{ + arch_clock_init(); +#if defined(WITH_LOOP) + arch_init_loop(); +#endif +} + +#ifdef WITH_WAKEUP +extern void wakeup(); +#endif + +#if defined(WITH_LOOP) +extern void loop(); +extern volatile char run_loop; +#endif + +// for 80 MHz +void Arch::delay_us(unsigned int const us) +{ + volatile int x = us * 77; + while (x--) { + __asm("nop"); + } +} +void Arch::delay_ms(unsigned int const ms) +{ + for (unsigned int i = 0; i < ms; i++) { + volatile int x = 10000; + while (x--) { + __asm("nop"); + } + } +} + +void Arch::idle_loop(void) +{ + while (1) { + __asm__("wfi"); +#ifdef WITH_LOOP + if (run_loop) { +#ifdef TIMER_S + uptime.tick_s(); +#endif + loop(); + run_loop = 0; + } +#endif + } +} + +void Arch::idle(void) +{ + __asm__("wfi"); +#ifdef WITH_WAKEUP + wakeup(); +#endif +} + +Arch arch; |