kopia lustrzana https://github.com/meshtastic/firmware
move SPI init into main
rodzic
e9ca7792eb
commit
48c045a253
16
src/main.cpp
16
src/main.cpp
|
@ -118,8 +118,10 @@ static uint32_t ledBlinker()
|
||||||
|
|
||||||
Periodic ledPeriodic(ledBlinker);
|
Periodic ledPeriodic(ledBlinker);
|
||||||
|
|
||||||
#ifdef NO_ESP32
|
#include "RF95Interface.h"
|
||||||
#include "SX1262Interface.h"
|
#include "SX1262Interface.h"
|
||||||
|
|
||||||
|
#ifdef NO_ESP32
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -199,10 +201,20 @@ void setup()
|
||||||
digitalWrite(SX1262_ANT_SW, 1);
|
digitalWrite(SX1262_ANT_SW, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Init our SPI controller
|
||||||
|
#ifdef NRF52_SERIES
|
||||||
|
SPI.begin();
|
||||||
|
#else
|
||||||
|
// ESP32
|
||||||
|
SPI.begin(SCK_GPIO, MISO_GPIO, MOSI_GPIO, NSS_GPIO);
|
||||||
|
SPI.setFrequency(4000000);
|
||||||
|
#endif
|
||||||
|
|
||||||
// MUST BE AFTER service.init, so we have our radio config settings (from nodedb init)
|
// MUST BE AFTER service.init, so we have our radio config settings (from nodedb init)
|
||||||
RadioInterface *rIf =
|
RadioInterface *rIf =
|
||||||
#if defined(RF95_IRQ_GPIO)
|
#if defined(RF95_IRQ_GPIO)
|
||||||
new CustomRF95();
|
// new CustomRF95(); old Radiohead based driver
|
||||||
|
new RF95Interface(NSS_GPIO, RF95_IRQ_GPIO, RESET_GPIO, SPI);
|
||||||
#elif defined(SX1262_CS)
|
#elif defined(SX1262_CS)
|
||||||
new SX1262Interface(SX1262_CS, SX1262_DIO1, SX1262_RESET, SX1262_BUSY, SPI);
|
new SX1262Interface(SX1262_CS, SX1262_DIO1, SX1262_RESET, SX1262_BUSY, SPI);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -14,9 +14,6 @@ RF95Interface::RF95Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOL
|
||||||
/// \return true if initialisation succeeded.
|
/// \return true if initialisation succeeded.
|
||||||
bool RF95Interface::init()
|
bool RF95Interface::init()
|
||||||
{
|
{
|
||||||
// FIXME, move this to main
|
|
||||||
SPI.begin();
|
|
||||||
|
|
||||||
applyModemConfig();
|
applyModemConfig();
|
||||||
if (power > 20) // This chip has lower power limits than some
|
if (power > 20) // This chip has lower power limits than some
|
||||||
power = 20;
|
power = 20;
|
||||||
|
@ -46,6 +43,11 @@ bool RF95Interface::init()
|
||||||
return res == ERR_NONE;
|
return res == ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INTERRUPT_ATTR RF95Interface::disableInterrupt()
|
||||||
|
{
|
||||||
|
lora->clearDio0Action();
|
||||||
|
}
|
||||||
|
|
||||||
bool RF95Interface::reconfigure()
|
bool RF95Interface::reconfigure()
|
||||||
{
|
{
|
||||||
applyModemConfig();
|
applyModemConfig();
|
||||||
|
|
|
@ -30,7 +30,7 @@ class RF95Interface : public RadioLibInterface
|
||||||
/**
|
/**
|
||||||
* Glue functions called from ISR land
|
* Glue functions called from ISR land
|
||||||
*/
|
*/
|
||||||
virtual void INTERRUPT_ATTR disableInterrupt() { lora->clearDio0Action(); }
|
virtual void disableInterrupt();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable a particular ISR callback glue function
|
* Enable a particular ISR callback glue function
|
||||||
|
|
|
@ -12,9 +12,6 @@ SX1262Interface::SX1262Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RA
|
||||||
/// \return true if initialisation succeeded.
|
/// \return true if initialisation succeeded.
|
||||||
bool SX1262Interface::init()
|
bool SX1262Interface::init()
|
||||||
{
|
{
|
||||||
// FIXME, move this to main
|
|
||||||
SPI.begin();
|
|
||||||
|
|
||||||
float tcxoVoltage = 0; // None - we use an XTAL
|
float tcxoVoltage = 0; // None - we use an XTAL
|
||||||
bool useRegulatorLDO = false; // Seems to depend on the connection to pin 9/DCC_SW - if an inductor DCDC?
|
bool useRegulatorLDO = false; // Seems to depend on the connection to pin 9/DCC_SW - if an inductor DCDC?
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue