Artemis Teensy Flight Software
The software on the Teensy in the Artemis cubesat.
artemis_defs.h
Go to the documentation of this file.
1 
7 #ifndef _ARTEMIS_DEFS_H
8 #define _ARTEMIS_DEFS_H
9 
10 #include <TeensyThreads.h>
12 #include <support/packetcomm.h>
13 
15 #define ARTEMIS_CURRENT_BEACON_1_COUNT 2
17 #define ARTEMIS_CURRENT_SENSOR_COUNT 5
18 
20 #define ARTEMIS_TEMP_SENSOR_COUNT 7
27 const float MV_PER_DEGREE_F = 1.0;
34 const float OFFSET_F = 58.0;
42 const float MV_PER_ADC_UNIT = 3300.0 / 1024.0;
43 
45 const float heater_threshold = -10.0;
46 
48 #define MAXQUEUESIZE 8
49 
51 enum class NODES : uint8_t {
52  GROUND_NODE_ID = 1,
53  TEENSY_NODE_ID = 2,
54  RPI_NODE_ID = 3,
55 };
56 
63 struct thread_struct {
64  int thread_id;
65  uint8_t channel_id;
66 };
67 
70  UART4_RXD,
71  UART4_TXD,
72  T_GPIO2,
73  T_GPIO3,
74  T_GPIO4,
75  T_GPIO5,
76  T_GPIO6,
77  UART6_RX,
78  UART6_TX,
79  T_CS1,
80  T_CS,
81  SPI0_MOSI,
82  SPI0_MISO,
83  SPI0_SCLK,
84  AIN0,
85  AIN1,
86  SCL1_I2C,
87  SDA1_I2C,
88  I2C2_SDA,
89  I2C2_SCL,
90  AIN3,
91  AIN4,
92  AIN5,
93  AIN6,
94  I2C1_SCL,
95  I2C1_SDA,
96  SPI1_D1,
97  SPI1_SCLK,
98  UART5_TXD,
99  UART5_RXD,
100  RX_ON,
101  TX_ON,
102  RADIO_RESET,
103  GPS_RSTN,
104  UART2_RXD,
105  UART2_TXD,
106  RPI_ENABLE,
107  SDN,
108  SPI1_CS1,
109  SPI1_D0,
110  NIRQ,
111  AIN2
112 };
113 
114 extern vector<struct thread_struct> thread_list;
115 
116 extern std::map<string, NODES> NodeType;
117 
118 extern std::deque<PacketComm> main_queue;
119 extern std::deque<PacketComm> rfm23_queue;
120 extern std::deque<PacketComm> pdu_queue;
121 extern std::deque<PacketComm> rpi_queue;
122 
123 extern Threads::Mutex main_queue_mtx;
124 extern Threads::Mutex rfm23_queue_mtx;
125 extern Threads::Mutex pdu_queue_mtx;
126 extern Threads::Mutex rpi_queue_mtx;
127 
128 extern Threads::Mutex spi1_mtx;
129 extern Threads::Mutex i2c1_mtx;
130 
131 extern bool deploymentmode;
132 
133 bool kill_thread(uint8_t channel_id);
134 void PushQueue(PacketComm &packet, std::deque<PacketComm> &queue,
135  Threads::Mutex &mtx);
136 bool PullQueue(PacketComm &packet, std::deque<PacketComm> &queue,
137  Threads::Mutex &mtx);
138 
143 
144 #endif // _ARTEMIS_DEFS_H
const float heater_threshold
The activation temperature, in Celsius, of the heater.
Definition: artemis_defs.h:45
Threads::Mutex rpi_queue_mtx
The mutex for the Raspberry Pi channel's packet queue.
Definition: artemis_defs.cpp:42
Threads::Mutex main_queue_mtx
The mutex for the main channel's packet queue.
Definition: artemis_defs.cpp:36
Threads::Mutex rfm23_queue_mtx
The mutex for the RFM23 channel's packet queue.
Definition: artemis_defs.cpp:38
bool kill_thread(uint8_t channel_id)
Kill a running thread.
Definition: artemis_defs.cpp:62
Threads::Mutex spi1_mtx
The mutex for the SPI1 interface.
Definition: artemis_defs.cpp:45
std::deque< PacketComm > pdu_queue
The packet queue for the PDU channel.
Definition: artemis_defs.cpp:31
const float MV_PER_ADC_UNIT
The conversion factor between ADC units and voltage.
Definition: artemis_defs.h:42
Threads::Mutex i2c1_mtx
The mutex for the I2C1 interface.
Definition: artemis_defs.cpp:47
bool PullQueue(PacketComm &packet, std::deque< PacketComm > &queue, Threads::Mutex &mtx)
Pull a packet from a queue.
Definition: artemis_defs.cpp:104
std::map< string, NODES > NodeType
Mapping between string names and NodeType.
Definition: artemis_defs.cpp:20
void route_packet_to_rfm23(PacketComm packet)
Wrapper function to send a packet to the RFM23.
Definition: artemis_defs.cpp:120
vector< struct thread_struct > thread_list
The list of active threads.
Definition: artemis_defs.cpp:17
bool deploymentmode
Whether the satellite is in deployment mode.
Definition: artemis_defs.cpp:50
std::deque< PacketComm > rpi_queue
The packet queue for the Raspberry Pi channel.
Definition: artemis_defs.cpp:33
void PushQueue(PacketComm &packet, std::deque< PacketComm > &queue, Threads::Mutex &mtx)
Push a packet into a queue.
Definition: artemis_defs.cpp:83
const float OFFSET_F
The offset of the temperature sensors.
Definition: artemis_defs.h:34
void route_packet_to_rpi(PacketComm packet)
Wrapper function to send a packet to the Raspberry Pi.
Definition: artemis_defs.cpp:128
const float MV_PER_DEGREE_F
The conversion factor between temperature and voltage.
Definition: artemis_defs.h:27
void route_packet_to_pdu(PacketComm packet)
Wrapper function to send a packet to the PDU.
Definition: artemis_defs.cpp:124
std::deque< PacketComm > rfm23_queue
The packet queue for the RFM23 channel.
Definition: artemis_defs.cpp:29
void route_packet_to_main(PacketComm packet)
Wrapper function to send a packet to the main channel.
Definition: artemis_defs.cpp:116
NODES
Enumeration of Node ID.
Definition: artemis_defs.h:51
TEENSY_PINS
Enumeration of Teensy 4.1 pins, based on Artemis OBC v4.23.
Definition: artemis_defs.h:69
std::deque< PacketComm > main_queue
The packet queue for the main channel.
Definition: artemis_defs.cpp:27
Threads::Mutex pdu_queue_mtx
The mutex for the PDU channel's packet queue.
Definition: artemis_defs.cpp:40
Definition: packetcomm.h:13
Headers and definitions common to all COSMOS Kernel.
PacketComm packet
The packet used throughout the channel.
Definition: pdu_channel.cpp:19
The structure of a thread.
Definition: artemis_defs.h:63