tperale / sx127x Goto Github PK
View Code? Open in Web Editor NEW๐ก Radio driver for the Semtech SX127X LoRa transceiver working on contiki-ng operating system.
License: GNU Lesser General Public License v2.1
๐ก Radio driver for the Semtech SX127X LoRa transceiver working on contiki-ng operating system.
License: GNU Lesser General Public License v2.1
So far two methods are documented to know if there is an ongoing communication.
uint8_t status;
spi_read_register(__sx1272_dev.spi, REG_LR_MODEMSTAT, &status, 1);
if (status & (0x04 | 0x01)) {
sx1272_rx_internal_set(&__sx1272_dev, sx1272_rx_receiving);
}
if (sx1272_read_register(SX1272_DEV.spi, REG_LR_IRQFLAGS) & RFLR_IRQFLAGS_VALIDHEADER) {
SX1272_DEV.receiv_timestamp = RTIMER_NOW(); // - US_TO_RTIMERTICKS(439)
sx1272_write_register(SX1272_DEV.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_VALIDHEADER);
sx1272_rx_internal_set(&SX1272_DEV, sx1272_rx_receiving);
LOG_DBG("Receiving packet\n");
}
I only managed to make the second one work. I should try to implement the first one and study which one detect an incoming packet faster to reduce the time the radio must spend listening for incoming messages.
Some MAC protocol available in Contiki will use the packetbuf
directly in continuous listening mode, instead of passing the buffer as argument of sx1272_read_packet
.
Busywaiting for an interrupt on the pin DI0,DI1,DI2,DI3 introduce some delay in the software. As we can see in the next picture, the time between the interrupt and the acknowledgement from the software can almost reach 1ms.
If we assign some pins from the RE-MOTE to handle the interrupts we could process the pending packet more quickly.
So far only two pins are used by the driver.
The following code could be used to process the interrupt on those two pins.
static void sx1272_interrupt_dio0() {
if (__sx1272_dev.mode == sx1272_mode_receiver
|| __sx1272_dev.mode == sx1272_mode_receiver_single) {
SX1272_DEV.rx_timestamp = RTIMER_NOW();
sx1272_rx_internal_set(&__sx1272_dev, sx1272_rx_received);
sx1272_write_register(__sx1272_dev.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_RXDONE);
} else if (__sx1272_dev.mode == sx1272_mode_transmitter) {
sx1272_write_register(__sx1272_dev.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_TXDONE);
sx127x_set_opmode(&SX1272_DEV, sx1272_mode_standby);
}
}
static void sx1272_interrupt_dio1() {
sx1272_write_register(__sx1272_dev.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_RXTIMEOUT);
}
static void sx1272_interrupt_dio3() {
if (__sx1272_dev.mode == sx1272_mode_receiver
|| __sx1272_dev.mode == sx1272_mode_receiver_single) {
SX1272_DEV.receiv_timestamp = RTIMER_NOW();
sx1272_rx_internal_set(&__sx1272_dev, sx1272_rx_receiving);
sx1272_write_register(__sx1272_dev.spi, REG_LR_IRQFLAGS, RFLR_IRQFLAGS_VALIDHEADER);
}
}
Line 207 in b74c17f
During the transmition of a packet instead of just checking for the interrupt when it's done also use a timer to avoid infinite loop.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.