summaryrefslogtreecommitdiff
path: root/code/fe310/eos/spi_dev.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-02-26 13:38:40 +0100
committerUros Majstorovic <majstor@majstor.org>2020-02-26 13:38:40 +0100
commit819f823ec215d5c9f4ae6c3d05cd9048e22703b7 (patch)
tree5dba42761e0ab607ce6c00788ba002bcb562a2f2 /code/fe310/eos/spi_dev.c
parent4d45c548bfaf27bd2135384b3ffd0c4bdb41521c (diff)
spidev set divider
Diffstat (limited to 'code/fe310/eos/spi_dev.c')
-rw-r--r--code/fe310/eos/spi_dev.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/code/fe310/eos/spi_dev.c b/code/fe310/eos/spi_dev.c
index dd956f3..aed26bc 100644
--- a/code/fe310/eos/spi_dev.c
+++ b/code/fe310/eos/spi_dev.c
@@ -20,17 +20,19 @@
#define SPI_CSPIN_CAM 23
+static uint16_t spi_dev_div[EOS_DEV_MAX_DEV];
+
void eos_spi_dev_start(unsigned char dev) {
eos_net_stop();
switch (dev) {
case EOS_DEV_DISP:
- eos_spi_start(dev, SPI_DIV_DISP, SPI_CSID_DISP, 0);
+ eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_DISP, 0);
break;
case EOS_DEV_CARD:
- eos_spi_start(dev, SPI_DIV_CARD, SPI_CSID_CARD, 0);
+ eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_CARD, 0);
break;
case EOS_DEV_CAM:
- eos_spi_start(dev, SPI_DIV_CAM, SPI_CSID_NONE, SPI_CSPIN_CAM);
+ eos_spi_start(dev, spi_dev_div[dev-1], SPI_CSID_NONE, SPI_CSPIN_CAM);
break;
}
}
@@ -41,6 +43,10 @@ void eos_spi_dev_stop(void) {
}
void eos_spi_dev_init(void) {
+ spi_dev_div[EOS_DEV_DISP - 1] = SPI_DIV_DISP;
+ spi_dev_div[EOS_DEV_CARD - 1] = SPI_DIV_CARD;
+ spi_dev_div[EOS_DEV_CAM - 1] = SPI_DIV_CAM;
+
GPIO_REG(GPIO_INPUT_EN) &= ~(1 << SPI_CSPIN_CAM);
GPIO_REG(GPIO_OUTPUT_EN) |= (1 << SPI_CSPIN_CAM);
GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << SPI_CSPIN_CAM);
@@ -48,3 +54,6 @@ void eos_spi_dev_init(void) {
GPIO_REG(GPIO_OUTPUT_VAL) |= (1 << SPI_CSPIN_CAM);
}
+void eos_spi_dev_set_div(unsigned char dev, uint16_t div) {
+ spi_dev_div[dev-1] = div;
+}