summaryrefslogtreecommitdiff
path: root/src/arch/msp430fr5969lp/driver/gpio.cc
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2017-12-04 15:19:25 +0100
committerDaniel Friesel <derf@finalrewind.org>2017-12-04 15:19:25 +0100
commit7b5284023070b841293d0c5a6be0c6c345372cde (patch)
tree5f2c70451cf61ef6744813cac3a221cef210b213 /src/arch/msp430fr5969lp/driver/gpio.cc
Add basic system: LED GPIO on MSP430FR5969 Launchpad and faked GPIO on POSIX
Diffstat (limited to 'src/arch/msp430fr5969lp/driver/gpio.cc')
-rw-r--r--src/arch/msp430fr5969lp/driver/gpio.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/arch/msp430fr5969lp/driver/gpio.cc b/src/arch/msp430fr5969lp/driver/gpio.cc
new file mode 100644
index 0000000..e1179af
--- /dev/null
+++ b/src/arch/msp430fr5969lp/driver/gpio.cc
@@ -0,0 +1,43 @@
+#include "driver/gpio.h"
+#include <msp430.h>
+
+void GPIO::setup()
+{
+ P1OUT = 0;
+ P2OUT = 0;
+ P3OUT = 0;
+ P4OUT = 0;
+ P1DIR = BIT0;
+ P2DIR = 0;
+ P3DIR = 0;
+ P4DIR = BIT6;
+}
+
+void GPIO::led_on(unsigned char id)
+{
+ if (id == 0) {
+ P1OUT |= BIT0;
+ } else {
+ P4OUT |= BIT6;
+ }
+}
+
+void GPIO::led_off(unsigned char id)
+{
+ if (id == 0) {
+ P1OUT &= ~BIT0;
+ } else {
+ P4OUT &= ~BIT6;
+ }
+}
+
+void GPIO::led_toggle(unsigned char id)
+{
+ if (id == 0) {
+ P1OUT ^= BIT0;
+ } else {
+ P4OUT ^= BIT6;
+ }
+}
+
+GPIO gpio;