Provided by: libbcm2835-dev_1.71+ds-1_amd64 bug

NAME

       spi - SPI access

SYNOPSIS

   Functions
       int bcm2835_spi_begin (void)
       void bcm2835_spi_end (void)
       void bcm2835_spi_setBitOrder (uint8_t order)
       void bcm2835_spi_setClockDivider (uint16_t divider)
       void bcm2835_spi_set_speed_hz (uint32_t speed_hz)
       void bcm2835_spi_setDataMode (uint8_t mode)
       void bcm2835_spi_chipSelect (uint8_t cs)
       void bcm2835_spi_setChipSelectPolarity (uint8_t cs, uint8_t active)
       uint8_t bcm2835_spi_transfer (uint8_t value)
       void bcm2835_spi_transfernb (char *tbuf, char *rbuf, uint32_t len)
       void bcm2835_spi_transfern (char *buf, uint32_t len)
       void bcm2835_spi_writenb (const char *buf, uint32_t len)
       void bcm2835_spi_write (uint16_t data)
       int bcm2835_aux_spi_begin (void)
       void bcm2835_aux_spi_end (void)
       void bcm2835_aux_spi_setClockDivider (uint16_t divider)
       uint16_t bcm2835_aux_spi_CalcClockDivider (uint32_t speed_hz)
       void bcm2835_aux_spi_write (uint16_t data)
       void bcm2835_aux_spi_writenb (const char *buf, uint32_t len)
       void bcm2835_aux_spi_transfern (char *buf, uint32_t len)
       void bcm2835_aux_spi_transfernb (const char *tbuf, char *rbuf, uint32_t len)
       uint8_t bcm2835_aux_spi_transfer (uint8_t value)

Detailed Description

       These functions let you use SPI0 (Serial Peripheral Interface) to interface with an
       external SPI device.

Function Documentation

   int bcm2835_aux_spi_begin (void)
       Start AUX SPI operations. Forces RPi AUX SPI pins P1-38 (MOSI), P1-38 (MISO), P1-40 (CLK)
       and P1-36 (CE2) to alternate function ALT4, which enables those pins for SPI interface.

       Returns
           1 if successful, 0 otherwise (perhaps because you are not running as root)

   uint16_t bcm2835_aux_spi_CalcClockDivider (uint32_t speed_hz)
       Calculates the input for

       See also
           bcm2835_aux_spi_setClockDivider

       Parameters
           speed_hz A value between

       See also
           BCM2835_AUX_SPI_CLOCK_MIN and

           BCM2835_AUX_SPI_CLOCK_MAX

       Returns
           Input for

       See also
           bcm2835_aux_spi_setClockDivider

   void bcm2835_aux_spi_end (void)
       End AUX SPI operations. SPI1 pins P1-38 (MOSI), P1-38 (MISO), P1-40 (CLK) and P1-36 (CE2)
       are returned to their default INPUT behaviour.

   void bcm2835_aux_spi_setClockDivider (uint16_t divider)
       Sets the AUX SPI clock divider and therefore the AUX SPI clock speed.

       Parameters
           divider The desired AUX SPI clock divider.

   uint8_t bcm2835_aux_spi_transfer (uint8_t value)
       Transfers one byte to and from the AUX SPI slave. Clocks the 8 bit value out on MOSI, and
       simultaneously clocks in data from MISO. Returns the read data byte from the slave.

       Parameters
           value The 8 bit data byte to write to MOSI

       Returns
           The 8 bit byte simultaneously read from MISO

       See also
           bcm2835_aux_spi_transfern()

   void bcm2835_aux_spi_transfern (char * buf, uint32_t len)
       Transfers any number of bytes to and from the AUX SPI slave using
       bcm2835_aux_spi_transfernb. The returned data from the slave replaces the transmitted data
       in the buffer.

       Parameters
           buf Buffer of bytes to send. Received bytes will replace the contents
           len Number of bytes in the buffer, and the number of bytes to send/received

       See also
           bcm2835_aux_spi_transfer()

   void bcm2835_aux_spi_transfernb (const char * tbuf, char * rbuf, uint32_t len)
       Transfers any number of bytes to and from the AUX SPI slave. Asserts the CE2 pin during
       the transfer. Clocks the len 8 bit bytes out on MOSI, and simultaneously clocks in data
       from MISO. The data read read from the slave is placed into rbuf. rbuf must be at least
       len bytes long

       Parameters
           tbuf Buffer of bytes to send.
           rbuf Received bytes will by put in this buffer
           len Number of bytes in the tbuf buffer, and the number of bytes to send/received

   void bcm2835_aux_spi_write (uint16_t data)
       Transfers half-word to the AUX SPI slave. Asserts the currently selected CS pins during
       the transfer.

       Parameters
           data The 8 bit data byte to write to MOSI

       Returns
           The 16 bit byte simultaneously read from MISO

       See also
           bcm2835_spi_transfern()

   void bcm2835_aux_spi_writenb (const char * buf, uint32_t len)
       Transfers any number of bytes to the AUX SPI slave. Asserts the CE2 pin during the
       transfer.

       Parameters
           buf Buffer of bytes to send.
           len Number of bytes in the tbuf buffer, and the number of bytes to send

   int bcm2835_spi_begin (void)
       Start SPI operations. Forces RPi SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24
       (CE0) and P1-26 (CE1) to alternate function ALT0, which enables those pins for SPI
       interface. You should call bcm2835_spi_end() when all SPI funcitons are complete to return
       the pins to their default functions.

       See also
           bcm2835_spi_end()

       Returns
           1 if successful, 0 otherwise (perhaps because you are not running as root)

   void bcm2835_spi_chipSelect (uint8_t cs)
       Sets the chip select pin(s) When an bcm2835_spi_transfer() is made, the selected pin(s)
       will be asserted during the transfer.

       Parameters
           cs Specifies the CS pins(s) that are used to activate the desired slave. One of
           BCM2835_SPI_CS*, see bcm2835SPIChipSelect

   void bcm2835_spi_end (void)
       End SPI operations. SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and
       P1-26 (CE1) are returned to their default INPUT behaviour.

   void bcm2835_spi_set_speed_hz (uint32_t speed_hz)
       Sets the SPI clock divider by converting the speed parameter to the equivalent SPI clock
       divider. ( see

       See also
           bcm2835_spi_setClockDivider)

       Parameters
           speed_hz The desired SPI clock speed in Hz

   void bcm2835_spi_setBitOrder (uint8_t order)
       Sets the SPI bit order Set the bit order to be used for transmit and receive. The bcm2835
       SPI0 only supports BCM2835_SPI_BIT_ORDER_MSB, so if you select BCM2835_SPI_BIT_ORDER_LSB,
       the bytes will be reversed in software. The library defaults to BCM2835_SPI_BIT_ORDER_MSB.

       Parameters
           order The desired bit order, one of BCM2835_SPI_BIT_ORDER_*, see bcm2835SPIBitOrder

   void bcm2835_spi_setChipSelectPolarity (uint8_t cs, uint8_t active)
       Sets the chip select pin polarity for a given pin When an bcm2835_spi_transfer() occurs,
       the currently selected chip select pin(s) will be asserted to the value given by active.
       When transfers are not happening, the chip select pin(s) return to the complement
       (inactive) value.

       Parameters
           cs The chip select pin to affect
           active Whether the chip select pin is to be active HIGH

   void bcm2835_spi_setClockDivider (uint16_t divider)
       Sets the SPI clock divider and therefore the SPI clock speed.

       Parameters
           divider The desired SPI clock divider, one of BCM2835_SPI_CLOCK_DIVIDER_*, see
           bcm2835SPIClockDivider

   void bcm2835_spi_setDataMode (uint8_t mode)
       Sets the SPI data mode Sets the clock polariy and phase

       Parameters
           mode The desired data mode, one of BCM2835_SPI_MODE*, see bcm2835SPIMode

   uint8_t bcm2835_spi_transfer (uint8_t value)
       Transfers one byte to and from the currently selected SPI slave. Asserts the currently
       selected CS pins (as previously set by bcm2835_spi_chipSelect) during the transfer. Clocks
       the 8 bit value out on MOSI, and simultaneously clocks in data from MISO. Returns the read
       data byte from the slave. Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM
       Peripherls manual

       Parameters
           value The 8 bit data byte to write to MOSI

       Returns
           The 8 bit byte simultaneously read from MISO

       See also
           bcm2835_spi_transfern()

   void bcm2835_spi_transfern (char * buf, uint32_t len)
       Transfers any number of bytes to and from the currently selected SPI slave using
       bcm2835_spi_transfernb. The returned data from the slave replaces the transmitted data in
       the buffer.

       Parameters
           buf Buffer of bytes to send. Received bytes will replace the contents
           len Number of bytes int eh buffer, and the number of bytes to send/received

       See also
           bcm2835_spi_transfer()

   void bcm2835_spi_transfernb (char * tbuf, char * rbuf, uint32_t len)
       Transfers any number of bytes to and from the currently selected SPI slave. Asserts the
       currently selected CS pins (as previously set by bcm2835_spi_chipSelect) during the
       transfer. Clocks the len 8 bit bytes out on MOSI, and simultaneously clocks in data from
       MISO. The data read read from the slave is placed into rbuf. rbuf must be at least len
       bytes long Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls
       manual

       Parameters
           tbuf Buffer of bytes to send.
           rbuf Received bytes will by put in this buffer
           len Number of bytes in the tbuf buffer, and the number of bytes to send/received

       See also
           bcm2835_spi_transfer()

   void bcm2835_spi_write (uint16_t data)
       Transfers half-word to the currently selected SPI slave. Asserts the currently selected CS
       pins (as previously set by bcm2835_spi_chipSelect) during the transfer. Clocks the 8 bit
       value out on MOSI, and simultaneously clocks in data from MISO. Uses polled transfer as
       per section 10.6.1 of the BCM 2835 ARM Peripherls manual

       Parameters
           data The 8 bit data byte to write to MOSI

       See also
           bcm2835_spi_writenb()

   void bcm2835_spi_writenb (const char * buf, uint32_t len)
       Transfers any number of bytes to the currently selected SPI slave. Asserts the currently
       selected CS pins (as previously set by bcm2835_spi_chipSelect) during the transfer.

       Parameters
           buf Buffer of bytes to send.
           len Number of bytes in the buf buffer, and the number of bytes to send

Author

       Generated automatically by Doxygen for bcm2835 from the source code.