Exemplo n.º 1
0
void MonitorShockInit( tuiConfig* psuiConfig_t) {
	psuiConfig = psuiConfig_t;
	led_val = 0;
	blink_count = 0;

	// Initialise LED for shock indication
	InitialiseShockLED();
	//Initialise timer to control led

	ConfigTimer2(SysCtlClockGet()/5, LEDToggleISR);

	ADC1AcquireStart();
	//Need to poll the ADC
	ADCProcessorTrigger(ADC1_BASE, 3);
	//Configure timer for ADC shock monitor
	ConfigTimer1(SysCtlClockGet()/100, MonitorShockISR); //10ms
	//Start Monitor
	MonitorStart();
 }
Exemplo n.º 2
0
void LEDToggleISR() {
	ROM_TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	//
	// Toggle the flag for the third timer.
	//
	HWREGBITW(&g_ui32Flags, 2) ^= 1;
//	HWREGBITW(GPIO_PORTG_BASE, 2) ^= 1;
	if (led_val == 255) {
		led_val = 0;
	} else {
		led_val = 255;
	}
	GPIOPinWrite(GPIO_PORTG_BASE,0x04, led_val);
	blink_count++;
	if (blink_count == MAX_BLINK_COUNT){
		ROM_TimerDisable(TIMER2_BASE, TIMER_A);
		// Start monitoring again
		blink_count = 0;
		MonitorStart();
	}
}
Exemplo n.º 3
0
NTSTATUS DriverDeviceControlHandler( IN PDEVICE_OBJECT fdo, IN PIRP Irp )
{
    NTSTATUS Status = STATUS_SUCCESS;
    PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(Irp);
    ULONG ControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
    ULONG method = ControlCode & 0x3;
    ULONG ResultLength = 0;
    ULONG InputLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength;
    ULONG OutputLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;
    PVOID Buffer = Irp->AssociatedIrp.SystemBuffer;

	KeEnterGuardedRegion();

    KLOG(LInfo, "IoControl fdo %p, ioctl %x", fdo, ControlCode);
	if (OutputLength < InputLength) {
		KLog(LError, "invalid outputlen=%x vs inputlen=%x", OutputLength, InputLength);
		Status = STATUS_INVALID_PARAMETER;
		goto complete;
	}
	
	ResultLength = InputLength;

    switch( ControlCode) {
        case IOCTL_KMON_INIT:
            {   
				PKMON_INIT initData = (PKMON_INIT)Buffer;
				if (InputLength < sizeof(KMON_INIT)) {
					Status = STATUS_BUFFER_TOO_SMALL;
					goto complete;
				}

                KLog(LInfo, "IOCTL_KMON_INIT");
				Status = MonitorStart(initData);
                break;
            }
        case IOCTL_KMON_RELEASE:
            {
				PKMON_RELEASE releaseData = (PKMON_RELEASE)Buffer;
				if (InputLength < sizeof(KMON_RELEASE)) {
					Status = STATUS_BUFFER_TOO_SMALL;
					goto complete;
				}
                KLog(LInfo, "IOCTL_KMON_RELEASE");
				Status = MonitorStop(releaseData);
                break;
            }
		case IOCTL_KMON_OPEN_WINSTA:
			{
				POPEN_WINSTA openWinsta = (POPEN_WINSTA)Buffer;
				if (InputLength < sizeof(OPEN_WINSTA)) {
					Status = STATUS_BUFFER_TOO_SMALL;
					goto complete;
				}
				Status = MonitorOpenWinsta(openWinsta);
				break;
			}
		case IOCTL_KMON_OPEN_DESKTOP:
		{
				POPEN_DESKTOP openDeskop = (POPEN_DESKTOP)Buffer;
				if (InputLength < sizeof(OPEN_DESKTOP)) {
					Status = STATUS_BUFFER_TOO_SMALL;
					goto complete;
				}
				Status = MonitorOpenDesktop(openDeskop);
				break;
		}
		case IOCTL_KMON_SCREENSHOT:
		{
				PKMON_SCREENSHOT screenShot = (PKMON_SCREENSHOT)Buffer;
				if (InputLength < sizeof(KMON_SCREENSHOT)) {
					Status = STATUS_BUFFER_TOO_SMALL;
					goto complete;
				}
				Status = MonitorScreenshot(screenShot);
				break;
		}
        default: Status = STATUS_INVALID_DEVICE_REQUEST;
    }


complete:
	KeLeaveGuardedRegion();
	KLog(LInfo, "dev=%p IoControl: %x bytes: %x, Status=%x", fdo, ControlCode, ResultLength, Status);

    return CompleteIrp(Irp, Status, ResultLength);
}