contchannelreset.c 1.2 KB
/*---------------------------------------------------------------------
 	Copyright (C) 1998, Nintendo.
 	
 	File		contresetone.c
 	Coded    by	Koji Mitsunari.	Apr 22, 1998.
 	Modified by	
 	Comments	Controller Reset One Channel
   
 	$Id: contchannelreset.c,v 1.2 2003/03/25 20:42:04 blythe Exp $
   ---------------------------------------------------------------------*/

#include "osint.h"
#include "controller.h"
#include "siint.h"

#ifndef BBPLAYER
s32
__osContChannelReset(OSMesgQueue *mq, int channel)
{
  s32 	i, ret;
  u8	*ptr = (u8 *)(&__osPfsPifRam);
 
  /* Block to get resource token */
  __osSiGetAccess();

  __osPfsPifRam.pifstatus = CONT_FORMAT;

  /* Set up reset command  */
  for (i = 0; i < channel; i++) {
    *ptr++ = 0x00;              /* skip */
  }    
  *ptr++ = CHANNEL_RESET;	/* Reset command */
  *ptr = FORMAT_END;

  ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
  (void)osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);

  /* trigger pifmacro */

  ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
  (void)osRecvMesg(mq, (OSMesg *)NULL, OS_MESG_BLOCK);

  /* reformat the 64 bytes RAM data and save in data array */

  /* Return resource token */
  __osSiRelAccess();
  return(ret);
}
#endif