summaryrefslogtreecommitdiff
path: root/msp340/Blink/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'msp340/Blink/main.c')
-rwxr-xr-xmsp340/Blink/main.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/msp340/Blink/main.c b/msp340/Blink/main.c
new file mode 100755
index 0000000..dce5f31
--- /dev/null
+++ b/msp340/Blink/main.c
@@ -0,0 +1,45 @@
+#include <msp430.h>
+
+#define DEVELOPMENT_MODE 0x5A80
+
+#define LED_RED_ON 0x01
+#define LED_RED_OFF 0xFE
+
+#define LED_GREEN_ON 0x80
+#define LED_GREEN_OFF 0x7F
+
+#define ENABLE_IO 0xFFFE
+#define BUTTON11 0x02
+#define BUTTON12 0x04
+
+main() {
+ WDTCTL = DEVELOPMENT_MODE;
+ PM5CTL0 = ENABLE_IO;
+
+ P1DIR = LED_RED_ON; /* P1.0 == output */
+ P9DIR = LED_GREEN_ON; /* P9.7 == output */
+
+ P1OUT = BUTTON11; /* P1.1 == input (button) */
+ P1REN = BUTTON11; /* Use pull-up resistor */
+
+ P1OUT |= BUTTON12;
+ P1REN |= BUTTON12;
+
+
+
+
+ while (1) {
+
+ if ((BUTTON11 & P1IN) == 0)
+ P1OUT |= LED_RED_ON;
+ else
+ P1OUT &= LED_RED_OFF;
+
+ if ((BUTTON12 & P1IN) == 0)
+ P9OUT |= LED_GREEN_ON;
+ else
+ P9OUT &= LED_GREEN_OFF;
+
+
+ }
+}