Core SPI library.
More...
#include <stdint.h>
#include <stdbool.h>
#include <stm32g4xx_hal.h>
Go to the source code of this file.
|
| bool | core_SPI_init (SPI_TypeDef *spi, GPIO_TypeDef *cs_port, uint16_t cs_pin) |
| | Initialize an SPI module and set up a CS pin for it.
|
| |
| bool | core_SPI_read_write (SPI_TypeDef *spi, uint8_t *txbuf, uint32_t txbuflen, uint8_t *rxbuf, uint32_t rxbuflen) |
| | Transmit data from a buffer on the given SPI bus and store the incoming data in a separate buffer.
|
| |
| bool | core_SPI_start (SPI_TypeDef *spi) |
| | Set the CS pin for an SPI bus low.
|
| |
| bool | core_SPI_stop (SPI_TypeDef *spi) |
| | Set the CS pin for an SPI bus high.
|
| |
Core SPI library.
This core library component is used to interact with SPI devices.
◆ core_SPI_init()
| bool core_SPI_init |
( |
SPI_TypeDef * | spi, |
|
|
GPIO_TypeDef * | cs_port, |
|
|
uint16_t | cs_pin ) |
Initialize an SPI module and set up a CS pin for it.
- Parameters
-
| spi | The SPI module to be initialized |
| cs_port | Port the CS pin is located on (GPIOx) |
| cs_pin | CS pin (GPIO_PIN_x) |
◆ core_SPI_read_write()
| bool core_SPI_read_write |
( |
SPI_TypeDef * | spi, |
|
|
uint8_t * | txbuf, |
|
|
uint32_t | txbuflen, |
|
|
uint8_t * | rxbuf, |
|
|
uint32_t | rxbuflen ) |
Transmit data from a buffer on the given SPI bus and store the incoming data in a separate buffer.
- Note
- The number of bytes transmitted or received on the SPI bus is the greater of txbuflen and rxbuflen. Only the number of bytes given by each parameter will be read/stored respectively.
- Parameters
-
| spi | The SPI module |
| txbuf | Buffer from which data to be transmitted is read |
| txbuflen | Number of bytes to read from the TX buffer |
| rxbuf | Buffer to which received data is to be stored |
| rxbuflen | Number of bytes to write to the RX buffer |
◆ core_SPI_start()
| bool core_SPI_start |
( |
SPI_TypeDef * | spi | ) |
|
Set the CS pin for an SPI bus low.
- Parameters
-
◆ core_SPI_stop()
| bool core_SPI_stop |
( |
SPI_TypeDef * | spi | ) |
|
Set the CS pin for an SPI bus high.
- Parameters
-