Exemplo n.º 1
0
void D3D9Renderer::Tick() {
  XTRACE_FUNCTION;

  PROFILE_FUNCTION;

  // Restore lost device
  if (!IsValid() && CanReset()) {
    if (m_RestoreDeviceCallback.m_Callback) {
      m_RestoreDeviceCallback.m_Callback(m_RestoreDeviceCallback.m_Void);
    }
    return;
  }

#if BUILD_DEBUG
  m_DEBUGRenderStats.NumMeshes = 0;
  m_DEBUGRenderStats.NumPrimitives = 0;
#endif

  m_D3DDevice->BeginScene();

  RenderBuckets();
  PostRenderBuckets();

  m_D3DDevice->EndScene();

  Present();

#if BUILD_DEBUG
  STATIC_HASHED_STRING(Render);
  DEBUGCATPRINTF(sRender, 2, "%d meshes, %d primitives\n",
                 m_DEBUGRenderStats.NumMeshes,
                 m_DEBUGRenderStats.NumPrimitives);
#endif
}
Exemplo n.º 2
0
int CanConfig(unsigned char channel)
{
	unsigned char temp;
	
	CanReset(channel);	// reset CAN controller
	
	//------ Write Control Register (CR)
	CanWrite(channel, CR, 0x01);	// Enter Reset Mode without setting RIE
	// and enter reset mode (Set Reset Request bit)
	
	//------ Write Bus Timing Register 0 & 1 (BTR0 & BTR1)
	// BTR can be accessed (read/write) if the reset mode is active
	CanWrite(channel, BTR0, CAN[channel].btr0); // Write Bus Timing Register 0 (BTR0)
	CanWrite(channel, BTR1, CAN[channel].btr1); // Write Bus Timing Register 1 (BTR1)
	
	temp = CanRead(channel, BTR0);
	if(temp != CAN[channel].btr0)			// Read BTR0 and confirm it
		return(ERR_CONFIG);					// fail to configure
	
	temp = CanRead(channel, BTR1);
	if(temp != CAN[channel].btr1)			// Read BTR1 and confirm it
		return(ERR_CONFIG);					// fail to configure
	
	//------ Write Acceptance Code Register (ACR) and
	//		 Acceptance Mask Register (AMR)
	CanWrite(channel, ACR, CAN[channel].acc_code);        // Write ACR
	CanWrite(channel, AMR, CAN[channel].acc_mask);        // Write AMR
	
	//------ Write Output Control Register (OCR)
	//   Set Normal Output Mode & Push-pull dirver
	CanWrite(channel, OCR, 0xfa);
	
	return(ERR_OK);	        // successful
}
Exemplo n.º 3
0
// CAN 제어기 초기화 함수
int InitCANHW(void)
{
	unsigned char data;
	
	// Check memory base address for PCM-3680 : 0xC000 ~ 0xDF00
	if( baseAddr>0xdf00 || baseAddr<0xc000 || (baseAddr%0x100) )
		return(ERR_SEG);			// Return : segment address set error
	
	// CAN0 Init. 
	data = CanRead(0, CR);			// read control register (CR)
	if(data & 0x01)					// check if "Reset Request" is set (Reset Mode)
	{
		// 1. CanWrite(0, CR, 0x60);     	// Set Transmit (TIE) & Receive (RIE) Interrupt Enable bits -> 처음 프로그램
		// 2. CanWrite(0, CR, 0x06);     	// Set Transmit (TIE) & Receive (RIE) Interrupt Enable bits -> by jungho77
		CanWrite(0, CR, 0x00);     	// Set Transmit (TIE) & Receive (RIE) Interrupt Enable bits to 'Low'
		data = CanRead(0, CR);
		if(data & 0x01)				// if "Reset Request" is set to HIGH
			return(ERR_RESET);		// Return : reset error
	}
	CanReset(0);               		// Reset CAN port 0
	data = CanRead(0, CR);
	if(! (data & 0x01) )			// if "Reset Request" is disabled (LOW)
		return(ERR_RESET);			// Return : reset error
	else
		return(ERR_OK);				// if "Reset Request" is set to HIGH


	// CAN1 Init. 
	data = CanRead(1, CR);			// read control register (CR)
	if(data & 0x01)					// check if "Reset Request" is set (Reset Mode)
	{
		// 1. CanWrite(1, CR, 0x60);     	// Set Transmit (TIE) & Receive (RIE) Interrupt Enable bits -> 처음 프로그램
		// 2. CanWrite(1, CR, 0x06);     	// Set Transmit (TIE) & Receive (RIE) Interrupt Enable bits -> by jungho77
		CanWrite(1, CR, 0x00);     	// Set Transmit (TIE) & Receive (RIE) Interrupt Enable bits to 'Low'
		data = CanRead(1, CR);
		if(data & 0x01)				// if "Reset Request" is set to HIGH
			return(ERR_RESET);		// Return : reset error
	}
	CanReset(1);               		// Reset CAN port 0
	data = CanRead(1, CR);
	if(! (data & 0x01) )			// if "Reset Request" is disabled (LOW)
		return(ERR_RESET);			// Return : reset error
	else
		return(ERR_OK);				// if "Reset Request" is set to HIGH

}
Exemplo n.º 4
0
// CAN 각 채널을 초기화 하는 함수.
// PCM-3680은 2개의 CAN 채널을 제공
int InitCAN(unsigned char channel, enum Bitrate BAUD)
{
	//------ reset CAN controller
	CanReset(channel);
	
    //------ CAN irq setting
	CAN[channel].irq = IRQ_POLLING;
	//------ CAN configuration
    CAN[channel].acc_code = 0x00;		// Write Acceptance Code
    CAN[channel].acc_mask = 0xFF;		// Write Acceptance Mask Register
	// *** 0xFF means "no bits are compared"
    CAN[channel].btr1 = 0x14; 			// Write Bus Timing Register 1
	//CAN[channel].btr1 = 0x32; 			// Write Bus Timing Register 1
	// Sampling = Single
	// Tseg1 = 6, Tseg2 = 2
	// Sampling Point @ 75%
    //------ Write Bus Timing Register 0
    //	SJW(Synchronization Jump Width)(b7,b6) = 4
    //  BRP(Baud Rate Prescaler)(b5..b0) = depends on Bitrate
    switch(BAUD) 
	{
	case BAUD_1M:	CAN[channel].btr0 = 0xC0;
		break;
	case BAUD_500K: CAN[channel].btr0 = 0xC1;
		break;
	case BAUD_250K:	CAN[channel].btr0 = 0xC3;
		break;
	case BAUD_125K: CAN[channel].btr0 = 0xC7;
		break;
	case BAUD_100K:	CAN[channel].btr0 = 0xC9;
		break;
	default:		return(ERR_BAUD);       // Bitrate setting error
    }
	
    if(CanConfig(channel) != ERR_OK) return(ERR_CONFIG);
	
    // Put CAN port to normal mode
    return(CanNormalRun(channel));		// successful initialization
}
Exemplo n.º 5
0
// Recover from a lost device
bool D3D9Renderer::Reset() {
  XTRACE_FUNCTION;

  if (!CanReset()) {
    return false;
  }

  PreReset();

  D3DPRESENT_PARAMETERS Params;
  GetPresentParams(Params);

  XTRACE_BEGIN(ResetDevice);
  const HRESULT hr = m_D3DDevice->Reset(&Params);
  if (hr != D3D_OK) {
    return false;
  }
  XTRACE_END;

  m_DeviceLost = false;
  PostReset();

  return true;
}