static void place_lamps(game_t *p_game, level_t *p_level) { int i; memset(p_game->lamps, 0, N_LAMPS*sizeof(lamp_t)); for (i=0; i<p_level->n_lamps; i++) { lamp_store_t *p_cur = &p_level->p_lamps[i]; if (LAMP_IS_SET(*p_level->p_lamp_mask, p_cur->id)) lamp_init(p_game, &p_game->lamps[i], p_cur); } }
void main(void){ lamp_t t; color_t c; lamp_init(&t ,&PORTD, 5 ,&PORTD, 6,&PORTD,7); while (1){ c=Green; _delay_ms(1000); lamp_toggle(t,c); c=Yellow; _delay_ms(1000); lamp_toggle(t,c); c=Red; _delay_ms(1000); lamp_toggle(t,c); } }
/** Initialize the FreeWPC program. */ __noreturn__ void freewpc_init (void) { extern __common__ void system_reset (void); /* Initialize the platform specifics first */ VOIDCALL (platform_init); /* Reset the blanking and watchdog circuitry. * Eventually, the watchdog will be tickled every 1ms * by the IRQ; until interrupts are enabled, we will * have to do this periodically ourselves. */ pinio_watchdog_reset (); /* Set init complete flag to false. When everything is * ready, we'll change this to a 1. */ sys_init_complete = 0; periodic_ok = 0; sys_init_pending_tasks = 0; /* Initialize all of the other kernel subsystems, * starting with the hardware-centric ones and moving on * to software features. */ /* Initialize the real-time scheduler. The periodic functions are scheduled at compile-time using the 'gensched' utility. */ VOIDCALL (tick_init); /* Initialize the hardware. * After each init call, tickle the watchdog (IRQ isn't enabled yet) * to prevent it from expiring and resetting the CPU. * We don't use a callset here because there are some ordering * dependencies -- some modules must be initialized before others -- * and gencallset doesn't allow us to express those conditions. */ #ifdef DEBUGGER db_init (); bpt_init (); pinio_watchdog_reset (); #endif ac_init (); pinio_watchdog_reset (); sol_init (); pinio_watchdog_reset (); #ifdef CONFIG_GI gi_init (); pinio_watchdog_reset (); #endif display_init (); pinio_watchdog_reset (); switch_init (); pinio_watchdog_reset (); flipper_init (); pinio_watchdog_reset (); lamp_init (); pinio_watchdog_reset (); device_init (); pinio_watchdog_reset (); free_timer_init (); pinio_watchdog_reset (); sound_init (); pinio_watchdog_reset (); #if (MACHINE_PIC == 1) pic_init (); pinio_watchdog_reset (); #endif /* task_init is somewhat special in that it transforms the system * from a single task into a multitasking one. After this, tasks * can be spawned if need be. A task is created for the current * thread of execution, too. */ task_init (); pinio_watchdog_reset (); #ifdef CONFIG_NATIVE /* Notify the simulator when the core OS is up and running. */ sim_init (); #endif /* Initialize the sound board early in a background * thread, since it involves polling for data back from it, * which may take unknown (or even infinite) time. */ sys_init_pending_tasks++; task_create_gid (GID_SOUND_INIT, sound_board_init); /* Enable interrupts (IRQs and FIRQs). Do this as soon as possible, * but not before all of the hardware modules are done. */ enable_interrupts (); /* Initialize everything else. Some of these are given explicitly to force a particular order, since callsets do not guarantee the order of invocation. For most things the order doesn't matter. */ deff_init (); leff_init (); test_init (); adj_init (); log_init (); callset_invoke (init); /* Check all adjustments and make sure that their checksums are valid. If problems are found, those adjustments will be made sane again. */ csum_area_check_all (); /* Enable periodic processing. */ periodic_ok = 1; task_sleep (TIME_16MS); /* The system is initialized from a hardware perspective. * Now, perform additional final initializations. */ system_reset (); /* The system can run itself now, this task is done! */ task_exit (); }