diff --git a/API.md b/API.md index 739ade2..d1f5789 100644 --- a/API.md +++ b/API.md @@ -32,6 +32,17 @@ LoRa.setPins(ss, reset, dio0); This call is optional and only needs to be used if you need to change the default pins used. +### Set SPI Frequency + +Override the default SPI frequency of 10 MHz used by the library. **Must** be called before `LoRa.begin()`. + +```arduino +LoRa.setSPIFrequency(frequency); +``` + * `frequency` - new SPI frequency to use, defaults to `10E6` + +This call is optional and only needs to be used if you need to change the default SPI frequency used. Some logic level converters cannot support high speeds such as 10 MHz, so a lower SPI frequency can be selected with `LoRa.setSPIFrequency(frequency)`. + ### End Stop the library diff --git a/keywords.txt b/keywords.txt index 93c5562..0ef2c76 100644 --- a/keywords.txt +++ b/keywords.txt @@ -46,6 +46,7 @@ noCrc KEYWORD2 random KEYWORD2 setPins KEYWORD2 +setSPIFrequency KEYWORD2 dumpRegisters KEYWORD2 ####################################### diff --git a/src/LoRa.cpp b/src/LoRa.cpp index e792917..260917d 100644 --- a/src/LoRa.cpp +++ b/src/LoRa.cpp @@ -413,6 +413,11 @@ void LoRaClass::setPins(int ss, int reset, int dio0) _dio0 = dio0; } +void LoRaClass::setSPIFrequency(uint32_t frequency) +{ + _spiSettings = SPISettings(frequency, MSBFIRST, SPI_MODE0); +} + void LoRaClass::dumpRegisters(Stream& out) { for (int i = 0; i < 128; i++) { diff --git a/src/LoRa.h b/src/LoRa.h index 849cf0f..e8b551e 100644 --- a/src/LoRa.h +++ b/src/LoRa.h @@ -51,6 +51,7 @@ public: byte random(); void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); + void setSPIFrequency(uint32_t frequency); void dumpRegisters(Stream& out);