void niuniu(void) { int_init(); timer_init(); beeper_init(); uart_init(); timer_update(); while(1) { puts("haha ......\r\n"); sleep(1); } }
int main(void) { serial_init(E_BAUD_38400); serial_install_interrupts(E_FLAGS_SERIAL_RX_INTERRUPT); serial_flush(); beeper_init(PIN); unsigned char size = 0; struct packet pack; while (1) { if (0 >= (size = slip_recv((void *)&pack, sizeof(pack)))) { continue; } // ignore incomplete data chunks if (size < 5) { continue; } // verify if the information is genuine if (!slip_verify_crc16((unsigned char *)&pack, size, 0)) { continue; } for (unsigned char i = 0; i < pack.num; i++) { play(PIN, &pack.notes[i]); serial_poll_send(&pack.notes[i].note, 2); serial_poll_send(&pack.notes[i].duration, 2); } } return 0; }
int main(int argc, char* argv[]) { #if defined(WINDOWS) && defined(DEBUG) //Allocate debugging console int conHandle; long stdHandle; AllocConsole(); stdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); conHandle = _open_osfhandle(stdHandle, _O_TEXT); *stdout = *_fdopen( conHandle, "w" ); stdHandle = (long)GetStdHandle(STD_INPUT_HANDLE); conHandle = _open_osfhandle(stdHandle, _O_TEXT); *stdin = *_fdopen( conHandle, "r" ); setvbuf( stdout, NULL, _IONBF, 0 ); setvbuf( stdin, NULL, _IONBF, 0 ); #endif if (argc < 2) { char *filename = strrchr(argv[0], '\\'); if (!filename) filename = strrchr(argv[0], '/'); if (*filename != '\0') filename++; printf("Crisp-8, Syntax:\n%s FILE\n", filename); return -1; } if (!vid_init()) return -1; beeper_init(); config_loadGlobal(&config); Chip8* chip = (Chip8*)calloc(1, sizeof(Chip8)); if (chip8_loadRom(chip, argv[1]) == -1) { chip->status = CHIP8_EXIT; //TODO:: Create helper_sdl.c SDL_FillRect(vid_surface, 0, 0); font_renderText(RGB_TO_U32(255, 0, 0), FONT_CENTERED, vid_surface->w/2, 0, "Unable to open specified file!\nPlease check if file exists.", argv[1]); SDL_Flip(vid_surface); SDL_Delay(3000); } while(chip->status != CHIP8_EXIT) { switch(chip->status) { case CHIP8_RUNNING: chip8_doStep(chip); break; case CHIP8_DEAD: case CHIP8_PAUSED: menu_doStep(&chip); break; default: break; } } vid_deinit(); beeper_deinit(); SDL_Quit(); free(chip); return 0; }