/* Read switches and use the data to set LEDs on EduPad * * The four LEDs are: * LED3 - P2.4 * LED2 - P2.5 * LED1 - P3.3 * LED0 - P3.2 * The four switches are: * SW2 - P4.4 * SW3 - P4.2 * SW4 - P4.0 * SW5 - P6.1 * * Built and tested with MSP432P401R Rev. C, Keil MDK-ARM v5.24a and MSP432P4xx_DFP v3.1.0 */ #include "msp.h" int main(void) { P2->DIR |= 0x30; /* P2.5, P2.4 set as output */ P3->DIR |= 0xC; /* P3.3, P3.2 set as output */ P6->DIR &= ~2; /* P6.1 set as input */ P4->DIR &= ~0x15; /* P4.4, P4.2, P4.0 input */ while (1) { if (P4->IN & 0x10) P2->OUT |= 0x10; else P2->OUT &= ~0x10; if (P4->IN & 4) P2->OUT |= 0x20; else P2->OUT &= ~0x20; if (P4->IN & 1) P3->OUT |= 8; else P3->OUT &= ~8; if (P6->IN & 2) P3->OUT |= 4; else P3->OUT &= ~4; } }