Created
July 13, 2013 11:35
-
-
Save jsleeio/5990413 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msp430.h> | |
#include "../misc.h" | |
int main(void) { | |
stop_watchdog(); | |
// set up bit 0 of P1 as output | |
// P1DIR = BIT0 | BIT6; | |
P1DIR = 0; | |
pinmode_out(1,0); | |
pinmode_out(1,6); | |
// clear all output pins | |
port_clear(1); | |
// loop forever | |
for (;;) { | |
green_led_on(); | |
delay(0x6000); | |
green_led_off(); | |
red_led_on(); | |
delay(0x6000); | |
red_led_off(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef IG_MSP430_MISC_H__ | |
#define IG_MSP430_MISC_H__ | |
#define pinmode_out(port,pin) P##port##DIR |= BIT##pin | |
#define stop_watchdog() WDTCTL = WDTPW | WDTHOLD | |
#define delay(x) for (volatile int _delayctr = 0; _delayctr < (x); _delayctr++); | |
#define port_clear(port) P##port##OUT = 0 | |
#define pin_on(port,pin) P##port##OUT |= BIT##pin | |
#define pin_off(port,pin) P##port##OUT &= ~(BIT##pin) | |
#define pin_toggle(port,pin) P##port##OUT ^= BIT##pin | |
#define green_led_on() pin_on(1,0) | |
#define green_led_off() pin_off(1,0) | |
#define green_led_toggle() pin_toggle(1,0) | |
#define red_led_on() pin_on(1,6) | |
#define red_led_off() pin_off(1,6) | |
#define red_led_toggle() pin_toggle(1,6) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment