diff --git a/src/hal/CAMStreamMessage.cs b/src/hal/CANStreamMessage.cs similarity index 100% rename from src/hal/CAMStreamMessage.cs rename to src/hal/CANStreamMessage.cs diff --git a/src/hal/JoystickDescriptor.cs b/src/hal/JoystickDescriptor.cs index ee778f94..91b1c8ef 100644 --- a/src/hal/JoystickDescriptor.cs +++ b/src/hal/JoystickDescriptor.cs @@ -7,6 +7,7 @@ namespace WPIHal; public readonly record struct JoystickDescriptor(bool IsXbox, int Type, string Name, int[] AxisTypes, int ButtonCount, int PovCount); [CustomMarshaller(typeof(JoystickDescriptor), MarshalMode.ManagedToUnmanagedOut, typeof(JoystickDescriptorMarshaller))] +[CustomMarshaller(typeof(JoystickDescriptor), MarshalMode.ManagedToUnmanagedIn, typeof(JoystickDescriptorMarshaller))] public static class JoystickDescriptorMarshaller { public static JoystickDescriptor ConvertToManaged(NativeJoystickDescriptor unmanaged) @@ -22,6 +23,11 @@ public static JoystickDescriptor ConvertToManaged(NativeJoystickDescriptor unman }; } + public static NativeJoystickDescriptor ConvertToUnmanaged(JoystickDescriptor managed) + { + throw new NotImplementedException(); + } + [StructLayout(LayoutKind.Sequential)] public struct NativeJoystickDescriptor { diff --git a/src/hal/MatchInfo.cs b/src/hal/MatchInfo.cs index b8ad3cf4..f30e3a9e 100644 --- a/src/hal/MatchInfo.cs +++ b/src/hal/MatchInfo.cs @@ -8,6 +8,7 @@ namespace WPIHal; public record struct MatchInfo(string EventName, MatchType MatchType, int MatchNumber, int ReplayNumber, byte[] GameSpecificMessage); [CustomMarshaller(typeof(MatchInfo), MarshalMode.ManagedToUnmanagedOut, typeof(MatchInfoMarshaller))] +[CustomMarshaller(typeof(MatchInfo), MarshalMode.ManagedToUnmanagedIn, typeof(MatchInfoMarshaller))] public static class MatchInfoMarshaller { public static unsafe MatchInfo ConvertToManaged(NativeMatchInfo unmanaged) @@ -22,6 +23,11 @@ public static unsafe MatchInfo ConvertToManaged(NativeMatchInfo unmanaged) }; } + public static NativeMatchInfo ConvertToUnmanaged(in MatchInfo managed) + { + throw new NotImplementedException(); + } + [StructLayout(LayoutKind.Sequential)] public struct NativeMatchInfo { diff --git a/src/hal/Natives/Simulation/AccelerometerData.cs b/src/hal/Natives/Simulation/AccelerometerData.cs new file mode 100644 index 00000000..78cfe007 --- /dev/null +++ b/src/hal/Natives/Simulation/AccelerometerData.cs @@ -0,0 +1,99 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalAccelerometerData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetAccelerometerData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetAccelerometerData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAccelerometerActiveCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAccelerometerActiveCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAccelerometerActiveCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAccelerometerActiveCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAccelerometerActive")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetAccelerometerActive(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAccelerometerActive")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAccelerometerActive(int index, [MarshalAs(UnmanagedType.I4)] bool active); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAccelerometerRangeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAccelerometerRangeCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAccelerometerRangeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAccelerometerRangeCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAccelerometerRange")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial HalAccelerometer.Range GetAccelerometerRange(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAccelerometerRange")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAccelerometerRange(int index, HalAccelerometer.Range range); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAccelerometerXCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAccelerometerXCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAccelerometerXCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAccelerometerXCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAccelerometerX")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAccelerometerX(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAccelerometerX")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAccelerometerX(int index, double x); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAccelerometerYCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAccelerometerYCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAccelerometerYCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAccelerometerYCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAccelerometerY")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAccelerometerY(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAccelerometerY")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAccelerometerY(int index, double y); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAccelerometerZCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAccelerometerZCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAccelerometerZCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAccelerometerZCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAccelerometerZ")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAccelerometerZ(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAccelerometerZ")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAccelerometerZ(int index, double z); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAccelerometerAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterAccelerometerAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/AddressableLEDData.cs b/src/hal/Natives/Simulation/AddressableLEDData.cs new file mode 100644 index 00000000..8117bc85 --- /dev/null +++ b/src/hal/Natives/Simulation/AddressableLEDData.cs @@ -0,0 +1,105 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_ConstBufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalAddressableLEDData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_FindAddressableLEDForChannel")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int FindAddressableLEDForChannel(int channel); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetAddressableLEDData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetAddressableLEDData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAddressableLEDInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAddressableLEDInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAddressableLEDInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAddressableLEDInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAddressableLEDInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetAddressableLEDInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAddressableLEDInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAddressableLEDInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAddressableLEDOutputPortCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAddressableLEDOutputPortCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAddressableLEDOutputPortCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAddressableLEDOutputPortCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAddressableLEDOutputPort")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetAddressableLEDOutputPort(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAddressableLEDOutputPort")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAddressableLEDOutputPort(int index, int outputPort); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAddressableLEDLengthCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAddressableLEDLengthCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAddressableLEDLengthCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAddressableLEDLengthCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAddressableLEDLength")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetAddressableLEDLength(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAddressableLEDLength")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAddressableLEDLength(int index, int length); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAddressableLEDRunningCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAddressableLEDRunningCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAddressableLEDRunningCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAddressableLEDRunningCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAddressableLEDRunning")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetAddressableLEDRunning(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAddressableLEDRunning")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAddressableLEDRunning(int index, [MarshalAs(UnmanagedType.I4)] bool running); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAddressableLEDDataCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAddressableLEDDataCallback(int index, HAL_ConstBufferCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAddressableLEDDataCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAddressableLEDDataCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAddressableLEDData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetAddressableLEDData(int index, HalAddressableLED.LedData* data); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAddressableLEDData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAddressableLEDData(int index, HalAddressableLED.LedData* data, int length); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAddressableLEDAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterAddressableLEDAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/AnalogGyroData.cs b/src/hal/Natives/Simulation/AnalogGyroData.cs new file mode 100644 index 00000000..a2295ced --- /dev/null +++ b/src/hal/Natives/Simulation/AnalogGyroData.cs @@ -0,0 +1,67 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalAnalogGyroData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetAnalogGyroData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetAnalogGyroData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogGyroAngleCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogGyroAngleCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogGyroAngleCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogGyroAngleCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogGyroAngle")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAnalogGyroAngle(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogGyroAngle")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogGyroAngle(int index, double angle); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogGyroRateCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogGyroRateCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogGyroRateCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogGyroRateCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogGyroRate")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAnalogGyroRate(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogGyroRate")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogGyroRate(int index, double rate); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogGyroInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogGyroInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogGyroInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogGyroInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogGyroInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetAnalogGyroInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogGyroInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogGyroInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogGyroAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterAnalogGyroAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/AnalogInData.cs b/src/hal/Natives/Simulation/AnalogInData.cs new file mode 100644 index 00000000..5189f461 --- /dev/null +++ b/src/hal/Natives/Simulation/AnalogInData.cs @@ -0,0 +1,168 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalAnalogInData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetAnalogInData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetAnalogInData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetAnalogInInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInSimDevice")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial WPIHal.Handles.HalSimDeviceHandle GetAnalogInSimDevice(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInAverageBitsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInAverageBitsCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInAverageBitsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInAverageBitsCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInAverageBits")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetAnalogInAverageBits(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInAverageBits")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInAverageBits(int index, int averageBits); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInOversampleBitsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInOversampleBitsCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInOversampleBitsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInOversampleBitsCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInOversampleBits")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetAnalogInOversampleBits(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInOversampleBits")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInOversampleBits(int index, int oversampleBits); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInVoltageCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInVoltageCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAnalogInVoltage(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInVoltage(int index, double voltage); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInAccumulatorInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInAccumulatorInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInAccumulatorInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInAccumulatorInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInAccumulatorInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetAnalogInAccumulatorInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInAccumulatorInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInAccumulatorInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool accumulatorInitialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInAccumulatorValueCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInAccumulatorValueCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInAccumulatorValueCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInAccumulatorValueCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInAccumulatorValue")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial long GetAnalogInAccumulatorValue(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInAccumulatorValue")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInAccumulatorValue(int index, long accumulatorValue); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInAccumulatorCountCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInAccumulatorCountCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInAccumulatorCountCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInAccumulatorCountCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInAccumulatorCount")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial long GetAnalogInAccumulatorCount(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInAccumulatorCount")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInAccumulatorCount(int index, long accumulatorCount); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInAccumulatorCenterCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInAccumulatorCenterCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInAccumulatorCenterCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInAccumulatorCenterCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInAccumulatorCenter")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetAnalogInAccumulatorCenter(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInAccumulatorCenter")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInAccumulatorCenter(int index, int accumulatorCenter); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInAccumulatorDeadbandCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogInAccumulatorDeadbandCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogInAccumulatorDeadbandCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogInAccumulatorDeadbandCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogInAccumulatorDeadband")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetAnalogInAccumulatorDeadband(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogInAccumulatorDeadband")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogInAccumulatorDeadband(int index, int accumulatorDeadband); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogInAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterAnalogInAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/AnalogOutData.cs b/src/hal/Natives/Simulation/AnalogOutData.cs new file mode 100644 index 00000000..4f0afcc1 --- /dev/null +++ b/src/hal/Natives/Simulation/AnalogOutData.cs @@ -0,0 +1,51 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalAnalogOutData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetAnalogOutData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetAnalogOutData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogOutVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogOutVoltageCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogOutVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogOutVoltageCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogOutVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAnalogOutVoltage(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogOutVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogOutVoltage(int index, double voltage); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogOutInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogOutInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogOutInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogOutInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogOutInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetAnalogOutInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogOutInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogOutInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogOutAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterAnalogOutAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/AnalogTriggerData.cs b/src/hal/Natives/Simulation/AnalogTriggerData.cs new file mode 100644 index 00000000..98db435e --- /dev/null +++ b/src/hal/Natives/Simulation/AnalogTriggerData.cs @@ -0,0 +1,95 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public enum HalSimAnalogTriggerMode : int +{ + Unassigned, + Filtered, + DutyCycle, + Averaged +} + +public static unsafe partial class HalAnalogTriggerData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_FindAnalogTriggerForChannel")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int FindAnalogTriggerForChannel(int channel); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetAnalogTriggerData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetAnalogTriggerData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogTriggerInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogTriggerInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogTriggerInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogTriggerInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogTriggerInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetAnalogTriggerInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogTriggerInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogTriggerInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogTriggerTriggerLowerBoundCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogTriggerTriggerLowerBoundCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogTriggerTriggerLowerBound")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAnalogTriggerTriggerLowerBound(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogTriggerTriggerLowerBound")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogTriggerTriggerLowerBound(int index, double triggerLowerBound); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogTriggerTriggerUpperBoundCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogTriggerTriggerUpperBoundCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogTriggerTriggerUpperBound")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetAnalogTriggerTriggerUpperBound(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogTriggerTriggerUpperBound")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogTriggerTriggerUpperBound(int index, double triggerUpperBound); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogTriggerTriggerModeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterAnalogTriggerTriggerModeCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAnalogTriggerTriggerModeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAnalogTriggerTriggerModeCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetAnalogTriggerTriggerMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial HalSimAnalogTriggerMode GetAnalogTriggerTriggerMode(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetAnalogTriggerTriggerMode")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetAnalogTriggerTriggerMode(int index, HalSimAnalogTriggerMode triggerMode); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterAnalogTriggerAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterAnalogTriggerAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/CTREPCMData.cs b/src/hal/Natives/Simulation/CTREPCMData.cs new file mode 100644 index 00000000..a19dbaec --- /dev/null +++ b/src/hal/Natives/Simulation/CTREPCMData.cs @@ -0,0 +1,131 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalCTREPCMData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetCTREPCMData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetCTREPCMData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCTREPCMInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCTREPCMInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCTREPCMInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCTREPCMInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetCTREPCMInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetCTREPCMInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetCTREPCMInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetCTREPCMInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool solenoidInitialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCTREPCMSolenoidOutputCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCTREPCMSolenoidOutputCallback(int index, int channel, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCTREPCMSolenoidOutputCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCTREPCMSolenoidOutputCallback(int index, int channel, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetCTREPCMSolenoidOutput")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetCTREPCMSolenoidOutput(int index, int channel); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetCTREPCMSolenoidOutput")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetCTREPCMSolenoidOutput(int index, int channel, [MarshalAs(UnmanagedType.I4)] bool solenoidOutput); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCTREPCMCompressorOnCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCTREPCMCompressorOnCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCTREPCMCompressorOnCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCTREPCMCompressorOnCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetCTREPCMCompressorOn")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetCTREPCMCompressorOn(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetCTREPCMCompressorOn")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetCTREPCMCompressorOn(int index, [MarshalAs(UnmanagedType.I4)] bool compressorOn); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCTREPCMClosedLoopEnabledCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCTREPCMClosedLoopEnabledCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCTREPCMClosedLoopEnabledCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCTREPCMClosedLoopEnabledCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetCTREPCMClosedLoopEnabled")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetCTREPCMClosedLoopEnabled(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetCTREPCMClosedLoopEnabled")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetCTREPCMClosedLoopEnabled(int index, [MarshalAs(UnmanagedType.I4)] bool closedLoopEnabled); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCTREPCMPressureSwitchCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCTREPCMPressureSwitchCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCTREPCMPressureSwitchCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCTREPCMPressureSwitchCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetCTREPCMPressureSwitch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetCTREPCMPressureSwitch(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetCTREPCMPressureSwitch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetCTREPCMPressureSwitch(int index, [MarshalAs(UnmanagedType.I4)] bool pressureSwitch); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCTREPCMCompressorCurrentCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCTREPCMCompressorCurrentCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCTREPCMCompressorCurrentCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCTREPCMCompressorCurrentCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetCTREPCMCompressorCurrent")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetCTREPCMCompressorCurrent(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetCTREPCMCompressorCurrent")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetCTREPCMCompressorCurrent(int index, double compressorCurrent); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetCTREPCMAllSolenoids")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetCTREPCMAllSolenoids(int index, Span values); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetCTREPCMAllSolenoids")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetCTREPCMAllSolenoids(int index, byte values); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCTREPCMAllNonSolenoidCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterCTREPCMAllNonSolenoidCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCTREPCMAllSolenoidCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterCTREPCMAllSolenoidCallbacks(int index, int channel, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/CanData.cs b/src/hal/Natives/Simulation/CanData.cs new file mode 100644 index 00000000..e6cd0d3b --- /dev/null +++ b/src/hal/Natives/Simulation/CanData.cs @@ -0,0 +1,66 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_CAN_CloseStreamSessionCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_CAN_GetCANStatusCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_CAN_OpenStreamSessionCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_CAN_ReadStreamSessionCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_CAN_ReceiveMessageCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_CAN_SendMessageCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalCanData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetCanData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetCanData(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCanSendMessageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCanSendMessageCallback(HAL_CAN_SendMessageCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCanSendMessageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCanSendMessageCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCanReceiveMessageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCanReceiveMessageCallback(HAL_CAN_ReceiveMessageCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCanReceiveMessageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCanReceiveMessageCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCanOpenStreamCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCanOpenStreamCallback(HAL_CAN_OpenStreamSessionCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCanOpenStreamCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCanOpenStreamCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCanCloseStreamCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCanCloseStreamCallback(HAL_CAN_CloseStreamSessionCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCanCloseStreamCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCanCloseStreamCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCanReadStreamCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCanReadStreamCallback(HAL_CAN_ReadStreamSessionCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCanReadStreamCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCanReadStreamCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterCanGetCANStatusCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterCanGetCANStatusCallback(HAL_CAN_GetCANStatusCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelCanGetCANStatusCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelCanGetCANStatusCallback(int uid); + +} diff --git a/src/hal/Natives/Simulation/DIOData.cs b/src/hal/Natives/Simulation/DIOData.cs new file mode 100644 index 00000000..dcf3c0fe --- /dev/null +++ b/src/hal/Natives/Simulation/DIOData.cs @@ -0,0 +1,105 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalDIOData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetDIOData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetDIOData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDIOInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDIOInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDIOInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDIOInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDIOInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDIOInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDIOInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDIOInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDIOSimDevice")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial WPIHal.Handles.HalSimDeviceHandle GetDIOSimDevice(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDIOValueCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDIOValueCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDIOValueCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDIOValueCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDIOValue")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDIOValue(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDIOValue")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDIOValue(int index, [MarshalAs(UnmanagedType.I4)] bool value); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDIOPulseLengthCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDIOPulseLengthCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDIOPulseLengthCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDIOPulseLengthCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDIOPulseLength")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetDIOPulseLength(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDIOPulseLength")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDIOPulseLength(int index, double pulseLength); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDIOIsInputCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDIOIsInputCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDIOIsInputCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDIOIsInputCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDIOIsInput")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDIOIsInput(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDIOIsInput")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDIOIsInput(int index, [MarshalAs(UnmanagedType.I4)] bool isInput); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDIOFilterIndexCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDIOFilterIndexCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDIOFilterIndexCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDIOFilterIndexCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDIOFilterIndex")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetDIOFilterIndex(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDIOFilterIndex")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDIOFilterIndex(int index, int filterIndex); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDIOAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterDIOAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/DigitalPWMData.cs b/src/hal/Natives/Simulation/DigitalPWMData.cs new file mode 100644 index 00000000..5fd9ac3c --- /dev/null +++ b/src/hal/Natives/Simulation/DigitalPWMData.cs @@ -0,0 +1,71 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalDigitalPWMData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_FindDigitalPWMForChannel")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int FindDigitalPWMForChannel(int channel); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetDigitalPWMData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetDigitalPWMData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDigitalPWMInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDigitalPWMInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDigitalPWMInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDigitalPWMInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDigitalPWMInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDigitalPWMInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDigitalPWMInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDigitalPWMInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDigitalPWMDutyCycleCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDigitalPWMDutyCycleCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDigitalPWMDutyCycleCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDigitalPWMDutyCycleCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDigitalPWMDutyCycle")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetDigitalPWMDutyCycle(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDigitalPWMDutyCycle")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDigitalPWMDutyCycle(int index, double dutyCycle); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDigitalPWMPinCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDigitalPWMPinCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDigitalPWMPinCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDigitalPWMPinCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDigitalPWMPin")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetDigitalPWMPin(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDigitalPWMPin")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDigitalPWMPin(int index, int pin); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDigitalPWMAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterDigitalPWMAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/DriverStationData.cs b/src/hal/Natives/Simulation/DriverStationData.cs new file mode 100644 index 00000000..80b0c773 --- /dev/null +++ b/src/hal/Natives/Simulation/DriverStationData.cs @@ -0,0 +1,334 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using WPIUtil; +using unsafe HAL_JoystickAxesCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_JoystickButtonsCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_JoystickDescriptorCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_JoystickOutputsCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_JoystickPOVsCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_MatchInfoCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalDriverStationData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetDriverStationData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetDriverStationData(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationEnabledCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationEnabledCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationEnabledCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationEnabledCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDriverStationEnabled")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDriverStationEnabled(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDriverStationEnabled")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDriverStationEnabled([MarshalAs(UnmanagedType.I4)] bool enabled); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationAutonomousCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationAutonomousCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationAutonomousCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationAutonomousCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDriverStationAutonomous")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDriverStationAutonomous(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDriverStationAutonomous")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDriverStationAutonomous([MarshalAs(UnmanagedType.I4)] bool autonomous); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationTestCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationTestCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationTestCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationTestCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDriverStationTest")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDriverStationTest(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDriverStationTest")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDriverStationTest([MarshalAs(UnmanagedType.I4)] bool test); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationEStopCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationEStopCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationEStopCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationEStopCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDriverStationEStop")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDriverStationEStop(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDriverStationEStop")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDriverStationEStop([MarshalAs(UnmanagedType.I4)] bool eStop); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationFmsAttachedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationFmsAttachedCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationFmsAttachedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationFmsAttachedCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDriverStationFmsAttached")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDriverStationFmsAttached(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDriverStationFmsAttached")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDriverStationFmsAttached([MarshalAs(UnmanagedType.I4)] bool fmsAttached); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationDsAttachedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationDsAttachedCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationDsAttachedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationDsAttachedCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDriverStationDsAttached")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDriverStationDsAttached(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDriverStationDsAttached")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDriverStationDsAttached([MarshalAs(UnmanagedType.I4)] bool dsAttached); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationAllianceStationIdCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationAllianceStationIdCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationAllianceStationIdCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationAllianceStationIdCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDriverStationAllianceStationId")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial WPIHal.AllianceStationID GetDriverStationAllianceStationId(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDriverStationAllianceStationId")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDriverStationAllianceStationId(WPIHal.AllianceStationID allianceStationId); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationMatchTimeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationMatchTimeCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationMatchTimeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationMatchTimeCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDriverStationMatchTime")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetDriverStationMatchTime(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDriverStationMatchTime")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDriverStationMatchTime(double matchTime); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterJoystickAxesCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterJoystickAxesCallback(int joystickNum, HAL_JoystickAxesCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelJoystickAxesCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelJoystickAxesCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetJoystickAxes")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetJoystickAxes(int joystickNum, Span axes); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickAxes")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickAxes(int joystickNum, ReadOnlySpan axes); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterJoystickPOVsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterJoystickPOVsCallback(int joystickNum, HAL_JoystickPOVsCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelJoystickPOVsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelJoystickPOVsCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetJoystickPOVs")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetJoystickPOVs(int joystickNum, Span povs); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickPOVs")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickPOVs(int joystickNum, ReadOnlySpan povs); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterJoystickButtonsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterJoystickButtonsCallback(int joystickNum, HAL_JoystickButtonsCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelJoystickButtonsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelJoystickButtonsCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetJoystickButtons")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetJoystickButtons(int joystickNum, Span buttons); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickButtons")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickButtons(int joystickNum, ReadOnlySpan buttons); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterJoystickDescriptorCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterJoystickDescriptorCallback(int joystickNum, HAL_JoystickDescriptorCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelJoystickDescriptorCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelJoystickDescriptorCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetJoystickDescriptor")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetJoystickDescriptor(int joystickNum, out JoystickDescriptor descriptor); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickDescriptor")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickDescriptor(int joystickNum, in JoystickDescriptor descriptor); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterJoystickOutputsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterJoystickOutputsCallback(int joystickNum, HAL_JoystickOutputsCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelJoystickOutputsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelJoystickOutputsCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetJoystickOutputs")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetJoystickOutputs(int joystickNum, long* outputs, int* leftRumble, int* rightRumble); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickOutputs")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickOutputs(int joystickNum, long outputs, int leftRumble, int rightRumble); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterMatchInfoCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterMatchInfoCallback(HAL_MatchInfoCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelMatchInfoCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelMatchInfoCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetMatchInfo")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetMatchInfo(out MatchInfo info); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetMatchInfo")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMatchInfo(in MatchInfo info); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickButton")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickButton(int stick, int button, [MarshalAs(UnmanagedType.I4)] bool state); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickAxis")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickAxis(int stick, int axis, double value); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickPOV")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickPOV(int stick, int pov, int value); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickButtonsValue")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickButtonsValue(int stick, uint buttons); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickAxisCount")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickAxisCount(int stick, int count); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickPOVCount")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickPOVCount(int stick, int count); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickButtonCount")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickButtonCount(int stick, int count); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetJoystickCounts")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetJoystickCounts(int stick, int* axisCount, int* buttonCount, int* povCount); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickIsXbox")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickIsXbox(int stick, [MarshalAs(UnmanagedType.I4)] bool isXbox); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickType")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickType(int stick, int type); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickName")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickName(int stick, WpiString name); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetJoystickAxisType")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetJoystickAxisType(int stick, int axis, int type); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetGameSpecificMessage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetGameSpecificMessage(WpiString message); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEventName")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEventName(WpiString name); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetMatchType")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMatchType(MatchType type); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetMatchNumber")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetMatchNumber(int matchNumber); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetReplayNumber")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetReplayNumber(int replayNumber); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterDriverStationAllCallbacks(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDriverStationNewDataCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDriverStationNewDataCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDriverStationNewDataCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDriverStationNewDataCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_NotifyDriverStationNewData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void NotifyDriverStationNewData(); + +} diff --git a/src/hal/Natives/Simulation/DutyCycleData.cs b/src/hal/Natives/Simulation/DutyCycleData.cs new file mode 100644 index 00000000..780fbd9c --- /dev/null +++ b/src/hal/Natives/Simulation/DutyCycleData.cs @@ -0,0 +1,79 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalDutyCycleData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_FindDutyCycleForChannel")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int FindDutyCycleForChannel(int channel); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetDutyCycleData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetDutyCycleData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDutyCycleDigitalChannel")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetDutyCycleDigitalChannel(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDutyCycleInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDutyCycleInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDutyCycleInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDutyCycleInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDutyCycleInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetDutyCycleInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDutyCycleInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDutyCycleInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDutyCycleSimDevice")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial WPIHal.Handles.HalSimDeviceHandle GetDutyCycleSimDevice(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDutyCycleOutputCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDutyCycleOutputCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDutyCycleOutputCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDutyCycleOutputCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDutyCycleOutput")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetDutyCycleOutput(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDutyCycleOutput")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDutyCycleOutput(int index, double output); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDutyCycleFrequencyCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterDutyCycleFrequencyCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelDutyCycleFrequencyCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelDutyCycleFrequencyCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetDutyCycleFrequency")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetDutyCycleFrequency(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetDutyCycleFrequency")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetDutyCycleFrequency(int index, int frequency); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterDutyCycleAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterDutyCycleAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/EncoderData.cs b/src/hal/Natives/Simulation/EncoderData.cs new file mode 100644 index 00000000..677639e9 --- /dev/null +++ b/src/hal/Natives/Simulation/EncoderData.cs @@ -0,0 +1,198 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalEncoderData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_FindEncoderForChannel")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int FindEncoderForChannel(int channel); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetEncoderData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetEncoderData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderDigitalChannelA")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetEncoderDigitalChannelA(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderDigitalChannelB")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetEncoderDigitalChannelB(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetEncoderInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderSimDevice")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial WPIHal.Handles.HalSimDeviceHandle GetEncoderSimDevice(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderCountCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderCountCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderCountCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderCountCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderCount")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetEncoderCount(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderCount")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderCount(int index, int count); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderPeriodCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderPeriodCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderPeriodCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderPeriodCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderPeriod")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetEncoderPeriod(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderPeriod")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderPeriod(int index, double period); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderResetCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderResetCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderResetCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderResetCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderReset")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetEncoderReset(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderReset")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderReset(int index, [MarshalAs(UnmanagedType.I4)] bool reset); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderMaxPeriodCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderMaxPeriodCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderMaxPeriodCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderMaxPeriodCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderMaxPeriod")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetEncoderMaxPeriod(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderMaxPeriod")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderMaxPeriod(int index, double maxPeriod); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderDirectionCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderDirectionCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderDirectionCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderDirectionCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderDirection")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetEncoderDirection(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderDirection")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderDirection(int index, [MarshalAs(UnmanagedType.I4)] bool direction); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderReverseDirectionCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderReverseDirectionCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderReverseDirectionCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderReverseDirectionCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderReverseDirection")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetEncoderReverseDirection(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderReverseDirection")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderReverseDirection(int index, [MarshalAs(UnmanagedType.I4)] bool reverseDirection); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderSamplesToAverageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderSamplesToAverageCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderSamplesToAverageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderSamplesToAverageCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderSamplesToAverage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetEncoderSamplesToAverage(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderSamplesToAverage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderSamplesToAverage(int index, int samplesToAverage); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderDistancePerPulseCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterEncoderDistancePerPulseCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelEncoderDistancePerPulseCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelEncoderDistancePerPulseCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderDistancePerPulse")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetEncoderDistancePerPulse(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderDistancePerPulse")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderDistancePerPulse(int index, double distancePerPulse); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterEncoderAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterEncoderAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderDistance")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderDistance(int index, double distance); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderDistance")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetEncoderDistance(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetEncoderRate")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetEncoderRate(int index, double rate); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetEncoderRate")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetEncoderRate(int index); + +} diff --git a/src/hal/Natives/Simulation/I2CData.cs b/src/hal/Natives/Simulation/I2CData.cs new file mode 100644 index 00000000..e2dbc947 --- /dev/null +++ b/src/hal/Natives/Simulation/I2CData.cs @@ -0,0 +1,48 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_ConstBufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalI2CData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetI2CData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetI2CData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterI2CInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterI2CInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelI2CInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelI2CInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetI2CInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetI2CInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetI2CInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetI2CInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterI2CReadCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterI2CReadCallback(int index, HAL_BufferCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelI2CReadCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelI2CReadCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterI2CWriteCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterI2CWriteCallback(int index, HAL_ConstBufferCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelI2CWriteCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelI2CWriteCallback(int index, int uid); + +} diff --git a/src/hal/Natives/Simulation/MockHooks.cs b/src/hal/Natives/Simulation/MockHooks.cs new file mode 100644 index 00000000..53b0c4a3 --- /dev/null +++ b/src/hal/Natives/Simulation/MockHooks.cs @@ -0,0 +1,81 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HALSIM_SendConsoleLineHandler = delegate* unmanaged[Cdecl]; +using unsafe HALSIM_SendErrorHandler = delegate* unmanaged[Cdecl]; +using unsafe HALSIM_SimPeriodicCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalMockHooks +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRuntimeType")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRuntimeType(WPIHal.RuntimeType type); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_WaitForProgramStart")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void WaitForProgramStart(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetProgramStarted")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetProgramStarted(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetProgramStarted")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetProgramStarted(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RestartTiming")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RestartTiming(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_PauseTiming")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void PauseTiming(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResumeTiming")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResumeTiming(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_IsTimingPaused")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool IsTimingPaused(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_StepTiming")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void StepTiming(ulong delta); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_StepTimingAsync")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void StepTimingAsync(ulong delta); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSendError")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSendError(HALSIM_SendErrorHandler handler); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSendConsoleLine")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSendConsoleLine(HALSIM_SendConsoleLineHandler handler); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSimPeriodicBeforeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSimPeriodicBeforeCallback(HALSIM_SimPeriodicCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSimPeriodicBeforeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSimPeriodicBeforeCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSimPeriodicAfterCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSimPeriodicAfterCallback(HALSIM_SimPeriodicCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSimPeriodicAfterCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSimPeriodicAfterCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelAllSimPeriodicCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelAllSimPeriodicCallbacks(); + +} diff --git a/src/hal/Natives/Simulation/NotifierData.cs b/src/hal/Natives/Simulation/NotifierData.cs new file mode 100644 index 00000000..9b316617 --- /dev/null +++ b/src/hal/Natives/Simulation/NotifierData.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public struct HalSimNotifierInfo +{ + // TODO fill this in +} + +public static unsafe partial class HalNotifierData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetNextNotifierTimeout")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial ulong GetNextNotifierTimeout(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetNumNotifiers")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetNumNotifiers(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetNotifierInfo")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetNotifierInfo(Span arr, int size); + +} diff --git a/src/hal/Natives/Simulation/NotifyListener.cs b/src/hal/Natives/Simulation/NotifyListener.cs new file mode 100644 index 00000000..7b85497f --- /dev/null +++ b/src/hal/Natives/Simulation/NotifyListener.cs @@ -0,0 +1,10 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalNotifyListener +{ +} diff --git a/src/hal/Natives/Simulation/PWMData.cs b/src/hal/Natives/Simulation/PWMData.cs new file mode 100644 index 00000000..fb34dd09 --- /dev/null +++ b/src/hal/Natives/Simulation/PWMData.cs @@ -0,0 +1,116 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalPWMData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetPWMData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetPWMData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPWMInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPWMInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPWMInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPWMInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPWMInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetPWMInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPWMInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPWMInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPWMPulseMicrosecondCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPWMPulseMicrosecondCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPWMPulseMicrosecondCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPWMPulseMicrosecondCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPWMPulseMicrosecond")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetPWMPulseMicrosecond(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPWMPulseMicrosecond")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPWMPulseMicrosecond(int index, int microsecondPulseTime); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPWMSpeedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPWMSpeedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPWMSpeedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPWMSpeedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPWMSpeed")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetPWMSpeed(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPWMSpeed")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPWMSpeed(int index, double speed); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPWMPositionCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPWMPositionCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPWMPositionCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPWMPositionCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPWMPosition")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetPWMPosition(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPWMPosition")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPWMPosition(int index, double position); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPWMPeriodScaleCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPWMPeriodScaleCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPWMPeriodScaleCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPWMPeriodScaleCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPWMPeriodScale")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetPWMPeriodScale(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPWMPeriodScale")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPWMPeriodScale(int index, int periodScale); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPWMZeroLatchCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPWMZeroLatchCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPWMZeroLatchCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPWMZeroLatchCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPWMZeroLatch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetPWMZeroLatch(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPWMZeroLatch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPWMZeroLatch(int index, [MarshalAs(UnmanagedType.I4)] bool zeroLatch); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPWMAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterPWMAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/PowerDistributionData.cs b/src/hal/Natives/Simulation/PowerDistributionData.cs new file mode 100644 index 00000000..36433f6f --- /dev/null +++ b/src/hal/Natives/Simulation/PowerDistributionData.cs @@ -0,0 +1,91 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalPowerDistributionData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetPowerDistributionData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetPowerDistributionData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPowerDistributionInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPowerDistributionInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPowerDistributionInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPowerDistributionInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPowerDistributionInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetPowerDistributionInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPowerDistributionInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPowerDistributionInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPowerDistributionTemperatureCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPowerDistributionTemperatureCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPowerDistributionTemperatureCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPowerDistributionTemperatureCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPowerDistributionTemperature")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetPowerDistributionTemperature(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPowerDistributionTemperature")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPowerDistributionTemperature(int index, double temperature); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPowerDistributionVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPowerDistributionVoltageCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPowerDistributionVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPowerDistributionVoltageCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPowerDistributionVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetPowerDistributionVoltage(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPowerDistributionVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPowerDistributionVoltage(int index, double voltage); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPowerDistributionCurrentCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterPowerDistributionCurrentCallback(int index, int channel, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelPowerDistributionCurrentCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelPowerDistributionCurrentCallback(int index, int channel, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPowerDistributionCurrent")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetPowerDistributionCurrent(int index, int channel); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPowerDistributionCurrent")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPowerDistributionCurrent(int index, int channel, double current); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetPowerDistributionAllCurrents")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetPowerDistributionAllCurrents(int index, double* currents, int length); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetPowerDistributionAllCurrents")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetPowerDistributionAllCurrents(int index, double* currents, int length); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterPowerDistributionAllNonCurrentCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterPowerDistributionAllNonCurrentCallbacks(int index, int channel, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/REVPHData.cs b/src/hal/Natives/Simulation/REVPHData.cs new file mode 100644 index 00000000..5e5ea301 --- /dev/null +++ b/src/hal/Natives/Simulation/REVPHData.cs @@ -0,0 +1,138 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public enum RevPHCompressorConfigType : int +{ + Disabled = 0, + Digital = 1, + Analog = 2, + Hybrid = 3 +} + +public static unsafe partial class HalREVPHData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetREVPHData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetREVPHData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterREVPHInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterREVPHInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelREVPHInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelREVPHInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetREVPHInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetREVPHInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetREVPHInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetREVPHInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool solenoidInitialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterREVPHSolenoidOutputCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterREVPHSolenoidOutputCallback(int index, int channel, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelREVPHSolenoidOutputCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelREVPHSolenoidOutputCallback(int index, int channel, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetREVPHSolenoidOutput")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetREVPHSolenoidOutput(int index, int channel); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetREVPHSolenoidOutput")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetREVPHSolenoidOutput(int index, int channel, [MarshalAs(UnmanagedType.I4)] bool solenoidOutput); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterREVPHCompressorOnCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterREVPHCompressorOnCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelREVPHCompressorOnCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelREVPHCompressorOnCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetREVPHCompressorOn")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetREVPHCompressorOn(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetREVPHCompressorOn")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetREVPHCompressorOn(int index, [MarshalAs(UnmanagedType.I4)] bool compressorOn); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterREVPHCompressorConfigTypeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterREVPHCompressorConfigTypeCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelREVPHCompressorConfigTypeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelREVPHCompressorConfigTypeCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetREVPHCompressorConfigType")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RevPHCompressorConfigType GetREVPHCompressorConfigType(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetREVPHCompressorConfigType")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetREVPHCompressorConfigType(int index, RevPHCompressorConfigType configType); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterREVPHPressureSwitchCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterREVPHPressureSwitchCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelREVPHPressureSwitchCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelREVPHPressureSwitchCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetREVPHPressureSwitch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetREVPHPressureSwitch(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetREVPHPressureSwitch")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetREVPHPressureSwitch(int index, [MarshalAs(UnmanagedType.I4)] bool pressureSwitch); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterREVPHCompressorCurrentCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterREVPHCompressorCurrentCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelREVPHCompressorCurrentCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelREVPHCompressorCurrentCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetREVPHCompressorCurrent")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetREVPHCompressorCurrent(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetREVPHCompressorCurrent")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetREVPHCompressorCurrent(int index, double compressorCurrent); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetREVPHAllSolenoids")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void GetREVPHAllSolenoids(int index, Span values); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetREVPHAllSolenoids")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetREVPHAllSolenoids(int index, byte values); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterREVPHAllNonSolenoidCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterREVPHAllNonSolenoidCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterREVPHAllSolenoidCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterREVPHAllSolenoidCallbacks(int index, int channel, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/RelayData.cs b/src/hal/Natives/Simulation/RelayData.cs new file mode 100644 index 00000000..95eefe68 --- /dev/null +++ b/src/hal/Natives/Simulation/RelayData.cs @@ -0,0 +1,86 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalRelayData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetRelayData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetRelayData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRelayInitializedForwardCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRelayInitializedForwardCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRelayInitializedForwardCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRelayInitializedForwardCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRelayInitializedForward")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetRelayInitializedForward(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRelayInitializedForward")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRelayInitializedForward(int index, [MarshalAs(UnmanagedType.I4)] bool initializedForward); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRelayInitializedReverseCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRelayInitializedReverseCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRelayInitializedReverseCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRelayInitializedReverseCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRelayInitializedReverse")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetRelayInitializedReverse(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRelayInitializedReverse")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRelayInitializedReverse(int index, [MarshalAs(UnmanagedType.I4)] bool initializedReverse); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRelayForwardCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRelayForwardCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRelayForwardCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRelayForwardCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRelayForward")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetRelayForward(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRelayForward")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRelayForward(int index, [MarshalAs(UnmanagedType.I4)] bool forward); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRelayReverseCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRelayReverseCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRelayReverseCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRelayReverseCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRelayReverse")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetRelayReverse(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRelayReverse")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRelayReverse(int index, [MarshalAs(UnmanagedType.I4)] bool reverse); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRelayAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterRelayAllCallbacks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/Reset.cs b/src/hal/Natives/Simulation/Reset.cs new file mode 100644 index 00000000..3b3ee936 --- /dev/null +++ b/src/hal/Natives/Simulation/Reset.cs @@ -0,0 +1,14 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalReset +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetAllSimData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetAllSimData(); + +} diff --git a/src/hal/Natives/Simulation/RoboRioData.cs b/src/hal/Natives/Simulation/RoboRioData.cs new file mode 100644 index 00000000..ad5d6508 --- /dev/null +++ b/src/hal/Natives/Simulation/RoboRioData.cs @@ -0,0 +1,361 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; +using WPIUtil; +using WPIUtil.Marshal; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_RoboRioStringCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalRoboRioData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetRoboRioData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetRoboRioData(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioFPGAButtonCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioFPGAButtonCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioFPGAButtonCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioFPGAButtonCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioFPGAButton")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetRoboRioFPGAButton(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioFPGAButton")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioFPGAButton([MarshalAs(UnmanagedType.I4)] bool fPGAButton); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioVInVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioVInVoltageCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioVInVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioVInVoltageCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioVInVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioVInVoltage(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioVInVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioVInVoltage(double vInVoltage); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioVInCurrentCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioVInCurrentCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioVInCurrentCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioVInCurrentCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioVInCurrent")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioVInCurrent(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioVInCurrent")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioVInCurrent(double vInCurrent); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserVoltage6VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserVoltage6VCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserVoltage6VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserVoltage6VCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserVoltage6V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioUserVoltage6V(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserVoltage6V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserVoltage6V(double userVoltage6V); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserCurrent6VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserCurrent6VCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserCurrent6VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserCurrent6VCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserCurrent6V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioUserCurrent6V(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserCurrent6V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserCurrent6V(double userCurrent6V); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserActive6VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserActive6VCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserActive6VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserActive6VCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserActive6V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetRoboRioUserActive6V(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserActive6V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserActive6V([MarshalAs(UnmanagedType.I4)] bool userActive6V); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserVoltage5VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserVoltage5VCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserVoltage5VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserVoltage5VCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserVoltage5V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioUserVoltage5V(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserVoltage5V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserVoltage5V(double userVoltage5V); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserCurrent5VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserCurrent5VCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserCurrent5VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserCurrent5VCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserCurrent5V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioUserCurrent5V(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserCurrent5V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserCurrent5V(double userCurrent5V); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserActive5VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserActive5VCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserActive5VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserActive5VCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserActive5V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetRoboRioUserActive5V(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserActive5V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserActive5V([MarshalAs(UnmanagedType.I4)] bool userActive5V); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserVoltage3V3Callback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserVoltage3V3Callback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserVoltage3V3Callback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserVoltage3V3Callback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserVoltage3V3")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioUserVoltage3V3(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserVoltage3V3")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserVoltage3V3(double userVoltage3V3); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserCurrent3V3Callback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserCurrent3V3Callback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserCurrent3V3Callback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserCurrent3V3Callback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserCurrent3V3")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioUserCurrent3V3(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserCurrent3V3")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserCurrent3V3(double userCurrent3V3); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserActive3V3Callback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserActive3V3Callback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserActive3V3Callback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserActive3V3Callback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserActive3V3")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetRoboRioUserActive3V3(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserActive3V3")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserActive3V3([MarshalAs(UnmanagedType.I4)] bool userActive3V3); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserFaults6VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserFaults6VCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserFaults6VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserFaults6VCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserFaults6V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetRoboRioUserFaults6V(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserFaults6V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserFaults6V(int userFaults6V); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserFaults5VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserFaults5VCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserFaults5VCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserFaults5VCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserFaults5V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetRoboRioUserFaults5V(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserFaults5V")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserFaults5V(int userFaults5V); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioUserFaults3V3Callback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioUserFaults3V3Callback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioUserFaults3V3Callback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioUserFaults3V3Callback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioUserFaults3V3")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetRoboRioUserFaults3V3(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioUserFaults3V3")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioUserFaults3V3(int userFaults3V3); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioBrownoutVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioBrownoutVoltageCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioBrownoutVoltageCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioBrownoutVoltageCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioBrownoutVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioBrownoutVoltage(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioBrownoutVoltage")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioBrownoutVoltage(double brownoutVoltage); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioTeamNumberCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioTeamNumberCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioTeamNumberCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioTeamNumberCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioTeamNumber")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetRoboRioTeamNumber(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioTeamNumber")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioTeamNumber(int teamNumber); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioSerialNumberCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioSerialNumberCallback(HAL_RoboRioStringCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioSerialNumberCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioSerialNumberCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioSerialNumber")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial nuint GetRoboRioSerialNumber([MarshalUsing(typeof(WpiStringMarshaller))] out string serialNumber); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioSerialNumber")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioSerialNumber(WpiString serialNumber); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioCommentsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioCommentsCallback(HAL_RoboRioStringCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioCommentsCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioCommentsCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioComments")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial nuint GetRoboRioComments([MarshalUsing(typeof(WpiStringMarshaller))] out string comments); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioComments")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioComments(WpiString comments); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioCPUTempCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioCPUTempCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioCPUTempCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioCPUTempCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioCPUTemp")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetRoboRioCPUTemp(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioCPUTemp")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioCPUTemp(double cpuTemp); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioRadioLEDStateCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterRoboRioRadioLEDStateCallback(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelRoboRioRadioLEDStateCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelRoboRioRadioLEDStateCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetRoboRioRadioLEDState")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial RadioLEDState GetRoboRioRadioLEDState(); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetRoboRioRadioLEDState")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetRoboRioRadioLEDState(RadioLEDState state); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterRoboRioAllCallbacks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/SPIAccelerometerData.cs b/src/hal/Natives/Simulation/SPIAccelerometerData.cs new file mode 100644 index 00000000..abef9a6f --- /dev/null +++ b/src/hal/Natives/Simulation/SPIAccelerometerData.cs @@ -0,0 +1,99 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalSPIAccelerometerData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetSPIAccelerometerData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetSPIAccelerometerData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIAccelerometerActiveCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIAccelerometerActiveCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIAccelerometerActiveCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIAccelerometerActiveCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSPIAccelerometerActive")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetSPIAccelerometerActive(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSPIAccelerometerActive")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSPIAccelerometerActive(int index, [MarshalAs(UnmanagedType.I4)] bool active); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIAccelerometerRangeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIAccelerometerRangeCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIAccelerometerRangeCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIAccelerometerRangeCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSPIAccelerometerRange")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int GetSPIAccelerometerRange(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSPIAccelerometerRange")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSPIAccelerometerRange(int index, int range); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIAccelerometerXCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIAccelerometerXCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIAccelerometerXCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIAccelerometerXCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSPIAccelerometerX")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetSPIAccelerometerX(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSPIAccelerometerX")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSPIAccelerometerX(int index, double x); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIAccelerometerYCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIAccelerometerYCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIAccelerometerYCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIAccelerometerYCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSPIAccelerometerY")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetSPIAccelerometerY(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSPIAccelerometerY")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSPIAccelerometerY(int index, double y); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIAccelerometerZCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIAccelerometerZCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIAccelerometerZCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIAccelerometerZCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSPIAccelerometerZ")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double GetSPIAccelerometerZ(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSPIAccelerometerZ")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSPIAccelerometerZ(int index, double z); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIAccelerometerAllCallbcaks")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void RegisterSPIAccelerometerAllCallbcaks(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + +} diff --git a/src/hal/Natives/Simulation/SPIData.cs b/src/hal/Natives/Simulation/SPIData.cs new file mode 100644 index 00000000..956f587f --- /dev/null +++ b/src/hal/Natives/Simulation/SPIData.cs @@ -0,0 +1,57 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HAL_BufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_ConstBufferCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_NotifyCallback = delegate* unmanaged[Cdecl]; +using unsafe HAL_SpiReadAutoReceiveBufferCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalSPIData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetSPIData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetSPIData(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIInitializedCallback(int index, HAL_NotifyCallback callback, void* param, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIInitializedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIInitializedCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSPIInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool GetSPIInitialized(int index); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSPIInitialized")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSPIInitialized(int index, [MarshalAs(UnmanagedType.I4)] bool initialized); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIReadCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIReadCallback(int index, HAL_BufferCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIReadCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIReadCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIWriteCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIWriteCallback(int index, HAL_ConstBufferCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIWriteCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIWriteCallback(int index, int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSPIReadAutoReceivedDataCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSPIReadAutoReceivedDataCallback(int index, HAL_SpiReadAutoReceiveBufferCallback callback, void* param); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSPIReadAutoReceivedDataCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSPIReadAutoReceivedDataCallback(int index, int uid); + +} diff --git a/src/hal/Natives/Simulation/SimDeviceData.cs b/src/hal/Natives/Simulation/SimDeviceData.cs new file mode 100644 index 00000000..244de345 --- /dev/null +++ b/src/hal/Natives/Simulation/SimDeviceData.cs @@ -0,0 +1,95 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using unsafe HALSIM_SimDeviceCallback = delegate* unmanaged[Cdecl]; +using unsafe HALSIM_SimValueCallback = delegate* unmanaged[Cdecl]; + +namespace WPIHal.Natives.Simulation; + +public static unsafe partial class HalSimDeviceData +{ + [LibraryImport("wpiHal", EntryPoint = "HALSIM_SetSimDeviceEnabled", StringMarshalling = StringMarshalling.Utf8)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void SetSimDeviceEnabled(string prefix, [MarshalAs(UnmanagedType.I4)] bool enabled); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_IsSimDeviceEnabled", StringMarshalling = StringMarshalling.Utf8)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + [return: MarshalAs(UnmanagedType.I4)] + public static partial bool IsSimDeviceEnabled(string name); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSimDeviceCreatedCallback", StringMarshalling = StringMarshalling.Utf8)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSimDeviceCreatedCallback(string prefix, void* param, HALSIM_SimDeviceCallback callback, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSimDeviceCreatedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSimDeviceCreatedCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSimDeviceFreedCallback", StringMarshalling = StringMarshalling.Utf8)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSimDeviceFreedCallback(string prefix, void* param, HALSIM_SimDeviceCallback callback, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSimDeviceFreedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSimDeviceFreedCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSimDeviceHandle", StringMarshalling = StringMarshalling.Utf8)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial WPIHal.Handles.HalSimDeviceHandle GetSimDeviceHandle(string name); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSimDeviceName")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial byte* GetSimDeviceName(WPIHal.Handles.HalSimDeviceHandle handle); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSimValueDeviceHandle")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial WPIHal.Handles.HalSimDeviceHandle GetSimValueDeviceHandle(WPIHal.Handles.HalSimDeviceHandle handle); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_EnumerateSimDevices", StringMarshalling = StringMarshalling.Utf8)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnumerateSimDevices(string prefix, void* param, HALSIM_SimDeviceCallback callback); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSimValueCreatedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSimValueCreatedCallback(WPIHal.Handles.HalSimDeviceHandle device, void* param, HALSIM_SimValueCallback callback, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSimValueCreatedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSimValueCreatedCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSimValueChangedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSimValueChangedCallback(WPIHal.Handles.HalSimDeviceHandle handle, void* param, HALSIM_SimValueCallback callback, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSimValueChangedCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSimValueChangedCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_RegisterSimValueResetCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial int RegisterSimValueResetCallback(WPIHal.Handles.HalSimDeviceHandle handle, void* param, HALSIM_SimValueCallback callback, [MarshalAs(UnmanagedType.I4)] bool initialNotify); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_CancelSimValueResetCallback")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void CancelSimValueResetCallback(int uid); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSimValueHandle", StringMarshalling = StringMarshalling.Utf8)] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial WPIHal.Handles.HalSimDeviceHandle GetSimValueHandle(WPIHal.Handles.HalSimDeviceHandle device, string name); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_EnumerateSimValues")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void EnumerateSimValues(WPIHal.Handles.HalSimDeviceHandle device, void* param, HALSIM_SimValueCallback callback); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSimValueEnumOptions")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial byte** GetSimValueEnumOptions(WPIHal.Handles.HalSimDeviceHandle handle, int* numOptions); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_GetSimValueEnumDoubleValues")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial double* GetSimValueEnumDoubleValues(WPIHal.Handles.HalSimDeviceHandle handle, int* numOptions); + + [LibraryImport("wpiHal", EntryPoint = "HALSIM_ResetSimDeviceData")] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] + public static partial void ResetSimDeviceData(); + +}