-
Notifications
You must be signed in to change notification settings - Fork 580
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
SpiConnectionSettings should have a property for chip select active state #201
Comments
@krwq could you please investigate for 3.0? |
@shaggygi got any specific devices in mind? (just curious) |
@krwq I came across this when trying to use with bit-banging GPIO pins. You can use SPI with a 74595 logic chip. While I have a partial binding started for this chip, it could be used with something like I2C/SPI Character LCD Backpack using SPI (with active-high CS). While reviewing this topic, I found that many processors allow CS enable to be configured to Low or High. I also came across various SPI tools where they can be configured and blogs/forums where users state they have a device that needs to be active-high enabled. However, there was never a specific device name mentioned where I could verify the CS interface. I agree most cases will be active-low CS as that appears to be the preferred method. I'm just thinking this option might need to be available sooner than later. Hope this helps. |
Given that this doesn't really apply to every device, I think that I would prefer if the active state would be passed in (with a paramter on the constructor) on the binding itself. Most of the devices I've worked with only allow having one state for the CS, so I don't think this should go on the SpiConnection class IMHO. |
@krwq I like your idea better with an enum. Not sure if you were thinking of a new enum or possibly use PinValue where it would accept a few ways. If so, we might want to use // By PinValue.Low or PinValue.High
var spiConnectionSettings = new SpiConnectionSettings(0, 0)
{
ChipSelectActiveState = PinValue.High,
ClockFrequency = 1000000,
Mode = SpiMode.Mode0
};
// By false or true
var spiConnectionSettings = new SpiConnectionSettings(0, 0)
{
ChipSelectActiveState = true,
ClockFrequency = 1000000,
Mode = SpiMode.Mode0
};
// By 0 or 1
var spiConnectionSettings = new SpiConnectionSettings(0, 0)
{
ChipSelectActiveState = 1,
ClockFrequency = 1000000,
Mode = SpiMode.Mode0
}; |
But then again, if we added an enum for #202, we might want to group related enums under the SPI namespace like var spiConnectionSettings = new SpiConnectionSettings(0, 0)
{
ChipSelectState = ChipSelectState.ActiveHigh,
DataFlow = DataFlow.MsbFirst,
ClockFrequency = 1000000,
Mode = SpiMode.Mode0
}; |
Yes this looks more or less correct - once I (or someone else) start working on this we can take a closer look at the exact shape and what makes most sense (probably makes sense to compare to other implementations like python/C and see what they call these so that we call them similarly). |
This proposal is to add a chip select active state property to the SpiConnectionSettings class.
Rationale and Usage
While most SPI devices are selected with an active-low chip select pin, there are devices that are active-high. To overcome this today (to my current knowledge) is adding additional hardware logic to inverse the select line between master/slave devices.
Proposed Changes
The proposed change is to add a new property for a chip select active state.
ChipSelectActiveHigh
or similar. It could have a default value offalse
that represents active-high since this is the minority use.SpiConnectionSettings
constructor as is similar to other properties likeClockFrequency
,Mode
, etc..References
Open Questions
The text was updated successfully, but these errors were encountered: