modeselectasync.c 1.07 KB

#include <ultra64.h>

#ifndef	_LONGCMD
#include <leo.h>
#else
#include <leosp.h>
#endif

extern 	s32	__leoActive;

s32 LeoModeSelectAsync(LEOCmd *cmdBlock, u32 standby,
		       u32 sleep, OSMesgQueue *mq)
{
  
  /* 
   * Check for existence of Leo Manager 
   */
  if (!__leoActive) {
    return(-1);
  }
  
  /*
   * Check if standby time and sleep time are legal
   */
  if ((standby > 10) || (sleep > 10))
    return -1;

  /*
   * Fill up command block
   */
  cmdBlock->header.command	= LEO_COMMAND_MODE_SELECT;
  cmdBlock->header.reserve1	= 0;
  cmdBlock->header.control	= 0;
  cmdBlock->header.reserve3	= 0;
  cmdBlock->data.modeselect.reserve1	= 0;
  cmdBlock->data.modeselect.reserve2	= 0;
  cmdBlock->data.modeselect.standby_time	= (u8)standby;
  cmdBlock->data.modeselect.sleep_time		= (u8)sleep;
  /*
   * Don't allow developers to change led timing
   */
  cmdBlock->data.modeselect.reserve3	= 0;

  if (mq != NULL)
  {
    cmdBlock->header.control	|= LEO_CONTROL_POST;
    cmdBlock->header.post	= mq;
  }

  leoCommand((void *)cmdBlock);

  return 0;
  
} /* LeoModeSelectAsync */