Exemple #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;
}
Exemple #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);
  }
}
Exemple #3
0
/* Watchdog configuration and initialization
 */
static void _start_watchdog(void)
{
    if (! WATCHDOG_ENABLED)
        return;

    const WDGConfig wdgcfg = {
        STM32_IWDG_PR_4,
        STM32_IWDG_RL(WATCHDOG_TIMEOUT)
    };
    wdgStart(&WDGD1, &wdgcfg);
}
Exemple #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;
}