Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

[SpiChannel] Question & suggestion #414

Open
BILLyTheLiTTle opened this issue Jun 2, 2018 · 0 comments
Open

[SpiChannel] Question & suggestion #414

BILLyTheLiTTle opened this issue Jun 2, 2018 · 0 comments

Comments

@BILLyTheLiTTle
Copy link

BILLyTheLiTTle commented Jun 2, 2018

I am trying to have more than 2 devices in SPI0.

I used a GPIO as CS pin.
val pinCS = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_29, "CS")

I am using the MCP23S17GpioProvider class but this class always needs an SpiChannel. I am setting it to SpiChannel.CS0 just to avoid any exceptions.
val provider = MCP23S17GpioProvider(MCP23S17GpioProvider.ADDRESS_0, SpiChannel.CS0)

I successfully done it by setting to low the CS pin before the job and after the job is done to set it to high.
// select the device
pinCS.low()

do the job you have to do

// deselect the device
pinCS.high()

This is not the right way to do it, because I use (for Exception reasons) the CS0 to the MCP23S17GpioProvider contructor. Is there any better way to do it?

Would be a good idea to add another value (SpiChannel.CS) with -1 value just to let the user do whatever he wants?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant