MT_SetWDT

■Description

Initialize and set the watchdog timer.

■Synopsis

MT_SetWDT(fd, pwdt)

■Argument

fd
[C/C++] int
[Python] ctypes.c_int
Please specify handle acquired by MT_Open function.
pwdt
[C/C++] PWDTVAL
[Python] ctypes.POINTER(WDTVAL)
Specify a pointer to a structure that stores WDT setting information.
    [C/C++]
      typedef struct _WDTVAL {
        unsigned char ucTimeOut;
        long lTickCount
      } WDTVAL, *PWDTVAL;

    [Python]
      class WDTVAL(ctypes.Structure):  
      _fields_ = ("ucTimeOut", c_ubyte), ("lTickCount", c_int)
    
Member variable Setting information
ucTimeOut
(Timeout value)
Sets the time-up time of the watchdog timer.
The setting range is from 1 to 255 (seconds).
lTickCount
(Tick count value)
Set the tick count value.

The MT_TickWDT function does not clear the WDT timer more than the number set here.
Therefore, if the number of times the timer is cleared reaches the tick count value
and the watchdog timer is not stopped before the timeout value elapses, the system is reset.
When the timer clear count reaches this set value, the lTickCount value will be 0,
so you will need to set it again when using this function again. If this value is set to 0,
it will be invalid and the system reset will not be performed according to the timer clear count.

■RETURN VALUE

[C/C++] int
[Python] ctypes.c_int
If the function succeeds, NO_ERROR is returned.
If the function fails, DRIVER_FAIL is returned.
The other errors : Error code details

■Sample Program Code

[C/C++]
  int fd;
  int ret;
  WDTVAL wdt;

  wdt.ucTimeOut = 120;
  wdt.lTickCount = 10;

  if ( (fd = MT_Open(NULL) ) < 0) {
    printf("Faild to open i2c port\n");
    return 1;
  }

  ret = MT_SetWDT(fd, &wdt);
  if (ret != 0) {
      printf("MT_SetWDT error");
  }

  MT_Close(fd);
  
[Python]
  import mtdll_arm

  wdt = WDTVAL();

  wdt.ucTimeOut = 120;
  wdt.lTickCount = 10;

  fd = mtdll_arm.MT_Open(None);

  ret = mtdll_arm.MT_SetWDT(fd, wdt);
  if ret != 0:
      print("MT_SetWDT error");

  mtdll_arm.MT_Close(fd);
  



Function List