summaryrefslogtreecommitdiff
path: root/include/msp430fr5969lp/driver/gpio.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/msp430fr5969lp/driver/gpio.h')
-rw-r--r--include/msp430fr5969lp/driver/gpio.h37
1 files changed, 33 insertions, 4 deletions
diff --git a/include/msp430fr5969lp/driver/gpio.h b/include/msp430fr5969lp/driver/gpio.h
index 177e7c5..7ac3ba3 100644
--- a/include/msp430fr5969lp/driver/gpio.h
+++ b/include/msp430fr5969lp/driver/gpio.h
@@ -1,16 +1,45 @@
#ifndef GPIO_H
#define GPIO_H
+#include <msp430.h>
+
class GPIO {
private:
GPIO(const GPIO &copy);
public:
GPIO () {}
- void setup();
- void led_on(unsigned char id);
- void led_off(unsigned char id);
- void led_toggle(unsigned char id);
+ inline void setup() {
+ P1OUT = 0;
+ P2OUT = 0;
+ P3OUT = 0;
+ P4OUT = 0;
+ P1DIR = BIT0;
+ P2DIR = 0;
+ P3DIR = 0;
+ P4DIR = BIT6;
+ }
+ inline void led_on(unsigned char id) {
+ if (id == 0) {
+ P1OUT |= BIT0;
+ } else {
+ P4OUT |= BIT6;
+ }
+ }
+ inline void led_off(unsigned char id) {
+ if (id == 0) {
+ P1OUT &= ~BIT0;
+ } else {
+ P4OUT &= ~BIT6;
+ }
+ }
+ inline void led_toggle(unsigned char id) {
+ if (id == 0) {
+ P1OUT ^= BIT0;
+ } else {
+ P4OUT ^= BIT6;
+ }
+ }
};
extern GPIO gpio;