From cf9043aed86d6b7f8580363bbf9e55189d2b9597 Mon Sep 17 00:00:00 2001 From: Tom Knot Date: Thu, 5 Apr 2018 16:04:50 +0200 Subject: [PATCH] Allowed overriding frequency settings with _lower_ frequency even for analog modules, and reduced maximum frequency to 7.5Mhz --- modules/unipi/src/unipi_common.h | 2 +- modules/unipi/src/unipi_spi.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/unipi/src/unipi_common.h b/modules/unipi/src/unipi_common.h index 1b27daa..eb560e6 100644 --- a/modules/unipi/src/unipi_common.h +++ b/modules/unipi/src/unipi_common.h @@ -59,7 +59,7 @@ #define NEURONSPI_B_PER_WORD 8 #define NEURONSPI_DEFAULT_FREQ 600000 #define NEURONSPI_COMMON_FREQ 12000000 -#define NEURONSPI_SLOWER_FREQ 8000000 +#define NEURONSPI_SLOWER_FREQ 7500000 #define NEURONSPI_MAX_TX 62 #define NEURONSPI_MAX_BAUD 115200 #define NEURONSPI_FIFO_SIZE 256 diff --git a/modules/unipi/src/unipi_spi.c b/modules/unipi/src/unipi_spi.c index e9f3490..14ed557 100644 --- a/modules/unipi/src/unipi_spi.c +++ b/modules/unipi/src/unipi_spi.c @@ -139,9 +139,6 @@ ssize_t neuronspi_read (struct file *file_p, char *buffer, size_t len, loff_t *o if (driver_data == NULL) return -2; if (driver_data->spi_driver == NULL) return -2; // Invalid private data if (driver_data->first_probe_reply[0] == 0) return -3; // No device present - if (driver_data->slower_model) { - frequency = NEURONSPI_SLOWER_FREQ; - } mutex_lock(&(private_data->lock)); if (private_data->recv_buf == NULL) { mutex_unlock(&(private_data->lock)); @@ -231,7 +228,7 @@ ssize_t neuronspi_write (struct file *file_p, const char *buffer, size_t len, lo } else if (driver_data->reserved_device) { return -5; // Device reserved } - if (driver_data->slower_model) { + if (driver_data->slower_model && frequency > NEURONSPI_SLOWER_FREQ) { frequency = NEURONSPI_SLOWER_FREQ; } #else -- 2.34.1