Skip to content

Commit

Permalink
Merge pull request #1108 from WildernessLabs/feature/sc16is
Browse files Browse the repository at this point in the history
Feature/sc16is
  • Loading branch information
adrianstevens authored Jan 4, 2025
2 parents fa2da40 + cb9335d commit e3f5736
Show file tree
Hide file tree
Showing 7 changed files with 619 additions and 569 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ public enum Addresses : byte
public enum FsrGain
{
/// <summary>
/// 2/3rds
/// Gain = 2/3rds. Range: ±6.144 V
/// </summary>
TwoThirds = 0x00,
/// <summary>
/// 1
/// Gain = 1. Range: ±4.096 V
/// </summary>
One = 0x01,
/// <summary>
/// 2
/// Gain = 2. Range: ±2.048 V
/// </summary>
Two = 0x02,
/// <summary>
/// 4
/// Gain = 4. Range: ±1.024 V
/// </summary>
Four = 0x03,
/// <summary>
/// 8
/// Gain = 8. Range: ±0.512 V
/// </summary>
Eight = 0x04,
/// <summary>
/// 16
/// Gain = 16. Range: ±0.256 V
/// </summary>
Sixteen = 0x05
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,82 @@
namespace Meadow.Foundation.ICs.IOExpanders
using System;

namespace Meadow.Foundation.ICs.IOExpanders
{
public partial class Sc16is7x2
{
/// <summary>
/// Address pin connection used for calculating peripherla addresses
/// </summary>
public enum AddressConnection
{
/// <summary>
/// Address pin tied to VDD
/// </summary>
VDD,
/// <summary>
/// Address pin tied to GND
/// </summary>
GND,
/// <summary>
/// Address pin tied to SCL
/// </summary>
SCL,
/// <summary>
/// Address pin tied to SDA
/// </summary>
SDA
}

/// <summary>
/// Calculates a bus address based on the connection of the address pins
/// </summary>
/// <param name="a0">A0's pin connection</param>
/// <param name="a1">A1's pin connection</param>
public static Addresses CalculateAddress(AddressConnection a0, AddressConnection a1)
{
switch (a1)
{
case AddressConnection.VDD:
switch (a0)
{
case AddressConnection.VDD: return Addresses.Address_0x48;
case AddressConnection.GND: return Addresses.Address_0x49;
case AddressConnection.SCL: return Addresses.Address_0x4A;
case AddressConnection.SDA: return Addresses.Address_0x4B;
}
break;
case AddressConnection.GND:
switch (a0)
{
case AddressConnection.VDD: return Addresses.Address_0x4C;
case AddressConnection.GND: return Addresses.Address_0x4D;
case AddressConnection.SCL: return Addresses.Address_0x4E;
case AddressConnection.SDA: return Addresses.Address_0x4F;
}
break;
case AddressConnection.SCL:
switch (a0)
{
case AddressConnection.VDD: return Addresses.Address_0x50;
case AddressConnection.GND: return Addresses.Address_0x51;
case AddressConnection.SCL: return Addresses.Address_0x52;
case AddressConnection.SDA: return Addresses.Address_0x53;
}
break;
case AddressConnection.SDA:
switch (a0)
{
case AddressConnection.VDD: return Addresses.Address_0x54;
case AddressConnection.GND: return Addresses.Address_0x55;
case AddressConnection.SCL: return Addresses.Address_0x56;
case AddressConnection.SDA: return Addresses.Address_0x57;
}
break;
}

throw new ArgumentException();
}

/// <summary>
/// The list of possible I2C addresses for the peripheral
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public Sc16is7x2(II2cBus i2cBus, Frequency oscillatorFrequency, Addresses addres
: this(oscillatorFrequency, irq, latchGpioInterrupt)
{
_i2cComms = new I2cCommunications(i2cBus, (byte)address);
Reset();
}
}
}
}
Loading

0 comments on commit e3f5736

Please sign in to comment.