Skip to main content

PwmControllerApiWrapper Class

Namespace: GHIElectronics.TinyCLR.Devices.Pwm.Provider · Assembly: GHIElectronics.TinyCLR.Devices.Pwm

Concrete IPwmControllerProvider backed by the native TinyCLR PWM HAL. Constructed internally by PwmController; you don't normally need to use this type directly.

public sealed class PwmControllerApiWrapper : IPwmControllerProvider

Constructors

PwmControllerApiWrapper(NativeApi api)

public PwmControllerApiWrapper(NativeApi api)

Wraps the given native API as a provider.

ParameterTypeDescription
apiNativeApiThe native PWM API to bind to.

Properties

Api

public NativeApi Api { get; }

The underlying native API descriptor.

ChannelCount

public extern int ChannelCount { get; }

Total number of channels exposed by this controller. (inherited)

MinFrequency

public extern double MinFrequency { get; }

Minimum frequency in Hz this controller can generate. (inherited)

MaxFrequency

public extern double MaxFrequency { get; }

Maximum frequency in Hz this controller can generate. (inherited)

Methods

Dispose()

public void Dispose()

Releases the native controller.

OpenChannel(int channel)

public extern void OpenChannel(int channel)

Acquires exclusive access to the specified channel. (inherited)

ParameterTypeDescription
channelintController-relative channel index.

CloseChannel(int channel)

public extern void CloseChannel(int channel)

Releases a previously opened channel. (inherited)

ParameterTypeDescription
channelintController-relative channel index.

EnableChannel(int channel)

public extern void EnableChannel(int channel)

Begins generating the configured waveform on the channel. (inherited)

ParameterTypeDescription
channelintController-relative channel index.

DisableChannel(int channel)

public extern void DisableChannel(int channel)

Stops the waveform; the pin is parked in its inactive state. (inherited)

ParameterTypeDescription
channelintController-relative channel index.

SetPulseParameters(int channel, double dutyCycle, PwmPulsePolarity polarity)

public extern void SetPulseParameters(int channel, double dutyCycle, PwmPulsePolarity polarity)

Sets the active duty cycle and polarity for the channel. (inherited)

ParameterTypeDescription
channelintController-relative channel index.
dutyCycledoubleActive fraction of the period, 0.0..1.0.
polarityPwmPulsePolarityWhich level is "active".

SetDesiredFrequency(double frequency)

public extern double SetDesiredFrequency(double frequency)

Sets the controller-wide frequency. (inherited)

ParameterTypeDescription
frequencydoubleTarget frequency in Hz.

Returns double — The frequency actually applied.

SetDesiredFrequency(int channel, double frequency)

public extern double SetDesiredFrequency(int channel, double frequency)

Sets a per-channel frequency where the hardware supports it. (inherited)

ParameterTypeDescription
channelintController-relative channel index.
frequencydoubleTarget frequency in Hz.

Returns double — The frequency actually applied to that channel.