Пример #1
0
//-----------------------------------------------------------------------------
void ReadHousekeeping(void) {

	// ADCs
	OutPortB(AIO_BASE + 0x1A, 0x00);					// disable triggered scan mode
	OutPortB(AIO_BASE + 0x1E, 0x00);
	OutPortB(AIO_BASE + 1, 0);							// reset FIFO

	// here force 16 acq when s/w triggering
	for (uint8 i = 0; i < 16; i++) {
		OutPortB(AIO_BASE, 0);
		while (!(InPortB(AIO_BASE + 0x08) & 0xF0));		// wait for FIFO not empty
		Adc[i] = Read_ACCESIO_AD();
	}

	OutPortB(AIO_BASE + 1, 0);							// reset FIFO
	EnableTriggeredScan();

	// digital IO lines
	Flags[FILL1_F] = Read_ACCESIO_DigOut(FILL1);
	Flags[FILL2_F] = Read_ACCESIO_DigOut(FILL2);
	Flags[FILL3_F] = Read_ACCESIO_DigOut(FILL3);
	Flags[STIRRER_F] = Read_ACCESIO_DigOut(STIRRER);
	Flags[PUMP1_F] = Read_ACCESIO_DigOut(PUMP1);
	Flags[PUMP2_F] = Read_ACCESIO_DigOut(PUMP2);
}
Пример #2
0
//-----------------------------------------------------------------------------
// sends a pulse on a digital line that can be piped into the camera to trigger it
//-----------------------------------------------------------------------------
void GenerateTrigger(void) {

	int i;

	// very crude way of generating a pulse
	for (i = 0; i < 10; i++)
		OutPortB(AIO_PORTB, 1);
	OutPortB(AIO_PORTB, 0);
}
Пример #3
0
//-----------------------------------------------------------------------------
void EnableTriggeredScan(void) {

	OutPortB(AIO_BASE + 1, 0x00);						//reset FIFO
	OutPortB(AIO_BASE + 0x1A, 0x10);					// enable triggered scan mode
	OutPortB(AIO_BASE + 0x1E, 0x40);
	
	// arm the comparator
	Set_ACCESIO_DigOut(0, HI);
}
Пример #4
0
//-----------------------------------------------------------------------------
//	Sets individual digital output lines
//	0 <= pin <= 15
//	STATE = HI or LO
//-----------------------------------------------------------------------------
bool Set_ACCESIO_DigOut(unsigned short pin, int state) {

	if (pin > 15)	{
		// throw a fit - wrong pin	
		MessageBox(0, _T(""), _T("Pin setting error in Set_ACCESIO_DigOut"), MB_OK | MB_ICONSTOP);
		return false;
	}

	// compute new pinstate for this port - state is HI or LO
	unsigned long port;

	if (pin < 8) {
		port = AIO_PORTA;
	} else {
		port = AIO_PORTB;
		pin -= 8;
	}

	unsigned char DIO_pinstate = (char)InPortB(port);				// read the current state
	if (state == HI)
		DIO_pinstate |= (1 << pin);
	else 
		DIO_pinstate &= ~(1 << pin);

	OutPortB(port, DIO_pinstate);

	return true;
}
Пример #5
0
int Shutdown(SHUTDOWN_ACTION saShutdown)	 
{
	Debug(Dbg,_T("Process Shutdown Starting."));

	NTSTATUS nResult;
	HMODULE hDll = ::LoadLibrary(_T("ntdll.dll"));
	if(hDll == NULL)
	{    
		return 0;
	}

	PRtlAdjustPrivilege RtlAdjustPrivilege = (PRtlAdjustPrivilege)GetProcAddress(hDll, "RtlAdjustPrivilege");

	PZwShutdownSystem ZwShutdownSystem = (PZwShutdownSystem)GetProcAddress(hDll, "ZwShutdownSystem");

	PZwSystemDebugControl ZwSystemDebugControl = (PZwSystemDebugControl)GetProcAddress(hDll, "ZwSystemDebugControl");

	if(ZwShutdownSystem == NULL || ZwSystemDebugControl == NULL || RtlAdjustPrivilege == NULL)
		return 0;

	int nEn = 0;

	if(RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, true, &nEn) == 0x0c000007c)
		RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, false, &nEn);
	switch (saShutdown)
	{
	case ShutdownPowerOff:
		nResult = ZwShutdownSystem(saShutdown);
	case ShutdownReboot:
		nResult = ZwShutdownSystem(saShutdown);
		OutPortB(ZwSystemDebugControl,0x64,0xFE);//OxFE 重启代码
		nResult = ZwShutdownSystem(saShutdown);
	default:
		OutPortB(ZwSystemDebugControl,0x64,0xFE);//OxFE 重启代码
	}

	FreeLibrary(hDll);

	return nResult;

}
Пример #6
0
//-----------------------------------------------------------------------------
// calls all the different functions to set up various ACCESIO operations
//-----------------------------------------------------------------------------
bool DAQInit(void) {

	// set the PMT HVs to zero
	SetDac(PMT1_DAC, 0.0);
	SetDac(PMT2_DAC, 0.0);
	SetDac(PMT3_DAC, 0.0);

	// get info from ACCESIO card
	accesSettings.jumpers = (unsigned char)InPortB(AIO_BASE+0x08);		// jumper configuration readback
	accesSettings.adrange = accesSettings.jumpers & 0x07;				// d2,d1,d0 are 5/10, uni/bip, 16/8
	accesSettings.dacBrange = (accesSettings.jumpers>>3) & 0x01;		// d4,d3 are 5/10 for daca,b
	accesSettings.dacArange = (accesSettings.jumpers>>4) & 0x01;

	// INIT THE ACCESIO CARD
	InPortB(AIO_BASE + 0x1D);											// master reset

	OutPortB(AIO_BASE + 2, 0xF0);			// end scan at CH15, start scan at CH0
	EnableTriggeredScan();					// set up the ADC channels

	// disarm the comparator just in case
	Set_ACCESIO_DigOut(0, LO);

	return true;
}
Пример #7
0
//-----------------------------------------------------------------------------
//	DAC will write to the selected DAC
//-----------------------------------------------------------------------------
void SetDac(unsigned char DACnum, double dacV) {

	unsigned int count;
	
	count = (unsigned int)(dacV / ((DACnum ? accesSettings.dacArange : accesSettings.dacBrange) ? 5.0 : 10.0) * 4096);
	count &= 0x0FFF;								// 12-bit DAC
	DACnum++;										// To the hardware, the DACs are 1-based

	OutPortB(AIO_BASE + 9, 0x81);					// DAC load mode = software
	OutPortB(AIO_BASE + 9, sbitd(DACnum, 1) | 2);	// DACnum bit 1
	OutPortB(AIO_BASE + 9, sbitd(DACnum, 0) | 2);	// DACnum bit 0
	OutPortB(AIO_BASE + 9, 0x01);					// unused bit
	OutPortB(AIO_BASE + 9, sbitd(count, 11));		// data bit 11
	OutPortB(AIO_BASE + 9, sbitd(count, 10));		// data bit 10
	OutPortB(AIO_BASE + 9, sbitd(count, 9));		// data bit 9
	OutPortB(AIO_BASE + 9, sbitd(count, 8));		// data bit 8
	OutPortB(AIO_BASE + 9, sbitd(count, 7));		// data bit 7
	OutPortB(AIO_BASE + 9, sbitd(count, 6));		// data bit 6
	OutPortB(AIO_BASE + 9, sbitd(count, 5));		// data bit 5
	OutPortB(AIO_BASE + 9, sbitd(count, 4));		// data bit 4
	OutPortB(AIO_BASE + 9, sbitd(count, 3));		// data bit 3
	OutPortB(AIO_BASE + 9, sbitd(count, 2));		// data bit 2
	OutPortB(AIO_BASE + 9, sbitd(count, 1));		// data bit 1
	OutPortB(AIO_BASE + 9, sbitd(count, 0));		// data bit 0
	OutPortB(AIO_BASE + 9, 0x00);					// end trans
	OutPortB(AIO_BASE + 9, 0x02);					// Load DACs
}