Crate embedded_lora_rfm95

Crate embedded_lora_rfm95 

Source
Expand description

License BSD-2-Clause License MIT AppVeyor CI docs.rs crates.io Download numbers dependency status

§embedded-lora-rfm95

A no-std-compatible, opinionated driver for the RFM95 LoRa modem. It only supports the LoRa mode, and has only been tested with the EU 868 MHz ISM bands for now.

§Features

The crate supports the following optional cargo features:

§fugit (disabled by default)

The fugit-feature implements simple From/Into-conversions between the built-in frequency type and fugit’s HertzU32 type. This is a comfort-feature only, and does not enable additional functionality.

§backtrace (disabled by default)

The backtrace-feature can be used to get more verbose errors. If this feature is enabled, errors will contain a human readable description as well as file and line information about where the error occurred. This is useful for debugging or better logging, but can be disabled if library size matters.

§debug (disabled by default)

The debug feature enables some debug functionality, namely an SPI debug callback which can be used to log all SPI transactions with the RFM95 modem, and provides some helper functions to dump the register state and FIFO contents. The debug feature also disables the modem silicon revision check.

To use this feature, you MUST implement this extern callback function in your crate (otherwise you’ll get a cryptic linker error):

extern "Rust" {
    /// A debug callback that is called for every SPI transaction
    /// 
    /// # About
    /// This function is called for every SPI transaction, where `operation` is the operation type (`0x00` for read,
    /// `0x80` for replace), `address` is the register address, and `input` and `output` are the values written and read
    /// respectively.
    fn embeddedrfm95_spidebug_AwiUzTRu(operation: u8, address: u8, input: u8, output: u8);
}

Example implementation:

/// The debug callback implementation for `embedded-rfm95`
#[no_mangle]
pub extern "Rust" fn embeddedrfm95_spidebug_AwiUzTRu(operation: u8, address: u8, input: u8, output: u8) {
    // Print the transaction to stdout
    println!("[SPI 0x{operation:02X} @[0x{address:02X}] tx:0x{input:02X} rx:0x{output:02X}");
}

Modules§

error
The crate’s error types
lora
LoRa specific configuration
rfm95
RFM95 LoRa implementation

Macros§

err
Creates an error