![]() |
MT7697 API Reference
LinkIt SDK v4
|
This section introduces the SPI Slave APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, enums, structures and functions. More...
This section introduces the SPI Slave APIs including terms and acronyms, supported features, software architecture, details on how to use this driver, enums, structures and functions.
| Terms | Details |
|---|---|
| DMA | Direct Memory Access. DMA is a feature of computer systems that allows certain hardware subsystems to access main system memory independent from the central processing unit (CPU). |
| GPIO | General Purpose Inputs-Outputs. For more details, please refer to GPIO. |
| IRQ | Interrupt Request. For more information, please refer to IRQ. |
| MISO | Master Input, Slave Output. Output from the SPI slave. |
| MOSI | Master Output, Slave Input. Output from the SPI master. |
| NVIC | Nested Vectored Interrupt Controller. NVIC is the interrupt controller of ARM Cortex-M series processors. For more details, please refer to ARM Cortex-M4 technical reference manual. |
| SCLK | Serial Clock. Output from the SPI master. |
| SPI | Serial Peripheral Interface. The Serial Peripheral Interface bus is a synchronous serial communication interface specification used for short distance communication. For more information, please refer to Serial Peripheral Interface Bus in Wikipedia. |
| SS | Slave Select. Output from the SPI master, active low. |
Emerging sensor applications support SPI interface communication. An SPI slave interface is required to communicate with an SPI master interface. This controller is the SPI slave interface with five functional registers for communication.
Support standard mode and fast mode programming sequences.
Fast mode supports address auto increment to reduce bus address write time when the SPI slave accesses the system memory. Example 1 and 2 use standard mode. Example 3 and 4 use fast mode. The default driver settings are on fast mode to provide better throughput.
Example 1: Write 0x0123_4567 data to the address 0x1013_0004.
Example 2: Read 0x0123_4567 data from the address 0x1013_0004. Note: Check if the status is busy before reading data from the SPI slave controller.
Example 3: Write 0x0123_4567 data to the address 0x1013_0004. Write 0x89ab_cdef data to the address 0x1013_0008. SPI master sends software IRQ command to trigger SPI slave IRQ.
The architecture is similar to the interrupt mode architecture in HAL overview. See HAL Driver Model for interrupt mode architecture.
Call hal_pinmux_set_function() to pinmux the GPIO pins to four SPI pins (SS, SCLK, MOSI, and MISO) based on the user's hardware platform design. Please note that user should choose the SPI pins for SPI slave, which can support 20MHz SPI clock, to get a better throughput. Then call hal_spi_slave_init() to apply basic settings for SPI slave hardware. After that call hal_spi_slave_register_callback() to register a user callback function. The steps are shown below:
When the SPI slave is operating on high frequency clock and the hardware environment is not well designed, the SPI slave may malfunction because of bad signal integrity. Use an oscilloscope to find out which pin requires an adjustment. Normally it'll be the data pin. Then the user can adjust the driving current of a specific SPI pin by calling #hal_gpio_set_driving().
Functions | |
| hal_spi_slave_status_t | hal_spi_slave_init (hal_spi_slave_port_t spi_port, hal_spi_slave_config_t *spi_configure) |
| This function initializes the SPI slave and sets user defined common parameters including clock polarity and clock phase, always setup internal configuration for 20MHz SPI clock for better throughput. More... | |
| hal_spi_slave_status_t | hal_spi_slave_register_callback (hal_spi_slave_port_t spi_port, hal_spi_slave_callback_t callback_function, void *user_data) |
| This function registers user's callback in the SPI slave driver. More... | |
Modules | |
| Enum | |
| Struct | |
| Typedef | |
| hal_spi_slave_status_t hal_spi_slave_init | ( | hal_spi_slave_port_t | spi_port, |
| hal_spi_slave_config_t * | spi_configure | ||
| ) |
This function initializes the SPI slave and sets user defined common parameters including clock polarity and clock phase, always setup internal configuration for 20MHz SPI clock for better throughput.
Note that the SPI slave supports only MSB bit order and can't be config to LSB bit order.
| [in] | spi_port | is the SPI slave port number, the value is defined at hal_spi_slave_port_t. |
| [in] | spi_configure | is the SPI slave configure parameters. Details are described at hal_spi_slave_config_t. |
| hal_spi_slave_status_t hal_spi_slave_register_callback | ( | hal_spi_slave_port_t | spi_port, |
| hal_spi_slave_callback_t | callback_function, | ||
| void * | user_data | ||
| ) |
This function registers user's callback in the SPI slave driver.
This function may be called when using the SPI slave driver, the callback will be called in SPI interrupt service routine.
| [in] | spi_port | is the SPI slave port number, the value is defined at hal_spi_slave_port_t. |
| [in] | callback_function | is the callback function given by user, which will be called at SPI slave interrupt service routine. |
| [in] | user_data | is a parameter given by user and will pass to user while the callback function is called. |