//! initialize the uart static void init(){ initialize_clock(); // Not using interrupts NVIC_DisableIRQ(UART_IRQn); // enable IO config LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16); //enable IOCON LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12); //enable UART // UART I/O config LPC_IOCON->PIO1_6 &= ~0x07; LPC_IOCON->PIO1_6 |= 0x01; // UART RXD LPC_IOCON->PIO1_7 &= ~0x07; LPC_IOCON->PIO1_7 |= 0x01; // UART TXD // Enable UART clock LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12); LPC_UART->LCR = 0x83; // 8 bits, no Parity, 1 Stop bit baudrate_set( baudrate ); LPC_UART->LCR = 0x03; // DLAB = 0 LPC_UART->FCR = 0x07; // Enable and reset TX and RX FIFO. // Read to clear the line status. (void)LPC_UART->LSR; // Ensure a clean start, no data in either TX or RX FIFO. while ( (LPC_UART->LSR & (LSR_THRE|LSR_TEMT)) != (LSR_THRE|LSR_TEMT) ); while ( LPC_UART->LSR & LSR_RDR ) { (void)LPC_UART->RBR; // Dump data from RX FIFO } }
static void init(){ initialize_clock(); SysTick->CTRL = 0; // stop the timer SysTick->LOAD = 0xFFFFFF; // use its as a 24-bit timer SysTick->VAL = 0; // clear the timer SysTick->CTRL = 1; // start the timer } }
int main(int args, char *argv[]) { char *save_file; ines_file *nes_rom; /* Print NOW everything :D */ #ifdef _MSC_VER setvbuf(stdout,NULL,_IONBF,0); setvbuf(stderr,NULL,_IONBF,0); #else setbuf(stdout,NULL); setbuf(stderr,NULL); #endif /* i18n stuff */ setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); /* Parse command line options */ initialize_configuration(); switch ( parse_options(args, argv) ) { case -1: usage(stderr,argv); exit(EXIT_FAILURE); case 0: exit(EXIT_SUCCESS); default: break; } load_user_configuration(); /* Initialize static data */ initialize_palette(); initialize_instruction_set(); initialize_playback(); initialize_apu(); initialize_cpu(); initialize_ppu(); initialize_clock(); initialize_pads(); /* Read the ines file and get all the ROM/VROM */ config.rom_file = argv[optind]; nes_rom = check_ines_file(config.rom_file); map_rom_memory(nes_rom); save_file = load_sram(config.rom_file); /* Init the graphics engine */ init_screen(); init_gui(); /* Main execution loop */ main_loop(); /* After finishing the emulation, save the SRAM if necessary */ save_sram(save_file); free(save_file); /* Free all the used resources */ mapper->end_mapper(); end_screen(); end_gui(); end_ppu(); end_cpu(); end_apu(); end_playback(); free_ines_file(nes_rom); return 0; }
/** @brief main() Initialize user task @return void */ MEMSPACE void setup(void) { int i; char time[20]; int ret; uint16_t *ptr; double ang; extern web_init(); int w,h; ip_msg[0] = 0; // CPU // 160MHZ REG_SET_BIT(0x3ff00014, BIT(0)); // 80MHZ // REG_CLR_BIT(0x3ff00014, BIT(0)); os_delay_us(200000L); // Power Up dalay - lets power supplies and devices settle // Configure the UART //uart_init(BIT_RATE_115200,BIT_RATE_115200); uart_init(BIT_RATE_74880,BIT_RATE_74880); os_delay_us(200000L); // Power Up dalay - lets power supplies and devices settle os_delay_us(200000L); // Power Up dalay - lets power supplies and devices settle printf("\n\n\n\n"); sep(); printf("System init...\n"); printf("ESP8266 multidevice project\n"); printf(" (c) 2014-2017 by Mike Gore\n"); printf(" GNU version 3\n"); printf("-> https://github.com/magore/esp8266_ili9341\n"); printf(" GIT last pushed: %s\n", GIT_VERSION); printf(" Last updated file: %s\n", LOCAL_MOD); sep(); PrintRam(); sep(); printf("HSPI init...\n"); hspi_init(1,0); printf("Timers init...\n"); init_timers(); // 1000HZ timer ms_init(); test_types(); // Functions manage user defined address pins chip_addr_init(); initialize_clock(300); #ifdef ADF4351 #ifdef ADF4351_CS chip_select_init(ADF4351_CS); #endif ADF4351_Init(); printf("ADF4351 init done\n"); #endif // Make sure all other GPIO pins are initialized BEFORE SD card #ifdef FATFS_SUPPORT sep(); // Functions manage chip selects #ifdef MMC_CS chip_select_init(MMC_CS); #endif printf("SD Card init...\n"); mmc_init(1); #endif #ifdef DISPLAY sep(); #ifdef ILI9341_CS chip_select_init(ILI9341_CS); #endif #ifdef XPT2046_CS XPT2046_spi_init(); #endif // Initialize TFT master = tft_init(); tft_calX = MatRead("/tft_calX"); tft_calY = MatRead("/tft_calY"); if(tft_calX.data == NULL || tft_calY.data == NULL) tft_is_calibrated = 0; else tft_is_calibrated = 1; printf("TFT calibration %s\n", tft_is_calibrated ? "YES" : "NO"); // rotateion = 1, debug = 1 setup_windows(1,1); #endif wdt_reset(); sep(); printf("Setup Tasks\n"); sep(); setup_networking(); #ifdef TELNET_SERIAL printf("Setup Network Serial Bridge\n"); bridge_task_init(23); #endif if ( espconn_tcp_set_max_con(MAX_CONNECTIONS+1) ) printf("espconn_tcp_set_max_con(%d) != (%d) - failed!\n", MAX_CONNECTIONS+1, espconn_tcp_get_max_con()); else printf("espconn_tcp_set_max_con(%d) = (%d) - success!\n", MAX_CONNECTIONS+1, espconn_tcp_get_max_con()); #ifdef NETWORK_TEST printf("Setup Network TFT Display Client\n"); servertest_setup(TCP_PORT); #endif #ifdef WEBSERVER printf("Setup Network WEB SERVER\n"); web_init(80); #endif sep(); PrintRam(); system_set_os_print(0); } //setup()