![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform various SPI master operations. More...
This section describes the M2MB APIs to perform various SPI master operations.
#define M2MB_SPI_BAUD_RATE_10MHZ 10000000 |
baud rate 10MHZ
Definition at line 60 of file m2mb_spi_master.h.
#define M2MB_SPI_BITS_PER_WORD_8 8 |
bits per word
Definition at line 58 of file m2mb_spi_master.h.
#define M2MB_SPI_CLKPHASE_FALLING_EDGE 1 |
SPI clock falling edge
Definition at line 56 of file m2mb_spi_master.h.
#define M2MB_SPI_CLKPHASE_RISING_EDGE 0 |
SPI clock rising edge
Definition at line 55 of file m2mb_spi_master.h.
#define M2MB_SPI_CLKPOL_IDLE_HIGH 1 |
SPI clock polarity idle high
Definition at line 53 of file m2mb_spi_master.h.
#define M2MB_SPI_CLKPOL_IDLE_LOW 0 |
SPI clock polarity idle low
Definition at line 52 of file m2mb_spi_master.h.
typedef void(* M2MB_SPI_CALLBACK_FN_T) (UINT32 status, void *callback_ctxt) |
Definition at line 152 of file m2mb_spi_master.h.
typedef void* M2MB_SPI_ID_t |
Definition at line 155 of file m2mb_spi_master.h.
typedef enum M2MB_SPI_IOCTL_REQUEST M2MB_SPI_IOCTL_REQUEST_T |
Definition at line 139 of file m2mb_spi_master.h.
enum M2MB_SPI_CLK_MODE_T |
Enumerator | |
---|---|
M2MB_SPI_CLK_NORMAL | Turns off the SPI clock during the Idle state |
M2MB_SPI_CLK_ALLWAYS_ON | Runs the SPI clock during the Idle state |
M2MB_SPI_CLK_INVALID |
Definition at line 120 of file m2mb_spi_master.h.
enum M2MB_SPI_CS_MODE_T |
Definition at line 130 of file m2mb_spi_master.h.
Definition at line 111 of file m2mb_spi_master.h.
Definition at line 65 of file m2mb_spi_master.h.
Definition at line 100 of file m2mb_spi_master.h.
close a SPI device
close a SPI device
[in] | fd | file descriptor returned by m2mb_spi_open |
Example
INT32 m2mb_spi_ioctl | ( | INT32 | fd, |
M2MB_SPI_IOCTL_REQUEST_T | request, | ||
... | |||
) |
configure a SPI device
configure a SPI device. Pass pointer to the set/get val, casted to void* as the variable argument.
[in] | fd | file descriptor returned by m2mb_spi_open |
[in] | request | required operation (see M2MB_SPI_IOCTL_REQUEST) |
Example
open a SPI device
open a SPI device
[in] | path | /dev/devspiX.Y where X is the HW SPI master instance index (from 1 to 24). Default is 5. Y is the SPI slave device index (from 0 to 6). At most 7 slaves are allowed. Default is 0. Path "/dev/devspiX" is equivalent to default "/dev/devspiX.0" Path "/dev/devspi" is equivalent to default "/dev/devspi5.0" |
[in] | flags | currently unused |
Example
read nbyte Bytes from a SPI device into the array pointed by buf
read nbyte Bytes from a SPI device into the array pointed by buf
[in] | fd | file descriptor returned by m2mb_spi_open |
[in] | buf | destination buffer, previously allocated |
[in] | nbyte | length of destination buffer in Bytes |
Example
write nbyte Bytes from the array pointed by buf to a SPI device
write nbyte Bytes from the array pointed by buf to a SPI device
[in] | fd | file descriptor returned by m2mb_spi_open |
[in] | buf | source buffer, previously allocated |
[in] | nbyte | length of source buffer in Bytes |
Example
perform a bi-directional (full duplex) transfer.
perform a bi-directional (full duplex) transfer. Read nbyte Bytes from a SPI device into the buffer bufRd and write nbyte Bytes from the buffer bufWr to a SPI device
[in] | fd | file descriptor returned by m2mb_spi_open |
[in] | bufwr | source buffer, previously allocated |
[in] | bufWr | destination buffer, previously allocated |
[in] | nbyte | length of source and destination buffers in Bytes |
Example