Open RTS
Full implementation of the Somfy RTS protocol
Loading...
Searching...
No Matches
spi_module.h
Go to the documentation of this file.
1#ifndef SPI_MODULE_H
2#define SPI_MODULE_H
3
4#include <stdint.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
22struct spi_module {
26 uint8_t cs_pin;
27
31 uint32_t clock;
32
36 uint8_t mode;
37
41 uint8_t read_mask;
42
46 uint8_t write_mask;
47
48 // The SPI transfer function to call (set by spi_module_init_*)
49 int (*transfer)(struct spi_module *spi, uint8_t *tx_buffer,
50 uint8_t *rx_buffer, uint8_t length);
51
52 // Internal user_data to store device handles, etc
53 union {
54 void *user_data_ptr;
55 int user_data_int;
56 };
57};
58
69uint8_t spi_read(struct spi_module *spi, uint8_t reg);
70
80void spi_write(struct spi_module *spi, uint8_t reg, uint8_t val);
81
92void spi_write_masked(struct spi_module *spi, uint8_t reg, uint8_t mask,
93 uint8_t val);
94
99#ifdef __cplusplus
100} // extern "C"
101#endif
102
103#endif // SPI_MODULE_H
Hardware abstraction layer for userland SPI drivers.
Definition spi_module.h:22
uint8_t mode
The SPI mode to use for transfers.
Definition spi_module.h:36
uint8_t cs_pin
The chip select pin for the target SPI device.
Definition spi_module.h:26
uint32_t clock
The SPI clock speed (in Hz) to use for transfers.
Definition spi_module.h:31
uint8_t write_mask
Bitmask to apply to the register address when we are writing.
Definition spi_module.h:46
uint8_t read_mask
Bitmask to apply to the register address when we are reading.
Definition spi_module.h:41