Ejemplo n.º 1
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Starting the watchdog driver.
   */
  wdgStart(&WDGD1, &wdgcfg);

  /*
   * Normal main() thread activity, it resets the watchdog.
   */
  while (true) {
    wdgReset(&WDGD1);
    palToggleLine(LINE_LED4);
    chThdSleepMilliseconds(500);
  }
  return 0;
}
Ejemplo n.º 2
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  palSetPad(IOPORT1, LED1);

  WDGConfig WDG_config = {
    .pause_on_sleep = 0,
    .pause_on_halt  = 0,
    .timeout_ms     = 5000,
    .callback       = timeout_callback
  };

  wdgStart(&WDGD1, &WDG_config);

  /*
   * Normal main() thread activity, in this demo it does nothing.
   */
  while (true) {
    if (palReadPad(IOPORT1, BTN1) == 0) {
      palTogglePad(IOPORT1, LED1);
      wdgReset(&WDGD1);
    }
    chThdSleepMilliseconds(500);
  }
}
Ejemplo n.º 3
0
int main(void)
{
   /*
    * System initializations.
    * - HAL initialization, this also initializes the configured device drivers
    *   and performs the board-specific initializations.
    * - Kernel initialization, the main() function becomes a thread and the
    *   RTOS is active.
    */

    /* ChibiOS initialization */
    halInit();
    chSysInit();
    _start_watchdog();

    /* Application specific initialization */
    system_can_init();
    system_serial_init();
    _start_mco_output();

   /*
    * Creates the processing threads.
    */
    chThdCreateStatic(wa_STN1110_rx, sizeof(wa_STN1110_rx), NORMALPRIO, STN1110_rx, NULL);
    chThdCreateStatic(can_rx_wa, sizeof(can_rx_wa), NORMALPRIO, can_rx, NULL);

    uint32_t stats_check = 0;
    while (true) {
        chThdSleepMilliseconds(MAIN_THREAD_CHECK_INTERVAL_MS);
        enum logging_levels level = get_logging_level();
        uint32_t stats_threshold = (level == logging_level_trace ? MAIN_THREAD_SLEEP_FINE_MS : MAIN_THREAD_SLEEP_NORMAL_MS);
        stats_check += MAIN_THREAD_CHECK_INTERVAL_MS;
        if (stats_check > stats_threshold) {
            broadcast_stats();
            stats_check = 0;
        }
        if (WATCHDOG_ENABLED)
            wdgReset(&WDGD1);
        check_system_state();
    }
    return 0;
}
Ejemplo n.º 4
0
/*
 * Application entry point.
 */
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  palSetPadMode(GPIOF, GPIOF_LED_RED, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOF, GPIOF_LED_BLUE, PAL_MODE_OUTPUT_PUSHPULL);

  palSetPadMode(GPIOF, GPIOF_SW1, PAL_MODE_INPUT_PULLUP);
  palSetPadMode(GPIOF, GPIOF_SW2, PAL_MODE_INPUT_PULLUP);

  /*
   * Starting the watchdog driver.
   */
  wdgStart(&WDGD1, &wdgcfg);

  /*
   * Normal main() thread activity, it resets the watchdog.
   */
  while (true) {
    if (palReadPad(GPIOF, GPIOF_SW1)) {
      /* Only reset the watchdog if the button is not pressed */
      wdgReset(&WDGD1);
      palClearPad(GPIOF, GPIOF_LED_RED);
    }

    palTogglePad(GPIOF, GPIOF_LED_BLUE);

    chThdSleepMilliseconds(500);
  }
  return 0;
}