summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-10-01 18:54:13 -0400
committerDan Halbert <halbert@halwitz.org>2018-10-01 18:54:13 -0400
commitaa95526428edb0196029587eb1b84fed544bbad8 (patch)
tree2bd12fe500541b713935589ba68ed4c35904ee3c
parentb263690e66c107d456b5a9493142f0f089456fed (diff)
nrf: remove error check for SPI baudrate too high; round to nearest baudrate
-rw-r--r--locale/circuitpython.pot20
-rw-r--r--locale/de_DE.po20
-rw-r--r--locale/en_US.po20
-rw-r--r--locale/es.po23
-rw-r--r--locale/fil.po20
-rw-r--r--locale/fr.po20
-rw-r--r--ports/nrf/common-hal/busio/SPI.c64
-rw-r--r--shared-bindings/busio/SPI.c13
8 files changed, 90 insertions, 110 deletions
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 513ec8efd..65f5caa75 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-09-21 12:23-0400\n"
+"POT-Creation-Date: 2018-10-01 18:52-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -361,7 +361,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/SPI.c:132
#: ports/atmel-samd/common-hal/busio/UART.c:119
#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45
-#: ports/nrf/common-hal/busio/I2C.c:77
+#: ports/nrf/common-hal/busio/I2C.c:81
msgid "Invalid pins"
msgstr ""
@@ -690,18 +690,14 @@ msgstr ""
msgid "AnalogOut functionality not supported"
msgstr ""
-#: ports/nrf/common-hal/busio/I2C.c:91
+#: ports/nrf/common-hal/busio/I2C.c:95
msgid "All I2C peripherals are in use"
msgstr ""
-#: ports/nrf/common-hal/busio/SPI.c:109
+#: ports/nrf/common-hal/busio/SPI.c:115
msgid "All SPI peripherals are in use"
msgstr ""
-#: ports/nrf/common-hal/busio/SPI.c:170
-msgid "Baud rate too high for this SPI peripheral"
-msgstr ""
-
#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
@@ -1990,19 +1986,19 @@ msgstr ""
msgid "Buffer must be at least length 1"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168
+#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:175
msgid "Invalid polarity"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172
+#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:179
msgid "Invalid phase"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176
+#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:183
msgid "Invalid number of bits"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341
+#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:348
msgid "buffer slices must be of equal length"
msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index 72f7b254d..43b7076d6 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-09-21 12:23-0400\n"
+"POT-Creation-Date: 2018-10-01 18:44-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Sebastian Plamauer\n"
"Language-Team: \n"
@@ -370,7 +370,7 @@ msgstr "Nicht genug Pins vorhanden"
#: ports/atmel-samd/common-hal/busio/SPI.c:132
#: ports/atmel-samd/common-hal/busio/UART.c:119
#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45
-#: ports/nrf/common-hal/busio/I2C.c:77
+#: ports/nrf/common-hal/busio/I2C.c:81
msgid "Invalid pins"
msgstr "Ungültige Pins"
@@ -699,20 +699,16 @@ msgstr ""
msgid "AnalogOut functionality not supported"
msgstr ""
-#: ports/nrf/common-hal/busio/I2C.c:91
+#: ports/nrf/common-hal/busio/I2C.c:95
#, fuzzy
msgid "All I2C peripherals are in use"
msgstr "Alle timer werden benutzt"
-#: ports/nrf/common-hal/busio/SPI.c:109
+#: ports/nrf/common-hal/busio/SPI.c:115
#, fuzzy
msgid "All SPI peripherals are in use"
msgstr "Alle timer werden benutzt"
-#: ports/nrf/common-hal/busio/SPI.c:170
-msgid "Baud rate too high for this SPI peripheral"
-msgstr ""
-
#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
@@ -2001,19 +1997,19 @@ msgstr ""
msgid "Buffer must be at least length 1"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168
+#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:175
msgid "Invalid polarity"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172
+#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:179
msgid "Invalid phase"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176
+#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:183
msgid "Invalid number of bits"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341
+#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:348
msgid "buffer slices must be of equal length"
msgstr ""
diff --git a/locale/en_US.po b/locale/en_US.po
index 63ae50ba5..fa60ee4fa 100644
--- a/locale/en_US.po
+++ b/locale/en_US.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-09-21 12:23-0400\n"
+"POT-Creation-Date: 2018-10-01 18:44-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -361,7 +361,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/SPI.c:132
#: ports/atmel-samd/common-hal/busio/UART.c:119
#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45
-#: ports/nrf/common-hal/busio/I2C.c:77
+#: ports/nrf/common-hal/busio/I2C.c:81
msgid "Invalid pins"
msgstr ""
@@ -690,18 +690,14 @@ msgstr ""
msgid "AnalogOut functionality not supported"
msgstr ""
-#: ports/nrf/common-hal/busio/I2C.c:91
+#: ports/nrf/common-hal/busio/I2C.c:95
msgid "All I2C peripherals are in use"
msgstr ""
-#: ports/nrf/common-hal/busio/SPI.c:109
+#: ports/nrf/common-hal/busio/SPI.c:115
msgid "All SPI peripherals are in use"
msgstr ""
-#: ports/nrf/common-hal/busio/SPI.c:170
-msgid "Baud rate too high for this SPI peripheral"
-msgstr ""
-
#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
@@ -1990,19 +1986,19 @@ msgstr ""
msgid "Buffer must be at least length 1"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168
+#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:175
msgid "Invalid polarity"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172
+#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:179
msgid "Invalid phase"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176
+#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:183
msgid "Invalid number of bits"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341
+#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:348
msgid "buffer slices must be of equal length"
msgstr ""
diff --git a/locale/es.po b/locale/es.po
index 5120c74f2..1fb4c9e3b 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-09-21 12:23-0400\n"
+"POT-Creation-Date: 2018-10-01 18:44-0400\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -376,7 +376,7 @@ msgstr "No hay suficientes pines disponibles"
#: ports/atmel-samd/common-hal/busio/SPI.c:132
#: ports/atmel-samd/common-hal/busio/UART.c:119
#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45
-#: ports/nrf/common-hal/busio/I2C.c:77
+#: ports/nrf/common-hal/busio/I2C.c:81
msgid "Invalid pins"
msgstr "pines inválidos"
@@ -620,7 +620,8 @@ msgstr "len debe de ser múltiple de 4"
#: ports/esp8266/modesp.c:274
#, c-format
msgid "memory allocation failed, allocating %u bytes for native code"
-msgstr "la asignación de memoria ha fallado, asignando %u bytes para código nativo"
+msgstr ""
+"la asignación de memoria ha fallado, asignando %u bytes para código nativo"
#: ports/esp8266/modesp.c:317
msgid "flash location must be below 1MByte"
@@ -706,18 +707,14 @@ msgstr "parámetro config desconocido"
msgid "AnalogOut functionality not supported"
msgstr ""
-#: ports/nrf/common-hal/busio/I2C.c:91
+#: ports/nrf/common-hal/busio/I2C.c:95
msgid "All I2C peripherals are in use"
msgstr "Todos los timers están siendo utilizados"
-#: ports/nrf/common-hal/busio/SPI.c:109
+#: ports/nrf/common-hal/busio/SPI.c:115
msgid "All SPI peripherals are in use"
msgstr "Todos los timers están siendo utilizados"
-#: ports/nrf/common-hal/busio/SPI.c:170
-msgid "Baud rate too high for this SPI peripheral"
-msgstr ""
-
#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
@@ -2033,19 +2030,19 @@ msgstr ""
msgid "Buffer must be at least length 1"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168
+#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:175
msgid "Invalid polarity"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172
+#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:179
msgid "Invalid phase"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176
+#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:183
msgid "Invalid number of bits"
msgstr ""
-#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341
+#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:348
msgid "buffer slices must be of equal length"
msgstr ""
diff --git a/locale/fil.po b/locale/fil.po
index ad6252a21..e41838757 100644
--- a/locale/fil.po
+++ b/locale/fil.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-09-21 12:23-0400\n"
+"POT-Creation-Date: 2018-10-01 18:44-0400\n"
"PO-Revision-Date: 2018-08-30 23:04-0700\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@@ -373,7 +373,7 @@ msgstr "Hindi sapat ang magagamit na pins"
#: ports/atmel-samd/common-hal/busio/SPI.c:132
#: ports/atmel-samd/common-hal/busio/UART.c:119
#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45
-#: ports/nrf/common-hal/busio/I2C.c:77
+#: ports/nrf/common-hal/busio/I2C.c:81
msgid "Invalid pins"
msgstr "Mali ang pins"
@@ -705,20 +705,16 @@ msgstr "hindi alam na config param"
msgid "AnalogOut functionality not supported"
msgstr "Hindi supportado ang AnalogOut"
-#: ports/nrf/common-hal/busio/I2C.c:91
+#: ports/nrf/common-hal/busio/I2C.c:95
#, fuzzy
msgid "All I2C peripherals are in use"
msgstr "Lahat ng timer ginagamit"
-#: ports/nrf/common-hal/busio/SPI.c:109
+#: ports/nrf/common-hal/busio/SPI.c:115
#, fuzzy
msgid "All SPI peripherals are in use"
msgstr "Lahat ng timer ginagamit"
-#: ports/nrf/common-hal/busio/SPI.c:170
-msgid "Baud rate too high for this SPI peripheral"
-msgstr ""
-
#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
@@ -2030,19 +2026,19 @@ msgstr "Function nangangailangan ng lock"
msgid "Buffer must be at least length 1"
msgstr "Buffer dapat ay hindi baba sa 1 na haba"
-#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168
+#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:175
msgid "Invalid polarity"
msgstr "Mali ang polarity"
-#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172
+#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:179
msgid "Invalid phase"
msgstr "Mali ang phase"
-#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176
+#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:183
msgid "Invalid number of bits"
msgstr "Mali ang bilang ng bits"
-#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341
+#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:348
msgid "buffer slices must be of equal length"
msgstr "aarehas na haba dapat ang buffer slices"
diff --git a/locale/fr.po b/locale/fr.po
index d6d7b6087..9fb6ef71c 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-09-21 12:23-0400\n"
+"POT-Creation-Date: 2018-10-01 18:52-0400\n"
"PO-Revision-Date: 2018-08-14 11:01+0200\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@@ -368,7 +368,7 @@ msgstr "Pas assez de broches disponibles"
#: ports/atmel-samd/common-hal/busio/SPI.c:132
#: ports/atmel-samd/common-hal/busio/UART.c:119
#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45
-#: ports/nrf/common-hal/busio/I2C.c:77
+#: ports/nrf/common-hal/busio/I2C.c:81
msgid "Invalid pins"
msgstr "Broche invalide"
@@ -701,20 +701,16 @@ msgstr "paramètre de config. inconnu"
msgid "AnalogOut functionality not supported"
msgstr "AnalogOut non supporté"
-#: ports/nrf/common-hal/busio/I2C.c:91
+#: ports/nrf/common-hal/busio/I2C.c:95
#, fuzzy
msgid "All I2C peripherals are in use"
msgstr "Tous les timers sont utilisés"
-#: ports/nrf/common-hal/busio/SPI.c:109
+#: ports/nrf/common-hal/busio/SPI.c:115
#, fuzzy
msgid "All SPI peripherals are in use"
msgstr "Tous les timers sont utilisés"
-#: ports/nrf/common-hal/busio/SPI.c:170
-msgid "Baud rate too high for this SPI peripheral"
-msgstr ""
-
#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
@@ -2021,19 +2017,19 @@ msgstr "La fonction nécessite un verrou"
msgid "Buffer must be at least length 1"
msgstr "Le tampon doit être de longueur au moins 1"
-#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168
+#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:175
msgid "Invalid polarity"
msgstr "Polarité invalide"
-#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172
+#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:179
msgid "Invalid phase"
msgstr "Phase invalide"
-#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176
+#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:183
msgid "Invalid number of bits"
msgstr "Nombre de bits invalide"
-#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341
+#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:348
msgid "buffer slices must be of equal length"
msgstr "les slices de tampon doivent être de longueurs égales"
diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c
index 54ae6e47c..8ff00d297 100644
--- a/ports/nrf/common-hal/busio/SPI.c
+++ b/ports/nrf/common-hal/busio/SPI.c
@@ -65,40 +65,40 @@ void spi_reset(void) {
}
}
-// Convert frequency to clock-speed-dependent value
+// Convert frequency to clock-speed-dependent value. Choose the nearest value, lower or higher.
static nrf_spim_frequency_t baudrate_to_spim_frequency(const uint32_t baudrate) {
- if (baudrate <= 125000) {
- return NRF_SPIM_FREQ_125K;
- }
- if (baudrate <= 250000) {
- return NRF_SPIM_FREQ_250K;
- }
- if (baudrate <= 500000) {
- return NRF_SPIM_FREQ_500K;
- }
- if (baudrate <= 1000000) {
- return NRF_SPIM_FREQ_1M;
- }
- if (baudrate <= 2000000) {
- return NRF_SPIM_FREQ_2M;
- }
- if (baudrate <= 4000000) {
- return NRF_SPIM_FREQ_4M;
- }
- if (baudrate <= 8000000) {
- return NRF_SPIM_FREQ_8M;
- }
-#ifdef SPIM_FREQUENCY_FREQUENCY_M16
- if (baudrate <= 16000000) {
- return NRF_SPIM_FREQ_16M;
- }
-#endif
+ // Round requested baudrate to nearest available baudrate.
+ static const struct {
+ const uint32_t boundary;
+ nrf_spim_frequency_t spim_frequency;
+ } baudrate_map[] = {
#ifdef SPIM_FREQUENCY_FREQUENCY_M32
- return NRF_SPIM_FREQ_32M;
-#else
- return NRF_SPIM_FREQ_8M;
+ { (16000000 + 32000000) / 2, NRF_SPIM_FREQ_32M },
+#endif
+#ifdef SPIM_FREQUENCY_FREQUENCY_M16
+ { ( 8000000 + 16000000) / 2, NRF_SPIM_FREQ_16M },
#endif
+ { ( 4000000 + 8000000) / 2, NRF_SPIM_FREQ_8M },
+ { ( 2000000 + 4000000) / 2, NRF_SPIM_FREQ_4M },
+ { ( 1000000 + 2000000) / 2, NRF_SPIM_FREQ_2M },
+ { ( 500000 + 1000000) / 2, NRF_SPIM_FREQ_1M },
+ { ( 250000 + 500000) / 2, NRF_SPIM_FREQ_500K },
+ { ( 125000 + 250000) / 2, NRF_SPIM_FREQ_250K },
+ { 0, NRF_SPIM_FREQ_125K },
+ };
+
+ size_t i = 0;
+ uint32_t boundary;
+ do {
+ boundary = baudrate_map[i].boundary;
+ if (baudrate >= boundary) {
+ return baudrate_map[i].spim_frequency;
+ }
+ i++;
+ } while (boundary != 0);
+ // Will get here only if baudrate == 0.
+ return 0;
}
void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * clock, const mcu_pin_obj_t * mosi, const mcu_pin_obj_t * miso) {
@@ -172,10 +172,6 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, uint32_t baudrate, ui
if (bits != 8)
return false;
- if (baudrate > self->spim_peripheral->max_frequency_MHz * 1000000) {
- mp_raise_ValueError(translate("Baud rate too high for this SPI peripheral"));
- return false;
- }
nrf_spim_frequency_set(self->spim_peripheral->spim.p_reg, baudrate_to_spim_frequency(baudrate));
nrf_spim_mode_t mode = NRF_SPIM_MODE_0;
diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c
index 7983a3a56..be5f431ec 100644
--- a/shared-bindings/busio/SPI.c
+++ b/shared-bindings/busio/SPI.c
@@ -141,14 +141,21 @@ static void check_lock(busio_spi_obj_t *self) {
//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower
//| due to the granularity of available clock settings.
//| Check the `frequency` attribute for the actual clock rate.
-//| **Note:** on the SAMD21, it is possible to set the baud rate to 24 MHz, but that
-//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is
-//| within spec for the SAMD21.
//| :param int polarity: the base state of the clock line (0 or 1)
//| :param int phase: the edge of the clock that data is captured. First (0)
//| or second (1). Rising or falling depends on clock polarity.
//| :param int bits: the number of bits per word
//|
+//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that
+//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is
+//| within spec for the SAMD21.
+//|
+//| .. note:: On the nRF52832, these baudrates are available: 125kHz, 250kHz, 1MHz, 2MHz, 4MHz,
+//| and 8MHz. On the nRF52840, 16MHz and 32MHz are also available, but only on the first
+//| `busio.SPI` object you create. Two more ``busio.SPI`` objects can be created, but they are restricted
+//| to 8MHz maximum. This is a hardware restriction: there is only one high-speed SPI peripheral.
+//| If you pick a a baudrate other than one of these, the nearest available
+//| baudrate will be chosen.
STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits };
static const mp_arg_t allowed_args[] = {