intbcm2835_aux_spi_begin(void)[extern]
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_tbcm2835_aux_spi_CalcClockDivider(uint32_tspeed_hz)[extern]
Calculates the input for
Seealsobcm2835_aux_spi_setClockDividerParametersspeed_hz A value between
SeealsoBCM2835_AUX_SPI_CLOCK_MIN and
BCM2835_AUX_SPI_CLOCK_MAXReturns
Input for
Seealsobcm2835_aux_spi_setClockDividervoidbcm2835_aux_spi_end(void)[extern]
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.
voidbcm2835_aux_spi_setClockDivider(uint16_tdivider)[extern]
Sets the AUX SPI clock divider and therefore the AUX SPI clock speed.
Parametersdivider The desired AUX SPI clock divider.
uint8_tbcm2835_aux_spi_transfer(uint8_tvalue)[extern]
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.
Parametersvalue The 8 bit data byte to write to MOSI
Returns
The 8 bit byte simultaneously read from MISO
Seealsobcm2835_aux_spi_transfern()voidbcm2835_aux_spi_transfern(char*buf,uint32_tlen)[extern]
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.
Parametersbuf 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
Seealsobcm2835_aux_spi_transfer()voidbcm2835_aux_spi_transfernb(constchar*tbuf,char*rbuf,uint32_tlen)[extern]
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
Parameterstbuf 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
voidbcm2835_aux_spi_write(uint16_tdata)[extern]
Transfers half-word to the AUX SPI slave. Asserts the currently selected CS pins during the transfer.
Parametersdata The 8 bit data byte to write to MOSI
Returns
The 16 bit byte simultaneously read from MISO
Seealsobcm2835_spi_transfern()voidbcm2835_aux_spi_writenb(constchar*buf,uint32_tlen)[extern]
Transfers any number of bytes to the AUX SPI slave. Asserts the CE2 pin during the transfer.
Parametersbuf Buffer of bytes to send.
len Number of bytes in the tbuf buffer, and the number of bytes to send
intbcm2835_spi_begin(void)[extern]
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.
Seealsobcm2835_spi_end()Returns
1 if successful, 0 otherwise (perhaps because you are not running as root)
voidbcm2835_spi_chipSelect(uint8_tcs)[extern]
Sets the chip select pin(s) When an bcm2835_spi_transfer() is made, the selected pin(s) will be asserted
during the transfer.
Parameterscs Specifies the CS pins(s) that are used to activate the desired slave. One of BCM2835_SPI_CS*, see
bcm2835SPIChipSelectvoidbcm2835_spi_end(void)[extern]
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.
voidbcm2835_spi_set_speed_hz(uint32_tspeed_hz)[extern]
Sets the SPI clock divider by converting the speed parameter to the equivalent SPI clock divider. ( see
Seealsobcm2835_spi_setClockDivider)
Parametersspeed_hz The desired SPI clock speed in Hz
voidbcm2835_spi_setBitOrder(uint8_torder)[extern]
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.
Parametersorder The desired bit order, one of BCM2835_SPI_BIT_ORDER_*, see bcm2835SPIBitOrdervoidbcm2835_spi_setChipSelectPolarity(uint8_tcs,uint8_tactive)[extern]
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.
Parameterscs The chip select pin to affect
active Whether the chip select pin is to be active HIGH
voidbcm2835_spi_setClockDivider(uint16_tdivider)[extern]
Sets the SPI clock divider and therefore the SPI clock speed.
Parametersdivider The desired SPI clock divider, one of BCM2835_SPI_CLOCK_DIVIDER_*, see bcm2835SPIClockDividervoidbcm2835_spi_setDataMode(uint8_tmode)[extern]
Sets the SPI data mode Sets the clock polariy and phase
Parametersmode The desired data mode, one of BCM2835_SPI_MODE*, see bcm2835SPIModeuint8_tbcm2835_spi_transfer(uint8_tvalue)[extern]
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
Parametersvalue The 8 bit data byte to write to MOSI
Returns
The 8 bit byte simultaneously read from MISO
Seealsobcm2835_spi_transfern()voidbcm2835_spi_transfern(char*buf,uint32_tlen)[extern]
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.
Parametersbuf 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
Seealsobcm2835_spi_transfer()voidbcm2835_spi_transfernb(char*tbuf,char*rbuf,uint32_tlen)[extern]
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
Parameterstbuf 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
Seealsobcm2835_spi_transfer()voidbcm2835_spi_write(uint16_tdata)[extern]
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
Parametersdata The 8 bit data byte to write to MOSI
Seealsobcm2835_spi_writenb()voidbcm2835_spi_writenb(constchar*buf,uint32_tlen)[extern]
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.
Parametersbuf Buffer of bytes to send.
len Number of bytes in the buf buffer, and the number of bytes to send