Prototype RF driver for STM Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo.
Prototype RF Driver for STM Sub-1 GHz RF Expansion Boards based on the SPSGRF-868 and SPSGRF-915 Modules for STM32 Nucleo
Currently supported boards:
Note, in order to use expansion board X-NUCLEO-IDS01A4 in mbed you need to perform the following HW modifications on the board:
- Unmount resistor
R4 - Mount resistor
R7
Furthermore, on some Nucleo development boards (e.g. the NUCLEO_F429ZI), in order to be able to use Ethernet together with these Sub-1 GHz RF expansion boards, you need to compile this driver with macro SPIRIT1_SPI_MOSI=PB_5 defined, while the development board typically requires some HW modification as e.g. described here!
This driver can be used together with the 6LoWPAN stack (a.k.a. Nanostack).
Diff: SimpleSpirit1.cpp
- Revision:
- 30:9c6dcfc47619
- Parent:
- 29:fe1b113f71d0
- Child:
- 31:a4d8072139f2
--- a/SimpleSpirit1.cpp Thu Nov 17 08:26:41 2016 +0100
+++ b/SimpleSpirit1.cpp Fri Nov 18 13:35:27 2016 +0100
@@ -63,7 +63,7 @@
/* init cube vars */
spirit_on = OFF;
last_rssi = 0 ; //MGR
- last_lqi = 0 ; //MGR
+ last_sqi = 0 ; //MGR
/* set frequencies */
radio_set_xtal_freq(XTAL_FREQUENCY);
@@ -153,7 +153,7 @@
};
csma_ca_init(&x_csma_init);
-#ifdef RX_FIFO_THR_WA
+#ifdef RX_FIFO_THR_AO_CSMA_WA
linear_fifo_set_almost_full_thr_rx(SPIRIT_MAX_FIFO_LEN-(MAX_PACKET_LEN+1));
#endif
@@ -189,8 +189,8 @@
pkt_basic_set_payload_length(payload_len); // set desired payload len
-#ifdef RX_FIFO_THR_WA
- // betzw - TODO: seems to be incompatible with TX FIFO usage (to be investigated)
+#ifdef RX_FIFO_THR_AO_CSMA_WA
+ // betzw - TODO: enabling CSMA/CA seems to be incompatible with TX FIFO usage (to be investigated)
csma_ca_state(S_ENABLE); // enable CSMA/CA
#endif
@@ -221,8 +221,8 @@
enable_spirit_irq();
BUSYWAIT_UNTIL(!_spirit_tx_started, STATE_TIMEOUT);
-#ifndef NDEBUG
- // debug("\n\r%s (%d): state=%x, _spirit_tx_started=%d\n\r", __func__, __LINE__, SPIRIT1_STATUS()>>1, _spirit_tx_started);
+#ifdef HEAVY_DEBUG
+ debug("\n\r%s (%d): state=%x, _spirit_tx_started=%d\n\r", __func__, __LINE__, SPIRIT1_STATUS()>>1, _spirit_tx_started);
#endif
csma_ca_state(S_DISABLE); // disable CSMA/CA
@@ -237,9 +237,15 @@
disable_spirit_irq();
+ _spirit_tx_started = false;
_is_receiving = false;
+ _spirit_rx_err = false;
stop_rx_timeout();
+ cmd_strobe(SPIRIT1_STROBE_FRX);
+ CLEAR_RXBUF();
+ CLEAR_TXBUF();
+
state = SPIRIT1_STATUS();
if(state == SPIRIT1_STATE_STANDBY) {
cmd_strobe(SPIRIT1_STROBE_READY);
@@ -283,12 +289,6 @@
spirit_on = OFF;
_nr_of_irq_disables = 1;
- _spirit_tx_started = false;
- _is_receiving = false;
- stop_rx_timeout();
-
- CLEAR_TXBUF();
- CLEAR_RXBUF();
}
return 0;
}
@@ -305,12 +305,6 @@
error("\n\rSpirit1: failed to enter rx (%x) => retry\n\r", last_state>>1);
}
- cmd_strobe(SPIRIT1_STROBE_FRX);
- CLEAR_RXBUF();
- _spirit_rx_err = false;
- _is_receiving = false;
- stop_rx_timeout();
-
/* Enables the mcu to get IRQ from the SPIRIT1 */
spirit_on = ON;
#ifndef NDEBUG
@@ -342,15 +336,10 @@
/* Checks if the RX buffer is empty */
if(IS_RXBUF_EMPTY()) {
- CLEAR_RXBUF();
set_ready_state();
- cmd_strobe(SPIRIT1_STROBE_FRX);
cmd_strobe(SPIRIT1_STROBE_RX);
BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_RX, STATE_TIMEOUT);
- _spirit_rx_err = false;
- _is_receiving = false;
- stop_rx_timeout();
enable_spirit_irq();
return 0;
}
@@ -368,8 +357,6 @@
memcpy(buf, spirit_rx_buf, spirit_rx_len);
bufsize = spirit_rx_len;
- _is_receiving = false;
- stop_rx_timeout();
CLEAR_RXBUF();
enable_spirit_irq();
@@ -430,10 +417,6 @@
error("\n\rSpirit1: (#2) failed to enter rx (%x) => retry\n\r", last_state>>1);
}
- CLEAR_RXBUF();
- _spirit_rx_err = false;
- _is_receiving = false;
- stop_rx_timeout();
enable_spirit_irq();
#ifndef NDEBUG
@@ -473,7 +456,6 @@
_is_receiving = false;
CLEAR_RXBUF();
cmd_strobe(SPIRIT1_STROBE_FRX);
- stop_rx_timeout();
if(_spirit_tx_started) {
_spirit_tx_started = false;
CLEAR_TXBUF();
@@ -527,7 +509,6 @@
_is_receiving = false;
cmd_strobe(SPIRIT1_STROBE_FRX);
CLEAR_RXBUF();
- stop_rx_timeout();
} else {
uint8_t fifo_available = linear_fifo_read_num_elements_rx_fifo();
unsigned int remaining = MAX_PACKET_LEN - _spirit_rx_pos;
@@ -536,7 +517,6 @@
_is_receiving = false;
CLEAR_RXBUF();
cmd_strobe(SPIRIT1_STROBE_FRX);
- stop_rx_timeout();
} else {
spi_read_linear_fifo(fifo_available, &spirit_rx_buf[_spirit_rx_pos]);
_spirit_rx_pos += fifo_available;
@@ -575,7 +555,7 @@
cmd_strobe(SPIRIT1_STROBE_FRX);
last_rssi = qi_get_rssi(); //MGR
- last_lqi = qi_get_lqi(); //MGR
+ last_sqi = qi_get_sqi(); //MGR
/* call user callback */
if(_current_irq_callback) {
X-NUCLEO-IDS01A4 Sub-1GHz RF Expansion Board