Ke Ao Teensy Flight Software
The software on the Teensy in the Ke Ao cubesat.
|
The satellite's RFM23 radio. More...
#include <rfm23.h>
Classes | |
struct | rfm23_config |
The RFM23 configuration structure. More... | |
Public Member Functions | |
RFM23 (uint8_t slaveSelectPin, uint8_t interruptPin, RHGenericSPI &spi=hardware_spi1) | |
Construct a new RFM23::RFM23 object. | |
int32_t | reset () |
Resets the RFM23 radio. | |
int32_t | init (rfm23_config cfg, Threads::Mutex *mtx) |
Initialization of the RFM23 radio. | |
int32_t | send (PacketComm &packet) |
Transmit a packet using the RFM23 radio. | |
int32_t | recv (PacketComm &packet, uint16_t timeout) |
Receive a packet using the RFM23 radio. | |
int32_t | set_tx_power (uint8_t power) |
Sets the transmit power of the RFM23 radio. | |
int32_t | get_tsen () |
Gets the RFM23's temperature. | |
int32_t | read_rssi () |
Gets the Received Signal Strength Indicator (RSSI). | |
The satellite's RFM23 radio.
Artemis::Devices::RFM23::RFM23 | ( | uint8_t | slaveSelectPin, |
uint8_t | interruptPin, | ||
RHGenericSPI & | spi = hardware_spi1 |
||
) |
Construct a new RFM23::RFM23 object.
slaveSelectPin | The chip/slave select pin connecting the Teensy and RFM23 radio. |
interruptPin | The interrupt pin connecting the Teensy and RFM23 radio. |
spi | The SPI connection connecting the Teensy and RFM23 radio. |
This constructor passes the external parameters to the internal RFM23 object stored in the RFM23 class.
int32_t Artemis::Devices::RFM23::get_tsen | ( | ) |
int32_t Artemis::Devices::RFM23::init | ( | rfm23_config | cfg, |
Threads::Mutex * | mtx | ||
) |
Initialization of the RFM23 radio.
cfg | A rfm23_config struct, containing the configuration settings for the radio. |
mtx | The mutex used to lock the SPI interface for the RFM23 channel. |
The passed-in parameters are copied over to the internal private variables in the RFM23 class.
The SPI interface is locked for the exclusive use by the RFM23 channel. The SPI1 interface is then configured to use the pins defined in the passed-in (now local) configuration struct.
The transmit and receive enable pins are set as digital output pins.
The internal RFM23 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 RFM23 class with the configuration struct passed in earlier.
Set the RFM23's modulation mode. This is hardcoded in the initialization code. These are defined as RadioHead macros. Some, but not all, possible options are:
See the RadioHead documentation on the ModemConfigChoice enum in the RH_RF22 class (https://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF22.html) for all pre-defined modulation options.
Print a success message to the Teensy's serial console, and put the RFM23 into sleep mode.
int32_t Artemis::Devices::RFM23::read_rssi | ( | ) |
Gets the Received Signal Strength Indicator (RSSI).
int32_t Artemis::Devices::RFM23::recv | ( | PacketComm & | packet, |
uint16_t | timeout | ||
) |
Receive a packet using the RFM23 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 RFM23 is put into receive state by setting the transmit pin low and the receive pin high.
The SPI interface is locked for the exclusive use by the RFM23 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::RFM23::reset | ( | ) |
int32_t Artemis::Devices::RFM23::send | ( | PacketComm & | packet | ) |
Transmit a packet using the RFM23 radio.
packet | A pointer to the PacketComm packet to be transmitted. |
The RFM23 is put into transmit state by setting the transmit pin high and the receive pin low.
The header and payload of the packet are merged into one.
The SPI interface is locked for the exclusive use by the RFM23 channel. The packet is then sent using the RadioHead library call. The RFM23 is then put into sleep mode.
int32_t Artemis::Devices::RFM23::set_tx_power | ( | uint8_t | power | ) |
Sets the transmit power of the RFM23 radio.
power | The desired output power (in dBm?) |
The transmit power is limited to values between +20dBm and +1dBm. It is then written to the internal RFM23 configuration.