FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
WatchDog HAL APIs

Macros

#define IOT_WATCHDOG_SUCCESS   ( 0 )
 Return values used by WatchDog driver. More...
 
#define IOT_WATCHDOG_INVALID_VALUE   ( 1 )
 
#define IOT_WATCHDOG_TIME_NOT_SET   ( 2 )
 
#define IOT_WATCHDOG_FUNCTION_NOT_SUPPORTED   ( 3 )
 

Typedefs

typedef struct IotWatchdogDescriptor * IotWatchdogHandle_t
 IotWatchdogHandle_t type is the WatchDog handle returned by calling iot_watchdog_open() this is initialized in open and returned to caller. Caller must pass this pointer to the rest of the APIs.
 
typedef void(* IotWatchdogCallback_t) (void *pvUserContext)
 WatchDog notification callback type. This callback is passed to the driver by using iot_watchdog_set_callback API. This callback is used for warning notification when the bark timer or bite timer expires based on the configuration. Caller can check the status of the WatchDog timer by using eGetStatus IOCTL. More...
 

Enumerations

enum  IotWatchdogStatus_t { eWatchdogTimerStopped, eWatchdogTimerRunning, eWatchdogTimerBarkExpired, eWatchdogTimerBiteExpired }
 WatchDog timer status values. More...
 
enum  IotWatchdogBiteConfig_t { eWatchdogBiteTimerReset, eWatchdogBiteTimerInterrupt }
 WatchDog timer bite behavior setting. More...
 
enum  IotWatchdogIoctlRequest_t {
  eSetWatchdogBarkTime, eGetWatchdogBarkTime, eSetWatchdogBiteTime, eGetWatchdogBiteTime,
  eGetWatchdogStatus, eSetWatchdogBiteBehaviour
}
 Ioctl request types. More...
 

Functions

IotWatchdogHandle_t iot_watchdog_open (int32_t lWatchdogInstance)
 iot_watchdog_open is used to initialize the WatchDog, This function will stop the timer if it was started and resets the timer if any was configured earlier. More...
 
int32_t iot_watchdog_start (IotWatchdogHandle_t const pxWatchdogHandle)
 iot_watchdog_start is used to start the WatchDog timer counter. WatchDog expiry (bite) time must be set before starting the WatchDog counter. Set the bite time using eSetBiteTime IOCTL. More...
 
int32_t iot_watchdog_stop (IotWatchdogHandle_t const pxWatchdogHandle)
 iot_watchdog_stop is used to stop and resets the WatchDog timer counter. After stopping the timer and before starting the timer again, expireTime must be set. More...
 
int32_t iot_watchdog_restart (IotWatchdogHandle_t const pxWatchdogHandle)
 iot_watchdog_restart is used to restart the WatchDog timer to the originally programmed values. This function is usually used once the WatchDog timer (either bark or bite) expired and generated a callback, so caller can restart the timer to original values to restart the WatchDog timer. The main difference b/w iot_watchdog_start and iot_watchdog_restart APIs are, the former requires the time values are set using the IOCTLs and the latter re-uses the already programmed values and re-programs them. If restart_timer is used without first setting the timers, it will return an error. More...
 
void iot_watchdog_set_callback (IotWatchdogHandle_t const pxWatchdogHandle, IotWatchdogCallback_t xCallback, void *pvUserContext)
 iot_wathcdog_set_callback is used to set the callback to be called when bark time reaches the WatchDog counter or if the bite time is configured to generate interrupt (if supported by HW). The caller must set the timers using IOCTL and start the timer for the callback to be called back. Caller must restart the timer when bark timer expires and bite time is configured to reset the device to avoid the target reset. More...
 
int32_t iot_watchdog_ioctl (IotWatchdogHandle_t const pxWatchdogHandle, IotWatchdogIoctlRequest_t xRequest, void *const pvBuffer)
 iot_watchdog_ioctl is used to configure the WatchDog timer properties like the WatchDog timeout value, WatchDog clock, handler for WatchDog interrupt etc. More...
 
int32_t iot_watchdog_close (IotWatchdogHandle_t const pxWatchdogHandle)
 iot_watchdog_close is used to de-initializes the WatchDog, stops the timer if it was started and resets the timer value. More...
 

Detailed Description

Macro Definition Documentation

◆ IOT_WATCHDOG_SUCCESS

#define IOT_WATCHDOG_SUCCESS   ( 0 )

Return values used by WatchDog driver.

Watchdog operation completed successfully.

◆ IOT_WATCHDOG_INVALID_VALUE

#define IOT_WATCHDOG_INVALID_VALUE   ( 1 )

At least one parameter is invalid.

◆ IOT_WATCHDOG_TIME_NOT_SET

#define IOT_WATCHDOG_TIME_NOT_SET   ( 2 )

Watchdog timeout value not set.

◆ IOT_WATCHDOG_FUNCTION_NOT_SUPPORTED

#define IOT_WATCHDOG_FUNCTION_NOT_SUPPORTED   ( 3 )

Watchdog operation not supported.

Typedef Documentation

◆ IotWatchdogCallback_t

typedef void(* IotWatchdogCallback_t) (void *pvUserContext)

WatchDog notification callback type. This callback is passed to the driver by using iot_watchdog_set_callback API. This callback is used for warning notification when the bark timer or bite timer expires based on the configuration. Caller can check the status of the WatchDog timer by using eGetStatus IOCTL.

Warning
The callback will only be called if WatchdogBark is supported, or if WatchdogBite behavior is set to interrupt and is supported.
Parameters
[in]pvUserContextUser Context passed when setting the callback. This is not used by the driver, but just passed back to the user in the callback.

Enumeration Type Documentation

◆ IotWatchdogStatus_t

WatchDog timer status values.

Enumerator
eWatchdogTimerStopped 

WatchDog is stopped

eWatchdogTimerRunning 

WatchDog is running

eWatchdogTimerBarkExpired 

WatchDog bark timer expired

eWatchdogTimerBiteExpired 

WatchDog bite timer expired

◆ IotWatchdogBiteConfig_t

WatchDog timer bite behavior setting.

Enumerator
eWatchdogBiteTimerReset 

Reset the device when WatchDog bite timer expires

eWatchdogBiteTimerInterrupt 

Generate Interrupt when WatchDog bite timer expires

◆ IotWatchdogIoctlRequest_t

Ioctl request types.

Note
BarkTime is the number of msec before a warning signaled in the form of an interrupt call to the set callback function.
BiteTime is the number of msec before a critical condition is signaled in the form of an interrupt (If supported and configured), and usually ends with the system being reset.
Warning
the BarkTime must be less than or equal to the BiteTime
Enumerator
eSetWatchdogBarkTime 

Set the WatchDog warning time (bark value) as uint32_t in msec.

Warning
The maximum value is limited to by the number of bits used for WatchDog counter in the HW. ex: at 24-bit Watchdog counter would have a maximum of 16,777,215 msec.
eGetWatchdogBarkTime 

Get the WatchDog warning time (bark value) as uint32_t in msec

eSetWatchdogBiteTime 

Set the WatchDog expire time (bite value) as uint32_t in msec.

Warning
The maximum value is limited to by the number of bits used for WatchDog counter in the HW. ex: at 24-bit Watchdog counter would have a maximum of 16,777,215 msec.
eGetWatchdogBiteTime 

Get the WatchDog expire time (bite value) as uint32_t in msec

eGetWatchdogStatus 

Returns the WatchDog timer status of type IotWatchdogStatus_t

eSetWatchdogBiteBehaviour 

Set the WatchDog bite behavior. Takes IotWatchdogBiteConfig_t type

Warning
Not all platforms may support interrupt generation.

Function Documentation

◆ iot_watchdog_open()

IotWatchdogHandle_t iot_watchdog_open ( int32_t  lWatchdogInstance)

iot_watchdog_open is used to initialize the WatchDog, This function will stop the timer if it was started and resets the timer if any was configured earlier.

Parameters
[in]lWatchdogInstanceThe instance of the WatchDog to initialize.
Returns
  • Handle to IotWatchdogHandle_t on success
  • NULL if
    • invalid lWatchdogInstance
    • instance is already open

◆ iot_watchdog_start()

int32_t iot_watchdog_start ( IotWatchdogHandle_t const  pxWatchdogHandle)

iot_watchdog_start is used to start the WatchDog timer counter. WatchDog expiry (bite) time must be set before starting the WatchDog counter. Set the bite time using eSetBiteTime IOCTL.

Parameters
[in]pxWatchdogHandlehandle to WatchDog interface returned in iot_watchdog_open.
Returns
  • IOT_WATCHDOG_SUCCESS on success
  • IOT_WATCHDOG_INVALID_VALUE if pxWatchdogHandle is NULL
  • IOT_WATCHDOG_TIME_NOT_SET if bite time has not been set.

◆ iot_watchdog_stop()

int32_t iot_watchdog_stop ( IotWatchdogHandle_t const  pxWatchdogHandle)

iot_watchdog_stop is used to stop and resets the WatchDog timer counter. After stopping the timer and before starting the timer again, expireTime must be set.

Parameters
[in]pxWatchdogHandlehandle to WatchDog interface returned in iot_watchdog_open.
Returns
  • IOT_WATCHDOG_SUCCESS on success
  • IOT_WATCHDOG_INVALID_VALUE if pxWatchdogHandle is NULL
  • IOT_WATCHDOG_NOT_SUPPORTED if stop operation not supported.

◆ iot_watchdog_restart()

int32_t iot_watchdog_restart ( IotWatchdogHandle_t const  pxWatchdogHandle)

iot_watchdog_restart is used to restart the WatchDog timer to the originally programmed values. This function is usually used once the WatchDog timer (either bark or bite) expired and generated a callback, so caller can restart the timer to original values to restart the WatchDog timer. The main difference b/w iot_watchdog_start and iot_watchdog_restart APIs are, the former requires the time values are set using the IOCTLs and the latter re-uses the already programmed values and re-programs them. If restart_timer is used without first setting the timers, it will return an error.

Parameters
[in]pxWatchdogHandlehandle to WatchDog interface returned in iot_watchdog_open.
Returns
  • IOT_WATCHDOG_SUCCESS on success
  • IOT_WATCHDOG_INVALID_VALUE if pxWatchdogHandle is NULL
  • IOT_WATCHDOG_TIME_NOT_SET if watchdog bark or bite time have not been set.

◆ iot_watchdog_set_callback()

void iot_watchdog_set_callback ( IotWatchdogHandle_t const  pxWatchdogHandle,
IotWatchdogCallback_t  xCallback,
void *  pvUserContext 
)

iot_wathcdog_set_callback is used to set the callback to be called when bark time reaches the WatchDog counter or if the bite time is configured to generate interrupt (if supported by HW). The caller must set the timers using IOCTL and start the timer for the callback to be called back. Caller must restart the timer when bark timer expires and bite time is configured to reset the device to avoid the target reset.

Note
Single callback is used, per instance, if eWatchdogBiteTimerInterrupt has been configured or if the bark time reaches the WatchDog counter.
Newly set callback overrides the one previously set
Warning
If input handle or if callback function is NULL, this function silently takes no action.
Parameters
[in]pxWatchdogHandlehandle to WatchDog interface returned in iot_watchdog_open.
[in]xCallbackThe callback function to be called.
[in]pvUserContextThe user context to be passed when callback is called.

◆ iot_watchdog_ioctl()

int32_t iot_watchdog_ioctl ( IotWatchdogHandle_t const  pxWatchdogHandle,
IotWatchdogIoctlRequest_t  xRequest,
void *const  pvBuffer 
)

iot_watchdog_ioctl is used to configure the WatchDog timer properties like the WatchDog timeout value, WatchDog clock, handler for WatchDog interrupt etc.

Parameters
[in]pxWatchdogHandlehandle to WatchDog interface returned in iot_watchdog_open.
[in]xRequestconfiguration request of type IotFlashIoctlRequest_t
[in,out]pvBufferthe configuration buffer to hold the request or response of IOCTL.
Returns
  • returns IOT_WATCHDOG_SUCCESS on success
  • IOT_WATCHDOG_INVALID_VALUE if
    • pxWatchdogHandle is NULL
    • xRequest is invalid
    • pvBuffer is NULL
  • IOT_WATCHDOG_TIME_NOT_SET on error
  • IOT_WATCHDOG_FUNCTION_NOT_SUPPORTED

◆ iot_watchdog_close()

int32_t iot_watchdog_close ( IotWatchdogHandle_t const  pxWatchdogHandle)

iot_watchdog_close is used to de-initializes the WatchDog, stops the timer if it was started and resets the timer value.

Parameters
[in]pxWatchdogHandlehandle to WatchDog interface returned in iot_watchdog_open.
Returns
  • IOT_WATCHDOG_SUCCESS on success
  • IOT_WATCHDOG_INVALID_VALUE if
    • pxWatchdogHandle == NULL
    • pxWatchdogHandle is not open (previously closed).