33#include <linux/spi/spidev.h>
46#pragma GCC diagnostic push
47#pragma GCC diagnostic ignored "-Wcast-qual"
66 memcpy(tx_buf, (
void *)
t->output_buf,
t->output_length);
69 xfer.tx_buf = (
unsigned long)
t->output_buf;
75 xfer.rx_buf = (
unsigned long)
t->input_buf;
83 xfer.bits_per_word = 16;
85 xfer.bits_per_word = 8;
98 memcpy((
void *)
t->input_buf, rx_buf,
t->input_length);
104#pragma GCC diagnostic pop
122#define SPI0_MODE (SPI_CPOL | SPI_CPHA)
125#ifndef SPI0_LSB_FIRST
126#define SPI0_LSB_FIRST 0
129#ifndef SPI0_BITS_PER_WORD
130#define SPI0_BITS_PER_WORD 8
133#ifndef SPI0_MAX_SPEED_HZ
134#define SPI0_MAX_SPEED_HZ 1000000
142 perror(
"Could not open SPI device /dev/spidev1.0");
151 perror(
"SPI0: can't set spi mode");
157 perror(
"SPI0: can't set spi bit justification");
163 perror(
"SPI0: can't set bits per word");
169 perror(
"SPI0: can't set max speed hz");
178#define SPI1_MODE (SPI_CPOL | SPI_CPHA)
181#ifndef SPI1_LSB_FIRST
182#define SPI1_LSB_FIRST 0
185#ifndef SPI1_BITS_PER_WORD
186#define SPI1_BITS_PER_WORD 8
189#ifndef SPI1_MAX_SPEED_HZ
190#define SPI1_MAX_SPEED_HZ 1000000
198 perror(
"Could not open SPI device /dev/spidev1.1");
202 spi1.reg_addr = (
void *)
fd;
207 perror(
"SPI1: can't set spi mode");
213 perror(
"SPI1: can't set spi bit justification");
219 perror(
"SPI1: can't set bits per word");
225 perror(
"SPI1: can't set max speed hz");
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
bool spi_lock(struct spi_periph *p, uint8_t slave)
spi_lock() function
void spi1_arch_init(void)
Architecture dependent SPI1 initialization.
void spi0_arch_init(void)
Architecture dependent SPI0 initialization.
process_rx_dma_interrupt & spi1
receive transferred over DMA
bool spi_resume(struct spi_periph *p, uint8_t slave)
spi_resume() function
void spi_init_slaves(void)
spi_init_slaves() function
@ SPISelectUnselect
slave is selected before transaction and unselected after
@ SPIUnselect
slave is not selected but unselected after transaction
SPI peripheral structure.
SPI transaction structure.
#define SPI1_BITS_PER_WORD
#define SPI1_MAX_SPEED_HZ
#define SPI0_MAX_SPEED_HZ
#define SPI0_BITS_PER_WORD
Architecture independent SPI (Serial Peripheral Interface) API.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.