From 7b5284023070b841293d0c5a6be0c6c345372cde Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 4 Dec 2017 15:19:25 +0100 Subject: Add basic system: LED GPIO on MSP430FR5969 Launchpad and faked GPIO on POSIX --- src/arch/posix/driver/gpio.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/arch/posix/driver/gpio.cc (limited to 'src/arch/posix/driver') diff --git a/src/arch/posix/driver/gpio.cc b/src/arch/posix/driver/gpio.cc new file mode 100644 index 0000000..25eed39 --- /dev/null +++ b/src/arch/posix/driver/gpio.cc @@ -0,0 +1,31 @@ +#include "driver/gpio.h" +#include + +void GPIO::led_on(unsigned char id) +{ + if (id < 8) { + printf("▶ LED %3d on\n", id); + ledstate |= (1 << id); + } +} + +void GPIO::led_off(unsigned char id) +{ + if (id < 8) { + printf("▶ LED %3d off\n", id); + ledstate &= ~(1 << id); + } +} + +void GPIO::led_toggle(unsigned char id) +{ + if (id < 8) { + if (ledstate & (1 << id)) { + led_off(id); + } else { + led_on(id); + } + } +} + +GPIO gpio; -- cgit v1.2.3