Skip to content

Commit

Permalink
Miscelaneous improvements (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniofagundes authored Sep 20, 2022
1 parent f9fd30d commit 8b37d59
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
11 changes: 3 additions & 8 deletions nanoFramework.GiantGecko.Adc/AdcChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class AdcChannel : AdcChannelBase, IDisposable
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
private readonly int _channelNumber;
private readonly AdcChannelConfiguration _adcChannelConfiguration;
private int _averageCount;
#pragma warning restore IDE0052 // Remove unread private members

/// <summary>
Expand Down Expand Up @@ -71,9 +70,7 @@ public override int ReadValue()
}

// set average count to 1 for single sample
_averageCount = 1;

return NativeReadValue();
return NativeReadValue(1);
}
}

Expand All @@ -88,9 +85,7 @@ public override int ReadValueAveraged(int count)
throw new ObjectDisposedException();
}

_averageCount = count;

return NativeReadValue();
return NativeReadValue(count);
}
}

Expand Down Expand Up @@ -138,7 +133,7 @@ public void Dispose()
#region Native Calls

[MethodImpl(MethodImplOptions.InternalCall)]
private extern int NativeReadValue();
private extern int NativeReadValue(int count);

[MethodImpl(MethodImplOptions.InternalCall)]
private extern void NativeDisposeChannel();
Expand Down
6 changes: 3 additions & 3 deletions nanoFramework.GiantGecko.Adc/AdcController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class AdcController : AdcControllerBase
private int _averageCount;
private bool _continuousSamplingStarted;

private readonly AdcConfiguration _acdConfiguration;
private readonly AdcConfiguration _adcConfiguration;

/// <inheritdoc/>
public override int ChannelCount
Expand All @@ -49,7 +49,7 @@ public override SampleResolution[] SupportedResolutionsInBits
/// <summary>
/// Initialization configuration for <see cref="AdcController"/>.
/// </summary>
public AdcConfiguration AcdConfiguration => _acdConfiguration;
public AdcConfiguration AcdConfiguration => _adcConfiguration;

/// <summary>
/// Gets an array with the last samples from an ongoing scan operation.
Expand Down Expand Up @@ -101,7 +101,7 @@ public AdcController(AdcConfiguration acdInitialization)
// check if this device is already opened
if (_syncLock == null)
{
_acdConfiguration = acdInitialization;
_adcConfiguration = acdInitialization;

// call native init to allow HAL/PAL inits related with ADC hardware
// this is also used to check if the requested ADC actually exists
Expand Down
49 changes: 42 additions & 7 deletions nanoFramework.GiantGecko.Adc/ReferenceVoltage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,71 @@ public enum ReferenceVoltage
/// <summary>
/// Internal 1.25 V reference.
/// </summary>
Internal1_25V,
Internal1_25V = 0,

/// <summary>
/// Internal 2.5 V reference.
/// </summary>
Internal2_5V,
Internal2_5V = 1,

/// <summary>
/// Buffered VDD.
/// </summary>
BufferedVdd,
BufferedVdd = 2,

/// <summary>
/// Internal differential 5 V reference.
/// </summary>
InternalDifferencial_5V,
InternalDifferencial_5V = 3,

/// <summary>
/// Single-ended external reference from pin 6.
/// </summary>
SingleEndedExternalPin6,
SingleEndedExternalPin6 = 4,

/// <summary>
/// Differential external reference from pin 6 and 7.
/// </summary>
DiffExternalPin6And7,
DiffExternalPin6And7 = 5,

/// <summary>
/// Unbuffered 2xVDD.
/// </summary>
Unbuffered2Vdd,
Unbuffered2Vdd = 6,

/// <summary>
/// Internal Bandgap reference. Custom VFS.
/// </summary>
InternalBandgap = 128,

/// <summary>
/// Scaled AVDD: AVDD * VREFATT.
/// </summary>
ScaledAvdd = 129,

/// <summary>
/// Scaled singled ended external reference from pin 6: VREFP * VREFATT.
/// </summary>
ScaledSingleEndedExternalPin6 = 130,

/// <summary>
/// Raw single-ended external reference from pin 6.
/// </summary>
RawSingleEndedExternalPin6 = 131,

/// <summary>
/// Special mode for entropy generation.
/// </summary>
EntropyGeneration = 132,

/// <summary>
/// Scaled differential external Vref from pin 6 and 7: (VREFP - VREFN) * VREFATT.
/// </summary>
ScaledExternalPin6And7 = 133,

/// <summary>
/// Raw differential external Vref from pin 6 and 7: VREFP - VREFN.
/// </summary>
RawExternalPin6And7 = 134
}
}

0 comments on commit 8b37d59

Please sign in to comment.