int main(int argc, char **argv) { __disable_irq(); LPC_GPIO2->FIODIR &= ~(1 << 8); LPC_SC->PCLKSEL0 = PCLKSEL0_INIT_VALUE; LPC_SC->PCLKSEL1 = PCLKSEL1_INIT_VALUE; LPC_SC->PCONP = PCONP_INIT_VALUE; clock_init(); serial_init(); /* Enable bus, usage, and mem faults. */ SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk | SCB_SHCSR_USGFAULTENA_Msk; #if 0 /* Disable write buffers. This is useful for debugging - wild writes * are imprecise exceptions unless the Cortex's write buffering is * disabled. However, this has a significant performance hit, so it * should only be set if necessary. */ *((uint32_t *)0xE000E008) |= (1<<1); #endif debugf("\r\n###############\r\n"); debugf("# Ether Dream #\r\n"); debugf("###############\r\n"); debugf("Firmware: %s\r\n", build); debugf("RSID: %d\r\n", LPC_SC->RSID); LPC_SC->RSID = 0xF; hw_get_board_rev(); debugf("Hardware Revision %d\n", hw_board_rev); debugf("Starting up: led"); led_init(); led_set_frontled(1); debugf(" skub"); skub_init(); debugf(" lwip\r\n"); lwip_init(); clock.time = 0; clock.mtime = 0; SysTick_Config(SystemCoreClock / 10000); /* Initialize hardware */ FPA_init(); outputf("Entering main loop..."); watchdog_init(); /* Startup might have taken some time, so reset the periodic event * timers. */ int i; for (i = 0; i < (sizeof(events) / sizeof(events[0])); i++) { events_last[i] = events[i].start + clock.time; } __enable_irq(); playback_set_src(SRC_NETWORK); /* Default values */ dac_set_rate(30000); ilda_set_fps_limit(30); while (1) { watchdog_feed(); /* Check the stuff we check on each loop iteration. */ for (i = 0; i < TABLE_LENGTH(poll); i++) { poll_table[i].f(); } /* Check for periodic events */ check_periodic_timers(); if (f0ad_flag) { /* Re-enter the bootloader. */ outputf("Reentering bootloader..."); dac_stop(0); FORCE_BOOTLOAD_FLAG = FORCE_BOOTLOAD_VALUE; __disable_irq(); /* The watchdog timer will kick us soon... */ while(1); } } }
int main(int argc, char **argv) { time = 0; int i; SysTick_Config(SystemCoreClock / 10000); serial_init(); /* LEDs */ LPC_GPIO0->FIODIR |= (1 << 0); LPC_GPIO1->FIODIR |= (1 << 28); LPC_GPIO1->FIOSET = (1 << 28); LPC_GPIO1->FIODIR |= (1 << 29); outputf("=== j4cDAC ==="); outputf("skub_init()"); skub_init(); outputf("lwip_init()"); lwip_init(); outputf("== hardware =="); for (i = 0; i < TABLE_LENGTH(hardware); i++) { outputf("%s()", hardware_table[i].name); hardware_table[i].f(); } outputf("== protocol =="); for (i = 0; i < TABLE_LENGTH(protocol); i++) { outputf("%s()", protocol_table[i].name); protocol_table[i].f(); } outputf("ilda player"); ilda_open("ildatest.ild"); outputf("Entering main loop..."); /* playback_src = SRC_ILDAPLAYER; playback_source_flags = ILDA_PLAYER_PLAYING | ILDA_PLAYER_REPEAT; */ __enable_irq(); int status = 0; for (i = 0; i < (sizeof(events) / sizeof(events[0])); i++) { events_last[i] = events[i].start + time; } dac_set_rate(12000); ilda_set_fps_limit(30); while (1) { /* If we're playing from something other than the network, * refill the point buffer. */ if (playback_src != SRC_NETWORK) playback_refill(); if (!(LPC_GPIO1->FIOPIN & (1 << 26))) { outputf("Blocking..."); while (!(LPC_GPIO1->FIOPIN & (1 << 26))); } // LPC_GPIO1->FIOCLR = (1 << 28); if (status) { LPC_GPIO0->FIOPIN = 1; LPC_GPIO1->FIOPIN = 0; status = 0; } else { LPC_GPIO0->FIOPIN = 0; LPC_GPIO1->FIOPIN = (1 << 29); status = 1; } // LPC_GPIO1->FIOSET = (1 << 28); /* Check for periodic events */ for (i = 0; i < (sizeof(events) / sizeof(events[0])); i++) { if (time > events_last[i] + events[i].period) { events[i].f(); events_last[i] += events[i].period; } } /* Check the stuff we check on each loop iteration. */ for (i = 0; i < TABLE_LENGTH(poll); i++) { poll_table[i].f(); } } }