Example #1
0
static void switch_init(void)
{
	/* Set up memory-mapped switch positions */
	memmap_switches = host_get_memmap(EC_MEMMAP_SWITCHES);
	*memmap_switches = 0;

	switch_update();

	/* Switch data is now present */
	*host_get_memmap(EC_MEMMAP_SWITCHES_VERSION) = 1;

#ifdef CONFIG_SWITCH_DEDICATED_RECOVERY
	/* Enable interrupts, now that we've initialized */
	gpio_enable_interrupt(GPIO_RECOVERY_L);
#endif

	/*
	 * TODO(crosbug.com/p/23793): It's weird that flash_common.c owns
	 * reading the write protect signal, but we enable the interrupt for it
	 * here.  Take ownership of WP back, or refactor it to its own module.
	 */
#ifdef CONFIG_WP_ACTIVE_HIGH
	gpio_enable_interrupt(GPIO_WP);
#else
	gpio_enable_interrupt(GPIO_WP_L);
#endif
}
Example #2
0
void switch_set(int turnout, unsigned char state, tid_t location_server_tid) {


    char command[3] = {state, turnout, 32};
    Write(COM1, command, 3);
    switches[switch_to_index(turnout)] = state;
    switch_update(turnout, state);
}