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 /include/arch | |
parent | b3cea73a75cb46e39ed7c7e6f765fc842a40fabf (diff) |
add minimal LM4F120H5QR (LM4F120XL Stellaris Launchpad) support
Diffstat (limited to 'include/arch')
-rw-r--r-- | include/arch/lm4f120h5qr-stellaris/driver/gpio.h | 63 | ||||
-rw-r--r-- | include/arch/lm4f120h5qr-stellaris/driver/stdout.h | 24 | ||||
-rw-r--r-- | include/arch/lm4f120h5qr-stellaris/driver/uptime.h | 32 | ||||
-rw-r--r-- | include/arch/lm4f120h5qr-stellaris/lm4f_cpp_wrapper.h | 16 |
4 files changed, 135 insertions, 0 deletions
diff --git a/include/arch/lm4f120h5qr-stellaris/driver/gpio.h b/include/arch/lm4f120h5qr-stellaris/driver/gpio.h new file mode 100644 index 0000000..f71164e --- /dev/null +++ b/include/arch/lm4f120h5qr-stellaris/driver/gpio.h @@ -0,0 +1,63 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef GPIO_H +#define GPIO_H + +extern "C" { +#include "lm4f_cpp_wrapper.h" +} + +class GPIO { + private: + GPIO(const GPIO ©); + + public: + GPIO () {} + + enum Pin : unsigned char { + pa_0 = 0, pa_1, pa_2, pa_3, pa_4, pa_5, pa_6, pa_7, + pb_0, pb_1, pb_2, pb_3, pb_4, pb_5, pb_6, pb_7, + pc_0, pc_1, pc_2, pc_3, pc_4, pc_5, pc_6, pc_7, + pd_0, pd_1, pd_2, pd_3, pd_4, pd_5, pd_6, pd_7, + pe_0, pe_1, pe_2, pe_3, pe_4, pe_5, pe_6, pe_7, + pf_0, pf_1, pf_2, pf_3, pf_4, + PIN_INVALID + }; + + inline void setup() { + mp_gpio_setup(); + } + inline void led_on(unsigned char id) { + mp_gpio_write(pf_1 + id, 1); + } + inline void led_off(unsigned char id) { + mp_gpio_write(pf_1 + id, 0); + } + inline void led_toggle(unsigned char id) { + mp_gpio_write(pf_1 + id, !mp_gpio_read(pf_1 + id)); + } + inline void input(unsigned char const pin) { + mp_gpio_input(pin); + } + inline void input(unsigned char const pin, unsigned char const pull) { + } + inline void output(unsigned char const pin) { + mp_gpio_output(pin); + } + /* + inline void output(unsigned char const pin, unsigned char const value) { + }*/ + inline unsigned int read(unsigned char const pin) { + return mp_gpio_read(pin); + } + inline void write(unsigned char const pin, unsigned char value) { + mp_gpio_write(pin, value); + } +}; + +extern GPIO gpio; + +#endif diff --git a/include/arch/lm4f120h5qr-stellaris/driver/stdout.h b/include/arch/lm4f120h5qr-stellaris/driver/stdout.h new file mode 100644 index 0000000..09b18c1 --- /dev/null +++ b/include/arch/lm4f120h5qr-stellaris/driver/stdout.h @@ -0,0 +1,24 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef STANDARDOUTPUT_H +#define STANDARDOUTPUT_H + +#include "object/outputstream.h" + +class StandardOutput : public OutputStream { + private: + StandardOutput(const StandardOutput ©); + + public: + StandardOutput () {} + void setup(); + + virtual void put(char c) override; +}; + +extern StandardOutput kout; + +#endif diff --git a/include/arch/lm4f120h5qr-stellaris/driver/uptime.h b/include/arch/lm4f120h5qr-stellaris/driver/uptime.h new file mode 100644 index 0000000..4031e61 --- /dev/null +++ b/include/arch/lm4f120h5qr-stellaris/driver/uptime.h @@ -0,0 +1,32 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef UPTIME_H +#define UPTIME_H + +#include <stdint.h> + +class Uptime { + private: + Uptime(const Uptime ©); +#ifdef TIMER_S + uint32_t seconds; +#endif + + public: +#ifdef TIMER_S + Uptime () : seconds(0) {} +#else + Uptime () {} +#endif +#ifdef TIMER_S + inline uint32_t get_s() { return seconds; } + inline void tick_s() { seconds++; } +#endif +}; + +extern Uptime uptime; + +#endif diff --git a/include/arch/lm4f120h5qr-stellaris/lm4f_cpp_wrapper.h b/include/arch/lm4f120h5qr-stellaris/lm4f_cpp_wrapper.h new file mode 100644 index 0000000..739f575 --- /dev/null +++ b/include/arch/lm4f120h5qr-stellaris/lm4f_cpp_wrapper.h @@ -0,0 +1,16 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +void arch_clock_init(); +void arch_init_loop(); + +void mp_uart_setup(); +void mp_uart_send_blocking(char c); + +void mp_gpio_setup(); +void mp_gpio_input(unsigned char const pin); +void mp_gpio_output(unsigned char const pin); +unsigned int mp_gpio_read(unsigned char const pin); +void mp_gpio_write(unsigned char const pin, unsigned char value); |