demo/include/posix/spi.h

38 lines
793 B
C
Raw Normal View History

2020-02-13 11:00:05 +00:00
#ifndef __SPI_H__
#define __SPI_H__
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
#include <linux/spi/spidev.h>
#include "driver.h"
int spi_open(const struct driver *drv);
int spi_close(const struct driver *drv);
int spi_read(const struct driver *drv, char *buffer, unsigned int len);
int spi_write(const struct driver *drv, const char *buffer, unsigned int len);
int spi_ioctl(const struct driver *drv, unsigned int cmd, unsigned int argc, va_list args);
struct spi {
const char * spi_device;
uint8_t mode;
uint8_t bits_per_word;
uint32_t speed;
int spi_file;
bool is_open;
};
static const struct driver_fp spi_fp = {
.open = spi_open,
.close = spi_close,
.read = spi_read,
.write = spi_write,
.ioctl = spi_ioctl,
};
#endif