MT_SetDioFuncMode

■Description

Set DIO port the function mode

■Synopsis

MT_SetDioFuncMode(fd, ucDiMode, ucDoMode)

■Argument

fd
[C/C++] int
[Python] ctypes.c_int
Please specify handle acquired by MT_Open function.
ucDiMode
[C/C++] unsigned char
[Python] ctypes.c_ubyte
Set the function mode for DI port
    0x00: GPIO Mode (default)
    0x10: Power Button1 (External SW) [For momentary operation]
             [Short press]:Notify shutdown or power ON
             [Long press]:Forced power OFF
    0x20: Power Button2 (External SW) [For momentary operation]
             Open:Power OFF
             Short:Power ON
    
※Issue a shutdown event when transitioning from ON to OFF
ucDoMode
[C/C++] unsigned char
[Python] ctypes.c_ubyte
Set the function mode for DO port
    0x00: GPIO Mode (default)
    0x40: High output with WDT (Default is low ouput)
    0x50: Low output with WDT (Default is high ouput)
    

■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 = 0;
  unsigned char difunc=0, dofunc=0;

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

  difunc = 0x10;
  dofunc = 0x40;

  printf("Set DIO Func DI:%02X  DO:%02X\n", difunc, dofunc);

  ret = MT_SetDioFuncMode(fd, difunc, dofunc);
  if (ret != 0) {
      printf("MT_SetDioFuncMode error");
  }

  ret = MT_GetDioFuncMode(fd, &difunc, &dofunc);
  if (ret == 0) {
      printf("Get DIO Func DI:%02X  DO:%02X\n", difunc, dofunc);
  }
  else {
      printf("MT_GetDioFuncMode Failled %d\n", ret);
  }

  MT_Close(fd);
  
[Python]
  import ctypes
  import sys
  import mtdll_arm

  fd = mtdll_arm.MT_Open(None);
  if fd < 0:
      print("Faild to open i2c port");
      sys.exit()

  difunc = ctypes.c_ubyte();
  dofunc = ctypes.c_ubyte();

  difunc = 0x10;
  dofunc = 0x40;

  print("Set DIO Func DI:", '{:02x}'.format(difunc), "  DO:", '{:02x}'.format(dofunc));

  ret = MT_SetDioFuncMode(fd, difunc, dofunc);
  if ret != 0:
      print("MT_SetDioFuncMode error");

  ret = mtdll_arm.MT_GetDioFuncMode(fd, difunc, dofunc);
  if ret == 0:
      print("Get DIO Func DI:", '{:02x}'.format(difunc.value), "   DO:", '{:02x}'.format(dofunc.value));
  else:
      print("MT_GetDioFuncMode Failled", '{:d}'.formart(ret));

  mtdll_arm.MT_Close(fd);
  



Function List