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).
Revision 73:a1342eb7974c, committed 2017-07-21
- Comitter:
- Wolfgang Betz
- Date:
- Fri Jul 21 15:18:37 2017 +0200
- Parent:
- 72:413cb97ac077
- Child:
- 74:7672516efa2a
- Commit message:
- Comment also main class
Changed in this revision
| stm-spirit1-rf-driver/SimpleSpirit1.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/stm-spirit1-rf-driver/SimpleSpirit1.h Fri Jul 21 13:54:39 2017 +0200
+++ b/stm-spirit1-rf-driver/SimpleSpirit1.h Fri Jul 21 15:18:37 2017 +0200
@@ -58,6 +58,43 @@
/*** A Simple Spirit1 Class ***/
// NOTE: must be a singleton (due to mix of MBED/CUBE code)!!!
// NOTE: implementation is IRQ-save but (intentionally) NOT thread-safe!!!
+/** Simple Spirit1 Class
+ *
+ * @Note Synchronization level: implementation is IRQ-save but (intentionally) NOT thread-safe!!!
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ * #include "SimpleSpirit1.h"
+ *
+ * static char *send_buf = "Hello World!";
+ *
+ * static SimpleSpirit1 &myspirit = SimpleSpirit1::CreateInstance(D11, D12, D3, D9, D10, D2);
+ *
+ * static volatile bool tx_done_flag = false;
+ *
+ * static void callback_func(int event)
+ * {
+ * if (event == SimpleSpirit1::TX_DONE) {
+ * tx_done_flag = true;
+ * }
+ * }
+ *
+ * int main()
+ * {
+ * myspirit.on();
+ *
+ * while(1)
+ * {
+ * size_t curr_len = strlen((const char*)send_buf);
+ * myspirit.send(send_buf, curr_len);
+ *
+ * while(!tx_done_flag);
+ * tx_done_flag = false;
+ * }
+ * }
+ * @endcode
+ */
class SimpleSpirit1 {
protected:
static SimpleSpirit1 *_singleton;
@@ -388,7 +425,6 @@
* @param sdn 'PinName' of pin to use for device shutdown
*
* @returns reference to singleton instance
- *
*/
static SimpleSpirit1& CreateInstance(PinName mosi, PinName miso, PinName sclk,
PinName irq, PinName cs, PinName sdn,
@@ -415,7 +451,6 @@
* @param sdn 'PinName' of pin to use for device shutdown
*
* @returns reference to singleton instance
- *
*/
static SimpleSpirit1& Instance() {
if(_singleton == NULL) {
@@ -432,18 +467,15 @@
* @note Function 'func' will be executed in interrupt context!
* @note Function 'func' will be call with either 'RX_DONE', 'TX_DONE', or 'TX_ERR' as parameter
* to indicate which event has occurred.
- *
*/
void attach_irq_callback(Callback<void(int)> func) {
_current_irq_callback = func;
}
/** Switch Radio On
- *
*/
int on(void);
/** Switch Radio Off
- *
*/
int off(void);
@@ -462,7 +494,6 @@
* @returns zero in case of success, non-zero error code otherwise
*
* @note the maximum payload size in bytes allowed is defined by macro 'SPIRIT1_MAX_PAYLOAD'
- *
*/
int send(const void *payload, unsigned int payload_len, bool use_csma_ca = true);
@@ -474,31 +505,26 @@
* @returns number of bytes copied into the buffer
*
* @note the buffer should be (at least) of size 'SPIRIT1_MAX_PAYLOAD' (in bytes).
- *
*/
int read(void *buf, unsigned int bufsize);
/** Perform a Clear-Channel Assessment (CCA) to find out if there is a packet in the air or not.
*
* @returns 1 if packet has been seen.
- *
*/
int channel_clear(void);
/** Check if the radio driver has just received a packet
- *
*/
int get_pending_packet(void);
/** Is radio currently receiving
- *
*/
bool is_receiving(void) {
return _is_receiving;
}
/** Get latest value of RSSI (in dBm)
- *
*/
float get_last_rssi_dbm(void) {
get_last_rssi_raw();
@@ -506,7 +532,6 @@
}
/** Get latest value of RSSI (as Spirit1 raw value)
- *
*/
uint8_t get_last_rssi_raw(void) {
if(last_rssi == 0) {
@@ -516,7 +541,6 @@
}
/** Get latest value of LQI (scaled to 8-bit)
- *
*/
uint8_t get_last_sqi(void) {
const uint8_t max_sqi = 8 * ((SYNC_LENGTH>>1)+1);
@@ -529,7 +553,6 @@
}
/** Reset Board
- *
*/
void reset_board() {
init();
X-NUCLEO-IDS01A4 Sub-1GHz RF Expansion Board