summaryrefslogtreecommitdiff
path: root/code/fe310/eos/spi.h
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-01-16 23:43:07 +0100
committerUros Majstorovic <majstor@majstor.org>2018-01-16 23:43:07 +0100
commit01c3e3af2394f863323b846fa304ff7e0a30e9df (patch)
tree84b499e6ece88e637ed86bbdd87333613e2433c5 /code/fe310/eos/spi.h
parent0d0e9facfcea3cf96da3b63285865182fdd5477e (diff)
eos support
Diffstat (limited to 'code/fe310/eos/spi.h')
-rw-r--r--code/fe310/eos/spi.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/code/fe310/eos/spi.h b/code/fe310/eos/spi.h
new file mode 100644
index 0000000..88e54bb
--- /dev/null
+++ b/code/fe310/eos/spi.h
@@ -0,0 +1,32 @@
+#include <stdint.h>
+
+#include "encoding.h"
+#include "platform.h"
+
+#define SPI_MODE0 0x00
+#define SPI_MODE1 0x01
+#define SPI_MODE2 0x02
+#define SPI_MODE3 0x03
+
+#define SPI_SIZE_BUF 1500
+#define SPI_SIZE_CHUNK 4
+#define SPI_SIZE_BUFQ 4
+#define SPI_GPIO_CTS_OFFSET PIN_2_OFFSET
+#define SPI_GPIO_RTS_OFFSET PIN_3_OFFSET
+#define SPI_IOF_MASK (((uint32_t)1 << IOF_SPI1_SCK) | ((uint32_t)1 << IOF_SPI1_MOSI) | ((uint32_t)1 << IOF_SPI1_MISO))
+
+typedef struct SPIBuffer {
+ unsigned char cmd;
+ unsigned char *buffer;
+ uint16_t len;
+ uint16_t len_rx;
+ uint16_t idx_tx;
+ uint16_t idx_rx;
+} SPIBuffer;
+
+typedef struct SPIBufQ {
+ uint8_t idx_r;
+ uint8_t idx_w;
+ unsigned char *array[SPI_SIZE_BUFQ];
+} SPIBufQ;
+