|
mraa
0.7.1
Low Level Skeleton Library for Communication on GNU/Linux platforms
|
This file defines the spi interface for libmraa. A Spi object in libmraa represents a spidev device. Linux spidev devices are created per spi bus and every chip select available on that bus has another spidev 'file'. A lot more information on spidev devices is available here.
Go to the source code of this file.
Functions | |
| mraa_spi_context | mraa_spi_init (int bus) |
| mraa_spi_context | mraa_spi_init_raw (unsigned int bus, unsigned int cs) |
| mraa_result_t | mraa_spi_mode (mraa_spi_context dev, mraa_spi_mode_t mode) |
| mraa_result_t | mraa_spi_frequency (mraa_spi_context dev, int hz) |
| int | mraa_spi_write (mraa_spi_context dev, uint8_t data) |
| uint16_t | mraa_spi_write_word (mraa_spi_context dev, uint16_t data) |
| uint8_t * | mraa_spi_write_buf (mraa_spi_context dev, uint8_t *data, int length) |
| uint16_t * | mraa_spi_write_buf_word (mraa_spi_context dev, uint16_t *data, int length) |
| mraa_result_t | mraa_spi_transfer_buf (mraa_spi_context dev, uint8_t *data, uint8_t *rxbuf, int length) |
| mraa_result_t | mraa_spi_transfer_buf_word (mraa_spi_context dev, uint16_t *data, uint16_t *rxbuf, int length) |
| mraa_result_t | mraa_spi_lsbmode (mraa_spi_context dev, mraa_boolean_t lsb) |
| mraa_result_t | mraa_spi_bit_per_word (mraa_spi_context dev, unsigned int bits) |
| mraa_result_t | mraa_spi_stop (mraa_spi_context dev) |
Typedefs | |
| typedef struct _spi * | mraa_spi_context |
Enumerations | |
| enum | mraa_spi_mode_t { MRAA_SPI_MODE0 = 0, MRAA_SPI_MODE1 = 1, MRAA_SPI_MODE2 = 2, MRAA_SPI_MODE3 = 3 } |
| mraa_spi_context mraa_spi_init | ( | int | bus | ) |
Initialise SPI_context, uses board mapping. Sets the muxes
| bus | Bus to use, as listed in platform definition, normally 0 |

| mraa_spi_context mraa_spi_init_raw | ( | unsigned int | bus, |
| unsigned int | cs | ||
| ) |
Initialise SPI_context without any board configuration, selects a bus and a mux.
| bus | Bus to use as listed by spidev |
| cs | Chip select to use as listed in spidev |
| mraa_result_t mraa_spi_mode | ( | mraa_spi_context | dev, |
| mraa_spi_mode_t | mode | ||
| ) |
Set the SPI device mode. see spidev 0-3.
| dev | The Spi context |
| mode | The SPI mode, See Linux spidev |

| mraa_result_t mraa_spi_frequency | ( | mraa_spi_context | dev, |
| int | hz | ||
| ) |
Set the SPI device operating clock frequency.
| dev | the Spi context |
| hz | the frequency in hz |

| int mraa_spi_write | ( | mraa_spi_context | dev, |
| uint8_t | data | ||
| ) |
Write Single Byte to the SPI device.
| dev | The Spi context |
| data | Data to send |

| uint16_t mraa_spi_write_word | ( | mraa_spi_context | dev, |
| uint16_t | data | ||
| ) |
Write Two Bytes to the SPI device.
| dev | The Spi context |
| data | Data to send |

| uint8_t* mraa_spi_write_buf | ( | mraa_spi_context | dev, |
| uint8_t * | data, | ||
| int | length | ||
| ) |
Write Buffer of bytes to the SPI device. The pointer return has to be free'd by the caller. It will return a NULL pointer in cases of error.
| dev | The Spi context |
| data | to send |
| length | elements within buffer, Max 4096 |

| uint16_t* mraa_spi_write_buf_word | ( | mraa_spi_context | dev, |
| uint16_t * | data, | ||
| int | length | ||
| ) |
Write Buffer of uint16 to the SPI device. The pointer return has to be free'd by the caller. It will return a NULL pointer in cases of error.
| dev | The Spi context |
| data | to send |
| length | elements (in bytes) within buffer, Max 4096 |

| mraa_result_t mraa_spi_transfer_buf | ( | mraa_spi_context | dev, |
| uint8_t * | data, | ||
| uint8_t * | rxbuf, | ||
| int | length | ||
| ) |
Transfer Buffer of bytes to the SPI device. Both send and recv buffers are passed in
| dev | The Spi context |
| data | to send |
| rxbuf | buffer to recv data back, may be NULL |
| length | elements within buffer, Max 4096 |

| mraa_result_t mraa_spi_transfer_buf_word | ( | mraa_spi_context | dev, |
| uint16_t * | data, | ||
| uint16_t * | rxbuf, | ||
| int | length | ||
| ) |
Transfer Buffer of uint16 to the SPI device. Both send and recv buffers are passed in
| dev | The Spi context |
| data | to send |
| rxbuf | buffer to recv data back, may be NULL |
| length | elements (in bytes) within buffer, Max 4096 |

| mraa_result_t mraa_spi_lsbmode | ( | mraa_spi_context | dev, |
| mraa_boolean_t | lsb | ||
| ) |
Change the SPI lsb mode
| dev | The Spi context |
| lsb | Use least significant bit transmission. 0 for msbi |

| mraa_result_t mraa_spi_bit_per_word | ( | mraa_spi_context | dev, |
| unsigned int | bits | ||
| ) |
Set bits per mode on transaction, defaults at 8
| dev | The Spi context |
| bits | bits per word |

| mraa_result_t mraa_spi_stop | ( | mraa_spi_context | dev | ) |
De-inits an mraa_spi_context device
| dev | The Spi context |

| typedef struct _spi* mraa_spi_context |
Opaque pointer definition to the internal struct _spi
| enum mraa_spi_mode_t |
MRAA SPI Modes

1.8.9.1