Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sc16is #1108

Merged
merged 6 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading