summaryrefslogtreecommitdiff
path: root/sensors/ADXL345Acc/driver.cpp
diff options
context:
space:
mode:
authorDave Wilson <[email protected]>2015-03-17 19:50:07 -0700
committerDave Wilson <[email protected]>2015-03-17 19:50:07 -0700
commit97cf5197cf5b882b2c689d8dc2b555f2edf8f418 (patch)
tree46f3701832d70b420eb0fc0eb93261f9da45db3f /sensors/ADXL345Acc/driver.cpp
parentef1905bf1e8825bb31120dfb27e0daf3154d859a (diff)
Initial publish
Diffstat (limited to 'sensors/ADXL345Acc/driver.cpp')
-rw-r--r--sensors/ADXL345Acc/driver.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/sensors/ADXL345Acc/driver.cpp b/sensors/ADXL345Acc/driver.cpp
new file mode 100644
index 00000000..0703d858
--- /dev/null
+++ b/sensors/ADXL345Acc/driver.cpp
@@ -0,0 +1,66 @@
+//Copyright (C) Microsoft Corporation, All Rights Reserved.
+//
+//Abstract:
+//
+// This module contains the implementation of entry and exit point
+// of sample ADXL345 accelerometer driver.
+//
+//Environment:
+//
+// Windows User-Mode Driver Framework (UMDF)
+
+#include "Device.h"
+#include "Driver.h"
+
+#include "Driver.tmh"
+
+// This routine is the driver initialization entry point.
+NTSTATUS DriverEntry(
+ _In_ PDRIVER_OBJECT DriverObject, // Pointer to the driver object created by the I/O manager.
+ // DriverEntry must initialize members of DriverObject before it
+ // returns to the caller. DriverObject is allocated by the system
+ // before the driver is loaded, and it is released by the system
+ // after the system unloads the function driver from memory.
+ _In_ PUNICODE_STRING RegistryPath) // Pointer to the driver specific registry key. The function
+ // driver can use the path to store driver related data between
+ // reboots. The path does not store hardware instance specific data.
+{
+ // Initialize WPP Tracing
+ WPP_INIT_TRACING(DriverObject, NULL);
+
+ SENSOR_FunctionEnter();
+
+ WDF_DRIVER_CONFIG DriverConfig;
+ DriverConfig.DriverPoolTag = SENSORV2_POOL_TAG_ACCELEROMETER;
+
+ // Register a cleanup callback so that we can call WPP_CLEANUP when
+ // the framework driver object is deleted during driver unload.
+ WDF_DRIVER_CONFIG_INIT(&DriverConfig, ADXL345AccDevice::OnDeviceAdd);
+ DriverConfig.EvtDriverUnload = OnDriverUnload;
+
+ NTSTATUS Status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &DriverConfig, WDF_NO_HANDLE);
+
+ if (!NT_SUCCESS(Status))
+ {
+ TraceError("WdfDriverCreate failed %!STATUS!", Status);
+ }
+
+ SENSOR_FunctionExit(Status);
+ return Status;
+}
+
+// This routine is called when the driver unloads.
+VOID OnDriverUnload(
+ _In_ WDFDRIVER Driver) // Driver object
+{
+ SENSOR_FunctionEnter();
+
+ SENSOR_FunctionExit(STATUS_SUCCESS);
+
+ // WPP_CLEANUP doesn't actually use the Driver parameter so we need to set it as unreferenced.
+ UNREFERENCED_PARAMETER(Driver);
+ WPP_CLEANUP(WdfDriverWdmGetDriverObject(Driver));
+
+ return;
+}
+