#include"ledx.h" int main(int argc, char const *argv[]) { int fd; fd = port_open(); while(1) { if ( (port_write(16, fd)) < 0 ) { exit(1); } else { /* 以下往GPX0_DAT寄存器写值,注意先要设置GPX0_DAT的地址 */ *GPX0_DAT = 0xFE; printf("LED1\n"); sleep(1); *GPX0_DAT = 0xFD; printf("LED2\n"); sleep(1); *GPX0_DAT = 0xFB; printf("LED3\n"); sleep(1); *GPX0_DAT = 0xF7; printf("LED4\n"); sleep(1); *GPX0_DAT = 0xEF; printf("LED5\n"); sleep(1); *GPX0_DAT = 0xDF; printf("LED6\n"); sleep(1); *GPX0_DAT = 0xBF; printf("LED7\n"); sleep(1); *GPX0_DAT = 0x7F; printf("LED8\n"); sleep(1); } } port_close(16, fd); return 0; }