Mbed OS Reference
Loading...
Searching...
No Matches
Synchronous SPI Hardware Abstraction Layer

Functions

int spi_master_write (spi_t *obj, int value)
 Write a byte out in master mode and receive a value. More...
 
int spi_master_block_write (spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, char write_fill)
 Write a block out in master mode and receive a value. More...
 
int spi_slave_receive (spi_t *obj)
 Check if a value is available to read. More...
 
int spi_slave_read (spi_t *obj)
 Get a received value out of the SPI receive buffer in slave mode. More...
 
void spi_slave_write (spi_t *obj, int value)
 Write a value to the SPI peripheral in slave mode. More...
 
int spi_busy (spi_t *obj)
 Checks if the specified SPI peripheral is in use. More...
 
uint8_t spi_get_module (spi_t *obj)
 Get the module number. More...
 
const PinMapspi_master_mosi_pinmap (void)
 Get the pins that support SPI MOSI. More...
 
const PinMapspi_master_miso_pinmap (void)
 Get the pins that support SPI MISO. More...
 
const PinMapspi_master_clk_pinmap (void)
 Get the pins that support SPI CLK. More...
 
const PinMapspi_master_cs_pinmap (void)
 Get the pins that support SPI CS. More...
 
const PinMapspi_slave_mosi_pinmap (void)
 Get the pins that support SPI MOSI. More...
 
const PinMapspi_slave_miso_pinmap (void)
 Get the pins that support SPI MISO. More...
 
const PinMapspi_slave_clk_pinmap (void)
 Get the pins that support SPI CLK. More...
 
const PinMapspi_slave_cs_pinmap (void)
 Get the pins that support SPI CS. More...
 

Detailed Description

Function Documentation

◆ spi_master_write()

int spi_master_write ( spi_t obj,
int  value 
)

Write a byte out in master mode and receive a value.

Parameters
[in]objThe SPI peripheral to use for sending
[in]valueThe value to send
Returns
Returns the value received during send

◆ spi_master_block_write()

int spi_master_block_write ( spi_t obj,
const char *  tx_buffer,
int  tx_length,
char *  rx_buffer,
int  rx_length,
char  write_fill 
)

Write a block out in master mode and receive a value.

The total number of bytes sent and received will be the maximum of tx_length and rx_length. The bytes written will be padded with the value 0xff.

Note: Even if the word size / bits per frame is not 8, rx_length and tx_length still give lengths in bytes of input data, not numbers of words.

Parameters
[in]objThe SPI peripheral to use for sending
[in]tx_bufferPointer to the byte-array of data to write to the device
[in]tx_lengthNumber of bytes to write, may be zero
[in]rx_bufferPointer to the byte-array of data to read from the device
[in]rx_lengthNumber of bytes to read, may be zero
[in]write_fillDefault data transmitted while performing a read
Returns
The number of bytes written and read from the device. This is maximum of tx_length and rx_length.

◆ spi_slave_receive()

int spi_slave_receive ( spi_t obj)

Check if a value is available to read.

Parameters
[in]objThe SPI peripheral to check
Returns
non-zero if a value is available

◆ spi_slave_read()

int spi_slave_read ( spi_t obj)

Get a received value out of the SPI receive buffer in slave mode.

Blocks until a value is available

Parameters
[in]objThe SPI peripheral to read
Returns
The value received

◆ spi_slave_write()

void spi_slave_write ( spi_t obj,
int  value 
)

Write a value to the SPI peripheral in slave mode.

Blocks until the SPI peripheral can be written to

Parameters
[in]objThe SPI peripheral to write
[in]valueThe value to write

◆ spi_busy()

int spi_busy ( spi_t obj)

Checks if the specified SPI peripheral is in use.

Parameters
[in]objThe SPI peripheral to check
Returns
non-zero if the peripheral is currently transmitting

◆ spi_get_module()

uint8_t spi_get_module ( spi_t obj)

Get the module number.

Parameters
[in]objThe SPI peripheral to check
Returns
The module number

◆ spi_master_mosi_pinmap()

const PinMap * spi_master_mosi_pinmap ( void  )

Get the pins that support SPI MOSI.

Return a PinMap array of pins that support SPI MOSI in master mode. The array is terminated with {NC, NC, 0}.

Returns
PinMap array

◆ spi_master_miso_pinmap()

const PinMap * spi_master_miso_pinmap ( void  )

Get the pins that support SPI MISO.

Return a PinMap array of pins that support SPI MISO in master mode. The array is terminated with {NC, NC, 0}.

Returns
PinMap array

◆ spi_master_clk_pinmap()

const PinMap * spi_master_clk_pinmap ( void  )

Get the pins that support SPI CLK.

Return a PinMap array of pins that support SPI CLK in master mode. The array is terminated with {NC, NC, 0}.

Returns
PinMap array

◆ spi_master_cs_pinmap()

const PinMap * spi_master_cs_pinmap ( void  )

Get the pins that support SPI CS.

Return a PinMap array of pins that support SPI CS in master mode. The array is terminated with {NC, NC, 0}.

Returns
PinMap array

◆ spi_slave_mosi_pinmap()

const PinMap * spi_slave_mosi_pinmap ( void  )

Get the pins that support SPI MOSI.

Return a PinMap array of pins that support SPI MOSI in slave mode. The array is terminated with {NC, NC, 0}.

Returns
PinMap array

◆ spi_slave_miso_pinmap()

const PinMap * spi_slave_miso_pinmap ( void  )

Get the pins that support SPI MISO.

Return a PinMap array of pins that support SPI MISO in slave mode. The array is terminated with {NC, NC, 0}.

Returns
PinMap array

◆ spi_slave_clk_pinmap()

const PinMap * spi_slave_clk_pinmap ( void  )

Get the pins that support SPI CLK.

Return a PinMap array of pins that support SPI CLK in slave mode. The array is terminated with {NC, NC, 0}.

Returns
PinMap array

◆ spi_slave_cs_pinmap()

const PinMap * spi_slave_cs_pinmap ( void  )

Get the pins that support SPI CS.

Return a PinMap array of pins that support SPI CS in slave mode. The array is terminated with {NC, NC, 0}.

Returns
PinMap array