Add nrf spi driver
This commit is contained in:
@@ -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
18
include/spi.h
Normal 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
|
||||
};
|
Reference in New Issue
Block a user