Ke Ao Teensy Flight Software
The software on the Teensy in the Ke Ao cubesat.
|
Definitions of Artemis Channels. More...
Go to the source code of this file.
Enumerations | |
enum | Artemis::Channels::Channel_ID : uint8_t { Artemis::Channels::RFM23_CHANNEL = 1 , Artemis::Channels::RFM98_CHANNEL , Artemis::Channels::ASTRODEV_CHANNEL , Artemis::Channels::PDU_CHANNEL , Artemis::Channels::RPI_CHANNEL } |
Enumeration of channel ID. More... | |
Functions | |
void | Artemis::Channels::rfm23_channel () |
The operating loop for the RFM23 radio. | |
void | Artemis::Channels::rfm98_channel () |
The operating loop for the RFM98 radio. | |
void | Artemis::Channels::astrodev_channel () |
The operating loop for the Astrodev (Li-3) radio. | |
void | Artemis::Channels::pdu_channel () |
The operating loop for the PDU. | |
void | Artemis::Channels::rpi_channel () |
The operating loop for communications with the Raspberry Pi. | |
Definitions of Artemis Channels.
This defines the channels used in the Teensy's main operating loop.
A 'channel' is used by the Teensy to multitask. Each channel acts like a loop() function in an Arduino sketch, run in parallel. The Teensy's single processor switches between sucessive channels, executing some portion of the loop when it is that channel's turn. This is called 'multithreading', with multiple 'threads' executing in parallel.
It is important to note that channels must be written with the assumption that they can be interrupted at any point in their execution. Thus, it is important to ensure that two channels cannot use the same resource (like a digital pin or serial connection) simultanously. To avoid this problem, we use mutual exclusions (mutexes). These are 'locks' that tie resources to a particular channel. If that channel is interrupted and another channel tries to use that same resource, it will have to wait until that mutex 'lock' is released. See spi1_mtx for an example of mutexes used by the channels.
enum Artemis::Channels::Channel_ID : uint8_t |
Enumeration of channel ID.
This enum represents the type of channel, using a 1-byte value. Using these identifiers, we can iterate over the channels.
void Artemis::Channels::astrodev_channel | ( | ) |
The operating loop for the Astrodev (Li-3) radio.
This is the equivalent of a seperate Arduino sketch for the Astrodev radio and its functions. The first portion is the equivalent to the setup() function and is run only once. The remainder is an infinite loop, equivalent to the loop() function.
This portion of the channel is run only once on startup. A serial connection to the Astrodev radio is initialized. If this initialization fails, it is retried every second. See the astrodev_init() helper function for details.
This portion of the channel is run in an infinite loop. The astrodev_queue is checked for a new PacketComm packet. If there is one, then that packet is sent to the Astrodev radio for transmission. The Astrodev radio's receive buffer is also checked for an incoming Astrodev frame. The Astrodev radio is then periodically polled for telemetry data. See the astrodev_send() and astrodev_recv() helper functions for details on how frames and packets are handled.
void Artemis::Channels::pdu_channel | ( | ) |
The operating loop for the PDU.
This is the equivalent of a seperate Arduino sketch for the PDU and its functions. The first portion is the equivalent to the setup() function and is run only once. The remainder is an infinite loop, equivalent to the loop() function.
This portion of the channel is run only once. A serial connection is initialized, then the PDU is given 5 seconds to warm up.
A connection test is performed. A ping command packet is sent over the PDU serial connection, and a response is awaited. If the response is a pong data packet, a confirmation message is printed to the Teensy's serial connection.
The burnwire switch is set, then 10 seconds is given to allow the burnwire switch to burn. The burnwire switch is then switched off.
This portion of the channel is run in an infinite loop. The pdu_queue is checked for a new packet. This loop only handles incoming command packets. If there is one, then the desired command is executed. See the code for a detailed explaination.
void Artemis::Channels::rfm23_channel | ( | ) |
The operating loop for the RFM23 radio.
This is the equivalent of a seperate Arduino sketch for the PDU and its functions. The first portion is the equivalent to the setup() function and is run only once. The remainder is an infinite loop, equivalent to the loop() function.
This portion of the channel is run only once. A SPI connection is initialized using the spi1_mtx mutex.
This portion of the channel is run in an infinite loop. The rfm23_queue is checked for a new packet. This loop only handles outgoing data packets. If there is one, then the desired packet is transmitted. The RFM23's receive buffer is also checked for an incoming packet. If there is one, it is copied to the main_queue. Additionally, telemetry packets are sent at regular intervals. See the code for a detailed explaination.
void Artemis::Channels::rfm98_channel | ( | ) |
The operating loop for the RFM98 radio.
This is the equivalent of a seperate Arduino sketch for the RFM98 radio and its functions. The first portion is the equivalent to the setup() function and is run only once. The remainder is an infinite loop, equivalent to the loop() function.
This portion of the channel is run only once. A SPI connection is initialized using the spi1_mtx mutex.
This portion of the channel is run in an infinite loop. The rfm98_queue is checked for a new packet. If there is one, then the desired packet is transmitted. The RFM98's receive buffer is also checked for an incoming packet. If there is one, it is copied to the main_queue. See the code for a detailed explaination.
void Artemis::Channels::rpi_channel | ( | ) |
The operating loop for communications with the Raspberry Pi.
This is the equivalent of a seperate Arduino sketch for communicating with the Raspberry Pi. The first portion is the equivalent to the setup() function and is run only once. The remainder is an infinite loop, equivalent to the loop() function.
This portion of the channel is run only once. An I2C connection is initialized between the Teensy and Raspberry Pi, with the Teensy as slave and Raspberry Pi as master. The helper functions receiveData() and sendData() are registered as helper functions to be invoked when data is transfered between the Teensy and Raspberry Pi. The Raspberry Pi status pin is also set as an input.
This portion of the channel is run in an infinite loop. The rpi_queue is checked for a new packet. If there is one, then the packet is packaged for transmission to the Raspberry Pi. The loop also checks for the special case where the packet is a command to shut down the Raspberry Pi. See the code for a detailed explaination.