Пример #1
0
Файл: menu.c Проект: naev/naev
/**
 * @brief Closes the small ingame menu and goes back to the main menu.
 *    @param str Unused.
 */
static void menu_small_exit( unsigned int wid, char* str )
{
   (void) str;
   unsigned int info_wid, board_wid;

   /* if landed we must save anyways */
   if (landed) {
      save_all();
      land_cleanup();
   }

   /* Close info menu if open. */
   if (menu_isOpen(MENU_INFO)) {
      info_wid = window_get("Info");
      window_destroy( info_wid );
      menu_Close(MENU_INFO);
   }

   /* Force unboard. */
   if (player_isBoarded()) {
      board_wid = window_get("Boarding");
      board_exit(board_wid, NULL);
   }

   /* Stop player sounds because sometimes they hang. */
   player_restoreControl( 0, _("Exited game.") );
   player_soundStop();

   /* Clean up. */
   window_destroy( wid );
   menu_Close(MENU_SMALL);
   menu_main();
}
Пример #2
0
Файл: board.c Проект: pegue/naev
/**
 * @brief Checks to see if the hijack attempt failed.
 *
 *    @return 1 on failure to board, otherwise 0.
 */
static int board_fail( unsigned int wdw )
{
   int ret;

   ret = board_trySteal( player );

   if (ret == 0)
      return 0;
   else if (ret < 0) /* killed ship. */
      player_message("You have tripped the ship's self destruct mechanism!");
   else /* you just got locked out */
      player_message("The ship's security system locks %s out.",
            (player->ship->crew > 0) ? "your crew" : "you" );

   board_exit( wdw, NULL);
   return 1;
}
Пример #3
0
struct ara_board_info *board_init(void) {
    int i;
    int rc;

    /* Disable the I/O expanders for now. */
    stm32_configgpio(SVC_RST_IOEXP1_GPIO);
    stm32_configgpio(SVC_RST_IOEXP2_GPIO);
    stm32_gpiowrite(SVC_RST_IOEXP1_GPIO, false);
    stm32_gpiowrite(SVC_RST_IOEXP2_GPIO, false);

    /*
     * Register STM32 GPIOs to GPIO chip framework. This has to happen
     * before the following configuration, which depends on STM32 GPIO
     * pin numbers.
     */
    stm32_gpio_init();

    /* Register the TCA64xx I/O Expanders to the gpio chip core. */
    for (i = 0; i < evt1_board_info.nr_io_expanders; i++) {
        struct io_expander_info *io_exp = &evt1_board_info.io_expanders[i];

        io_exp->i2c_dev = up_i2cinitialize(io_exp->i2c_bus);
        if (!io_exp->i2c_dev) {
            dbg_error("%s(): Failed to get I/O Expander I2C bus %u\n",
                      __func__, io_exp->i2c_bus);
            board_exit();
            return NULL;
        }
        if (tca64xx_init(&io_exp->io_exp_driver_data,
                         io_exp->part,
                         io_exp->i2c_dev,
                         io_exp->i2c_addr,
                         io_exp->reset,
                         io_exp->irq,
                         io_exp->gpio_base) < 0) {
            dbg_error("%s(): Failed to register I/O Expander(0x%02x)\n",
                      __func__, io_exp->i2c_addr);
            board_exit();
            return NULL;
        }
    }

    /* For now, just always enable REFCLK_MAIN and the buffers. */
    rc = vreg_config(&refclk_main_vreg) || vreg_get(&refclk_main_vreg);
    if (rc) {
        dbg_error("%s: can't start REFCLK_MAIN: %d\n", __func__, rc);
        board_exit();
        return NULL;
    }

    /* Configure the switch power supply lines. */
    rc = vreg_config(&sw_vreg);
    if (rc) {
        dbg_error("%s: can't configure switch regulators: %d\n", __func__, rc);
        board_exit();
        return NULL;
    }
    stm32_configgpio(evt1_board_info.sw_data.gpio_reset);
    up_udelay(POWER_SWITCH_OFF_STAB_TIME_US);

    /* Configure the wake/detect lines. */
    stm32_configgpio(WD_1_DET_IN_GPIO);
    stm32_configgpio(WD_2_DET_IN_GPIO);
    stm32_configgpio(WD_3A_DET_IN_GPIO);
    stm32_configgpio(WD_3B_DET_IN_GPIO);
    stm32_configgpio(WD_4A_DET_IN_GPIO);
    stm32_configgpio(WD_4B_DET_IN_GPIO);
    stm32_configgpio(WD_5_DET_IN_GPIO);
    stm32_configgpio(WD_8A_DET_IN_GPIO);
    stm32_configgpio(WD_8B_DET_IN_GPIO);

    /* Configure the ARA key. */
    stm32_configgpio(ARA_KEY_GPIO);

    /*
     * (Module hotplug pins unconfigured. TODO, part of SW-1942.)
     */

    return &evt1_board_info;
}