Ke Ao Teensy Flight Software
The software on the Teensy in the Ke Ao cubesat.
|
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. | |
The satellite's RFM98 radio.
Artemis::Devices::RFM98::RFM98 | ( | uint8_t | slaveSelectPin, |
uint8_t | interruptPin, | ||
RHGenericSPI & | spi = hardware_spi1 |
||
) |
Construct a new RFM98::RFM98 object.
slaveSelectPin | The chip/slave select pin connecting the Teensy and RFM98 radio. |
interruptPin | The interrupt pin connecting the Teensy and RFM98 radio. |
spi | The SPI connection connecting the Teensy and RFM98 radio. |
This constructor passes the external parameters to the internal RFM98 object stored in the RFM98 class.
int32_t Artemis::Devices::RFM98::init | ( | rfm98_config | cfg, |
Threads::Mutex * | mtx | ||
) |
Initialization of the RFM98 radio.
cfg | A rfm98_config struct, containing the configuration settings for the radio. |
mtx | The mutex used to lock the SPI interface for the RFM98 channel. |
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.
int32_t Artemis::Devices::RFM98::recv | ( | PacketComm & | packet, |
uint16_t | timeout | ||
) |
Receive a packet using the RFM98 radio.
packet | A pointer to the PacketComm packet that will hold the receieved data. |
timeout | The maximum time to wait for a packet to be received, in milliseconds. |
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.
int32_t Artemis::Devices::RFM98::reset | ( | ) |
Resets the RFM98 radio.
int32_t Artemis::Devices::RFM98::send | ( | PacketComm & | packet | ) |
Transmit a packet using the RFM98 radio.
packet | A pointer to the PacketComm packet to be transmitted. |
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.