The file spi_conf.h can be provided in the application source code, without it the default values specified in spi_master.h and spi_slave.h will be used. This file can set the following defines:
DEFAULT_SPI_CLOCK_DIV
This define sets the default clock divider, which the application can use when initialising the SPI master. See spi_clock_div parameter of spi_master_init() in Configuration Functions for clock divider format.
SPI_MASTER_MODE
The SPI mode the master operates in.
Mode CPOL CPHA 0 0 0 1 0 1 2 1 0 3 1 1
SPI_SLAVE_MODE
The SPI mode the slave operates in.
Mode CPOL CPHA 0 0 0 1 0 1 2 1 0 3 1 1
Structure containing the resources required for the SPI master interface.
It consists of two 8bit buffered output ports, and one 8bit input port.
Select lines are intentionally not part of API, they are simple port outputs, which depend on how many slaves there are and how they’re connected.
Structure Members:
Configure ports and clocks, clearing port buffers.
Must be called before any SPI data input or output functions are used.
Parameters: |
|
---|
Example: To achieve an sclk frequency of 25MHz, a divider of 2 must be specified, as 100(MHz)/(2*2) = 25(MHz).
Example: To achieve an sclk frequency of 625kHz, a divider of 80 must be specified, as 100(MHz)/(2*80) = 0.625(MHz).
Stops the clocks running.
Should be called when all SPI input and output is completed.
Parameters: |
|
---|
Receive one byte.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|---|
Returns: | The received byte |
Receive one short.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|---|
Returns: | The received short |
Receive one word.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|---|
Returns: | The received word |
Receive specified number of bytes.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Transmit one byte.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Transmit one short.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Transmit one word.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Transmit specified number of bytes.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Structure containing the resources required for the SPI slave interface.
It consists of two 1bit input ports, one 8bit buffered input port, and one 8bit buffered output port.
Structure Members:
Configure ports and clocks, clearing port buffers.
Must be called before any SPI data input or output functions are used.
Parameters: |
|
---|
Stops the clocks running, and disables the ports.
Should be called when all SPI input and output is completed.
Parameters: |
|
---|
Receive one byte.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|---|
Returns: | The received byte |
Receive one short.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|---|
Returns: | The received short |
Receive one word.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|---|
Returns: | The received word |
Receive specified number of bytes.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Transmit one byte.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Transmit one short.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Transmit one word.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|
Transmit specified number of bytes.
Most significant bit first order. Big endian byte order.
Parameters: |
|
---|