ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_spi.h
Go to the documentation of this file.
1 #ifndef RUUVI_INTERFACE_SPI_H
2 #define RUUVI_INTERFACE_SPI_H
4 #include "ruuvi_driver_error.h"
5 #include "ruuvi_interface_gpio.h"
6 #include <stdbool.h>
7 #include <stddef.h>
8 #include <stdint.h>
9 
25 #if RI_SPI_ENABLED
26 # define RUUVI_NRF5_SDK15_SPI_ENABLED RUUVI_NRF5_SDK15_ENABLED
27 #endif
28 
32 typedef enum
33 {
39 
43 typedef enum
44 {
50 
54 typedef struct
55 {
60  size_t ss_pins_number;
64 
75  const config);
76 
84 
95 
111 rd_status_t ri_spi_xfer_blocking (const uint8_t * const p_tx,
112  const size_t tx_len, uint8_t * const p_rx, const size_t rx_len);
113 /* @} */
114 #endif
uint32_t rd_status_t
bitfield for representing errors
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
uint16_t ri_gpio_id_t
port<<8 + pin
rd_status_t ri_spi_uninit()
Uninitialize SPI driver.
ri_spi_mode_t
@ RI_SPI_MODE_1
CPOL = 0, CPHA = 1.
@ RI_SPI_MODE_0
CPOL = 0, CPHA = 0.
@ RI_SPI_MODE_3
CPOL = 1, CPHA = 1.
@ RI_SPI_MODE_2
CPOL = 1, CPHA = 0.
ri_spi_frequency_t
@ RI_SPI_FREQUENCY_4M
4 Mbps
@ RI_SPI_FREQUENCY_2M
2 Mbps
@ RI_SPI_FREQUENCY_1M
1 Mbps
@ RI_SPI_FREQUENCY_8M
8 Mbps
rd_status_t ri_spi_xfer_blocking(const uint8_t *const p_tx, const size_t tx_len, uint8_t *const p_rx, const size_t rx_len)
SPI transfer function.
bool ri_spi_is_init()
check if SPI interface is already initialized.
rd_status_t ri_spi_init(const ri_spi_init_config_t *const config)
Initialize SPI driver with given settings.
ri_gpio_id_t * ss_pins
array of SPI pins, can be freed after function exits
ri_gpio_id_t sclk
pin number of SCLK
size_t ss_pins_number
sizeof ss_pins
ri_gpio_id_t miso
pin number of MISO
ri_spi_mode_t mode
Mode of SPI Bus, see ri_spi_mode_t.
ri_spi_frequency_t frequency
Frequency of SPI Bus, see ri_spi_frequency_t.
ri_gpio_id_t mosi
pin number of MOSI