Ke Ao Teensy Flight Software
The software on the Teensy in the Ke Ao cubesat.
Loading...
Searching...
No Matches
Artemis::Devices::RFM98 Class Reference

The satellite's RFM98 radio. More...

#include <rfm98.h>

Classes

struct  rfm98_config
 The RFM98 configuration structure. More...
 

Public Member Functions

 RFM98 (uint8_t slaveSelectPin, uint8_t interruptPin, RHGenericSPI &spi=hardware_spi1)
 Construct a new RFM98::RFM98 object.
 
int32_t reset ()
 Resets the RFM98 radio.
 
int32_t init (rfm98_config cfg, Threads::Mutex *mtx)
 Initialization of the RFM98 radio.
 
int32_t send (PacketComm &packet)
 Transmit a packet using the RFM98 radio.
 
int32_t recv (PacketComm &packet, uint16_t timeout)
 Receive a packet using the RFM98 radio.
 

Detailed Description

The satellite's RFM98 radio.

Constructor & Destructor Documentation

◆ RFM98()

Artemis::Devices::RFM98::RFM98 ( uint8_t  slaveSelectPin,
uint8_t  interruptPin,
RHGenericSPI &  spi = hardware_spi1 
)

Construct a new RFM98::RFM98 object.

Parameters
slaveSelectPinThe chip/slave select pin connecting the Teensy and RFM98 radio.
interruptPinThe interrupt pin connecting the Teensy and RFM98 radio.
spiThe SPI connection connecting the Teensy and RFM98 radio.

This constructor passes the external parameters to the internal RFM98 object stored in the RFM98 class.

Member Function Documentation

◆ init()

int32_t Artemis::Devices::RFM98::init ( rfm98_config  cfg,
Threads::Mutex *  mtx 
)

Initialization of the RFM98 radio.

Parameters
cfgA rfm98_config struct, containing the configuration settings for the radio.
mtxThe mutex used to lock the SPI interface for the RFM98 channel.
Returns
int32_t Returns 0 if successful, -1 if unsuccessful.

The passed-in parameters are copied over to the internal private variables in the RFM98 class.

The SPI interface is locked for the exclusive use by the RFM98 channel. The SPI1 interface is then configured to use the pins defined in the passed-in (now local) configuration struct.

The reset pin is defined, and set to low (reset). The reset() function is then called to enable the RFM98.

The internal RFM98 class is initialized using the RadioHead initialization code. If, after 10 seconds, initialization does not complete, print an error message to the Teensy's serial console and return -1.

Configure the internal RFM98 class with the configuration struct passed in earlier.

Print a success message to the Teensy's serial console, and put the RFM98 into sleep mode.

◆ recv()

int32_t Artemis::Devices::RFM98::recv ( PacketComm &  packet,
uint16_t  timeout 
)

Receive a packet using the RFM98 radio.

Parameters
packetA pointer to the PacketComm packet that will hold the receieved data.
timeoutThe maximum time to wait for a packet to be received, in milliseconds.
Returns
int32_t If successful, the size of the received packet. If unsuccessful, returns -1.

The SPI interface is locked for the exclusive use by the RFM98 channel. If a packet is received within the specified timeout, it is copied to the PacketComm packet. The packet is then unwrapped into a header and payload. The radio is then returned to idle mode.

◆ reset()

int32_t Artemis::Devices::RFM98::reset ( )

Resets the RFM98 radio.

Returns
int32_t Always returns 0.

◆ send()

int32_t Artemis::Devices::RFM98::send ( PacketComm &  packet)

Transmit a packet using the RFM98 radio.

Parameters
packetA pointer to the PacketComm packet to be transmitted.
Returns
int32_t Returns 0 if successful, -1 if unsuccessful.

The header and payload of the packet are merged into one.

The SPI interface is locked for the exclusive use by the RFM98 channel. The packet is then sent using the RadioHead library call. The RFM98 is then put into sleep mode, and the sent packet is printed to the Teensy's serial console.


The documentation for this class was generated from the following files: