/* * usermain.c (usermain) * User Main */ #include #include #include #define GPIOBase 0xe0028010 // IO1 #define IOPIN ((_UW *)(GPIOBase + 0x0000)) #define IOSET ((_UW *)(GPIOBase + 0x0004)) #define IODIR ((_UW *)(GPIOBase + 0x0008)) #define IOCLR ((_UW *)(GPIOBase + 0x000c)) #define SystemControlBase 0xe01fc000 #define SCS ((_UW *)(SystemControlBase + 0x01a0)) #define PinConnectBase 0xe002c000 #define PINSEL(x) ((_UW *)(PinConnectBase + 0x0000 + (x) * 4)) #define PINMODE(x) ((_UW *)(PinConnectBase + 0x0040 + (x) * 4)) #define LED_PIN (1 << 18) // LED @ P1.18 EXPORT INT usermain( void ) { *PINSEL(3) &= ~0x30; // P1.18: GPIO *PINMODE(3) &= ~0x30; // P1.18: pull-up enable *SCS &= ~1; // GPIO: use Legacy I/F *IOCLR = LED_PIN; // LED: on *IODIR |= LED_PIN; // LED pin: output while (1) { tk_dly_tsk(500); *IOPIN ^= LED_PIN; // toggle LED status } // never return return 0; }