Callisto4Bootloader: include/c4_watchdog.h File Reference

Callisto4Bootloader

Enumerations | Functions
c4_watchdog.h File Reference

Interface to enable watchdog functions. More...

`#include "c4_error_codes.h"`
`#include <stdint.h>`

Go to the source code of this file.

## Enumerations

enum | c4_wdog_t { C4_WDOG1, C4_WDOG2, C4_NUM_WDOG }
| Enumeration of watchdogs. More...

## Functions

exit_code_t | c4_initWatchdog (c4_wdog_t wdog, uint16_t to, uint16_t ito)
| Initialise watchdog subsystem. More...
exit_code_t | c4_setWdogTimeout (c4_wdog_t wdog, uint16_t to)
| Set timeout on watchdog. More...
exit_code_t | c4_disableWdog (c4_wdog_t wdog)
| disables the watchdog. More...
exit_code_t | c4_enableWdog (c4_wdog_t wdog)
| enables the watchdog. More...
exit_code_t | c4_setWdogInterrupt (c4_wdog_t wdog, uint16_t to)
| Enable interrupt on watchdog before expiry. More...
exit_code_t | c4_getResetHistory ()
| Retrieve reset history from watchdog registers and from System Register. More...

## Detailed Description

Interface to enable watchdog functions.

Copyright
  2020 Remsdaq Ltd.

The iMXRT1062 processor has three watchdog options: WDOG1, WDOG2 and RTWDOG

Date
  23 Jul 2020

Author
  Dan Smithers dwhs@.nosp@m.rems.nosp@m.daq.c.nosp@m.om

Definition in file c4_watchdog.h.

## Enumeration Type Documentation

## ◆ c4_wdog_t

enum c4_wdog_t

Enumeration of watchdogs.

Enumerator
C4_WDOG1 | Watchdog 1 - resets processor.
C4_WDOG2 | Watchdog 2 - for SNVS secure world.
C4_NUM_WDOG | Number of watchdogs.

Definition at line 34 of file c4_watchdog.h.

## Function Documentation

## ◆ c4_disableWdog()

exit_code_t c4_disableWdog | ( | c4_wdog_t | wdog | ) |

disables the watchdog.

Parameters

  [in] | wdog | Watchdog to disable.

Returns
  exit code

Return values

  ERR_OK | - success.

Definition at line 159 of file c4_watchdog.c.

## ◆ c4_enableWdog()

exit_code_t c4_enableWdog | ( | c4_wdog_t | wdog | ) |

enables the watchdog.

Parameters

  [in] | wdog | Watchdog to enable.

Returns
  exit code

Return values

  ERR_OK | - success.

Definition at line 176 of file c4_watchdog.c.

## ◆ c4_getResetHistory()

exit_code_t c4_getResetHistory | ( |  | ) |

Retrieve reset history from watchdog registers and from System Register.

Returns
  exit code

Return values

  ERR_OK | - success.

Definition at line 258 of file c4_watchdog.c.

## ◆ c4_initWatchdog()

exit_code_t c4_initWatchdog | ( | c4_wdog_t | wdog,
|  | uint16_t | to,
|  | uint16_t | ito
| ) |  |

Initialise watchdog subsystem.

Parameters

  [in] | wdog | Watchdog to programme.
  [in] | to | Timeout in deci-seconds.
  [in] | ito | Interrupt ante-delay in deci-seconds. If this is set greater than or equal to the watchdog timeout (to) then no interrupt is set.

Returns
  exit code

Return values

  ERR_OK | - success.

Timeout for Watchdog is specified in deci-seconds in half-second increments.

The register timeout range is 0x00 - 0xFF which is 0.5 - 128 s or 50 - 1280 ds.

The watchdog timeout can be changed at any point and will take effect the next time the watchdog is reset.

Interrupt time ahead of expiry for watchdog is in deci-seconds in half-second increments.

The register interrupt ante-delay range is 0x00 - 0xFF which is 0 - 127.5 s or 0 - 1275 ds.

Note
  The interrupt value can be set once once only and cannot be changed until the next system reset.

Definition at line 109 of file c4_watchdog.c.

## ◆ c4_setWdogInterrupt()

exit_code_t c4_setWdogInterrupt | ( | c4_wdog_t | wdog,
|  | uint16_t | to
| ) |  |

Enable interrupt on watchdog before expiry.

This specifies that an interrupt is raised a fixed time before the timeout is due to occur. If the watchdog is reset before the interrupt occurs, then no interrupt will be raised.

Note
  This can only be set once and cannot be changed before the next system reset.

Parameters

  [in] | wdog | Watchdog to programme.
  [in] | to | Timeout in deci-seconds.

Returns
  exit code

Return values

  ERR_OK | - success.
  ERR_ALREADY_SET | - Interrupt has already been set.

It appears that this can only be set before the watchdog is enabled, and that the interrupt time and enable bit must be set together.

Definition at line 213 of file c4_watchdog.c.

References c4_WDOG_reg_t::B, c4_WDOG_reg_t::c4_WDOG_wicr::B, C4_WDOG1, C4_WDOG2, NVIC_EnableIRQ, c4_WDOG_reg_t::c4_WDOG_wicr::R, sWdogRegisters, WDOG1_IRQn, WDOG2_IRQn, WDOG_MAX_INT, WDOG_MIN_INT, c4_WDOG_reg_t::WICR, and c4_WDOG_reg_t::c4_WDOG_wicr::WICT.

## ◆ c4_setWdogTimeout()

exit_code_t c4_setWdogTimeout | ( | c4_wdog_t | wdog,
|  | uint16_t | to
| ) |  |

Set timeout on watchdog.

This enables the watchdog for the specified timeout.

Parameters

  [in] | wdog | Watchdog to programme.
  [in] | to | Timeout in deci-seconds.

Returns
  exit code

Return values

  ERR_OK | - success.

Definition at line 193 of file c4_watchdog.c.