// Main entry point int main(void) { SystemInit(); LL_Init1msTick(SystemCoreClock); clock_config(); adc_config(); io_config(); spi_config(); sched_main(); return 0; }
/* * This function is to initiate the I/O devices. * It will be called from the CPU simulation before * any operation with the CPU is possible. */ void init_io(void) { io_config(); }
/* * Configuration */ void getconf(void) { FILE *f1; char line[STRLEN]; /* Configure defaults */ io_config(); /* Determine dot file name */ getdotfile(); /* Load dot file when available */ if (p.dotfile[0] && (f1 = fopen(p.dotfile, "rb")) != NULL) { while (fgets(line, STRLEN, f1) != NULL) { /* Remove CRLF */ rmcrlf(line, STRLEN); if (mystrcasestr(line, "DEVICE=") == line) { strncpy(p.device, &line[7], STRLEN); } #ifdef TTY else if (mystrcasestr(line, "BAUDRATE=") == line) { p.baudrate = strtoul(&line[9], NULL, 0); } #endif else if (mystrcasestr(line, "SLEEP=") == line) { p.sleep_low = strtoul(&line[6], NULL, 0); p.sleep_high = p.sleep_low; } else if (mystrcasestr(line, "SLEEP_LOW=") == line) { p.sleep_low = strtoul(&line[10], NULL, 0); } else if (mystrcasestr(line, "SLEEP_HIGH=") == line) { p.sleep_high = strtoul(&line[11], NULL, 0); } else if (mystrcasestr(line, "BITRULES=") == line) { p.bitrules = strtoul(&line[9], NULL, 0); } else if (mystrcasestr(line, "BUSY=") == line) { p.busy = strtoul(&line[5], NULL, 0); } #if defined(RPI) || defined(BITBANG) || defined(FTDI) || defined(BPI) else if (mystrcasestr(line, "VPP=") == line) { p.vpp = strtoul(&line[4], NULL, 0); } else if (mystrcasestr(line, "PGM=") == line) { p.pgm = strtoul(&line[4], NULL, 0); } else if (mystrcasestr(line, "PGC=") == line) { p.pgc = strtoul(&line[4], NULL, 0); } else if (mystrcasestr(line, "PGD=") == line) { p.pgdi = strtoul(&line[4], NULL, 0); p.pgdo = p.pgdi; } else if (mystrcasestr(line, "PGDO=") == line) { p.pgdo = strtoul(&line[5], NULL, 0); } else if (mystrcasestr(line, "PGDI=") == line) { p.pgdi = strtoul(&line[5], NULL, 0); } #endif /* RPI || BITBANG || FTDI || BPI */ #if defined(FTDI) else if (mystrcasestr(line, "USB_SERIAL=") == line) { strncpy(p.usb_serial, &line[11], STRLEN); } #endif /* FTDI*/ #ifdef MCP23017 else if (mystrcasestr(line, "MCP=") == line) { p.mcp = strtoul(&line[4], NULL, 0); } #endif /* MCP23017 */ else if (mystrcasestr(line, "FWSLEEP=") == line) { p.fwsleep = strtoul(&line[8], NULL, 0); } else if (mystrcasestr(line, "DEBUG=") == line) { p.debug = strtoul(&line[6], NULL, 0); } else if (mystrcasestr(line, "ETC=") == line) { strncpy(p.etc, &line[4], STRLEN); } } fclose(f1); } else { /* We are using the defaults */ snprintf(p.dotfile, STRLEN, "Using defaults (override in %s)", DOTFILENAME); } }