Add nrf spi driver

This commit is contained in:
Thomas Klaehn
2020-03-29 12:12:42 +02:00
parent 3729c0e2c0
commit 437ba90bc2
4 changed files with 102 additions and 84 deletions

View File

@@ -4,6 +4,7 @@
#include "driver.h"
#include "gpio.h"
#include "spi.h"
// LED 1
const struct gpio nrf_led_1 = {
@@ -49,4 +50,15 @@ const struct driver led_4 = {
.dev = &nrf_led_4
};
const struct spi nrf_spi_0 = {
.sck_pin = 2,
.mosi_pin = 3,
.miso_pin = 4
};
const struct driver spi_0 = {
.name = "SPI0",
.fp = &spi_fp,
.dev = &nrf_spi_0
};
#endif

18
include/spi.h Normal file
View File

@@ -0,0 +1,18 @@
int spi_open(const struct driver *drv);
int spi_close(const struct driver *drv);
int spi_write(const struct driver *drv, const char *buffer, unsigned int len);
struct spi {
unsigned int sck_pin;
unsigned int mosi_pin;
unsigned int miso_pin;
};
static const struct driver_fp spi_fp = {
.open = spi_open,
.close = spi_close,
.read = NULL,
.write = spi_write,
.ioctl = NULL
};