J_Ch
September 15, 2016, 1:47pm
1
Hi there,
I’ve got a number of your automona boards that I’m try to get working with lora (the libelium that uses the SX1272 rather than LoRaWan) and Pham’s code (https://github.com/CongducPham/LowCostLoRaGw/blob/master/Arduino/libraries/SX1272/SX1272.cpp ).
There seem to be issues around the EPPROM library and the LowPower Rocket Stream library. I understand that low power library is not for this type of chip, is there any alternative library that I can use?
Thanks so much,
Joel
The Lowpower Rocket Stream library is restricted to the SAMD21A18A and the Sodaq Autonomo uses the SAMD21J18A. We have been talking about it here .
The code to run could be: (Don’t forget to put a startup delay in your sketch)
Deepsleep.h:
#include <Arduino.h>
#include <SPI.h>
void DeepSleep();
void DFlashUltraDeepSleep();
void transmit(uint8_t);
void resetSPIPins();
void resetPin(uint8_t);
Deepsleep.cpp
#include "DeepSleep.h"
void DeepSleep() {
// Set sleep mode
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
//Disable USB
USB->DEVICE.CTRLA.reg &= ~USB_CTRLA_ENABLE;
DFlashUltraDeepSleep();
//Enter sleep mode
__DSB();
__WFI();
}
void DFlashUltraDeepSleep()
{
// SPI initialisation
SPI.begin();
// Initialise the CS pin for the data flash
pinMode(SS_DFLASH, OUTPUT);
digitalWrite(SS_DFLASH, HIGH);
transmit(0x00); // In case already in sleep, wake
transmit(0x79); // Now enter sleep
// SPI end
SPI.end();
// Resets the pins used
resetSPIPins();
}
void transmit(uint8_t val)
{
SPISettings settings;
SPI.beginTransaction(settings);
digitalWrite(SS_DFLASH, LOW);
SPI.transfer(val);
digitalWrite(SS_DFLASH, HIGH);
SPI.endTransaction();
delayMicroseconds(1000);
}
void resetSPIPins()
{
resetPin(MISO);
resetPin(MOSI);
resetPin(SCK);
resetPin(SS_DFLASH);
}
void resetPin(uint8_t pin)
{
PORT->Group[g_APinDescription[pin].ulPort].PINCFG[g_APinDescription[pin].ulPin].reg = (uint8_t)(0);
PORT->Group[g_APinDescription[pin].ulPort].DIRCLR.reg = (uint32_t)(1 << g_APinDescription[pin].ulPin);
PORT->Group[g_APinDescription[pin].ulPort].OUTCLR.reg = (uint32_t) (1 << g_APinDescription[pin].ulPin);
}