Skip to main content

spi.chipselect(select)

Controls the imp005’s dedicated SPI Chip Select pins

Availability

Device (from impOS™ 34)
Available on the imp005 only

Parameters

Name Type Description
select Integer 1 to assert the dedicated chip select pin, or 0 to de-assert

Returns

Nothing

Description

Unlike other imps, the imp005 provides a dedicated chip select pin on each of its two SPI buses. For spiBCAD this is pin D; for spi0 this is pin CS0. This method can be used to take control of the assertion and de-assertion of these chip select pins.

The imp005’s dedicated chip select pins will be driven high automatically when the SPI mode constant USE_CS_L is used by passing it into spi.configure(). Calling spi.chipselect() with select equal to 1 drives the chip select pin low, signaling readiness for data to be written to and/or read from the bus. Calling spi.chipselect() with select equal to 0 drives the pin high once more.

An error will be thrown if spi.chipselect() is called and USE_CS_L has not been applied during SPI configuration.

An error will also be thrown if the method is called in code running on other imps. The following code can be used to detect that the code is running on an imp005:

if ("spi0" in hardware) {
  // Device is a imp005/Murata Type1GC...
}

Example Code

The following code uses spi.chipselect() to toggle the CS pin. This code will only run on the imp005