aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/includes
diff options
context:
space:
mode:
authorMaximilien Cuony <maximilien@theglu.org>2016-06-05 15:41:07 +0200
committerMaximilien Cuony <maximilien@theglu.org>2016-06-05 15:41:07 +0200
commit9d5ff73c98c9c2da27791813b18721e366d61912 (patch)
tree8e04750b031b8c6e8471981a9a6527fd2b900234 /src/common/includes
parentb47c16bb91991d3cbf004de5b1d5f610a5b2c807 (diff)
downloadglutte-o-matic-9d5ff73c98c9c2da27791813b18721e366d61912.tar.gz
glutte-o-matic-9d5ff73c98c9c2da27791813b18721e366d61912.tar.bz2
glutte-o-matic-9d5ff73c98c9c2da27791813b18721e366d61912.zip
Simulator: Input, outputs and FSM
Diffstat (limited to 'src/common/includes')
-rw-r--r--src/common/includes/Core/delay.h33
-rw-r--r--src/common/includes/Core/fsm.h103
-rw-r--r--src/common/includes/GPIO/pio.h47
-rw-r--r--src/common/includes/GPIO/usart.h1
4 files changed, 184 insertions, 0 deletions
diff --git a/src/common/includes/Core/delay.h b/src/common/includes/Core/delay.h
new file mode 100644
index 0000000..73ed669
--- /dev/null
+++ b/src/common/includes/Core/delay.h
@@ -0,0 +1,33 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Matthias P. Braendli, Maximilien Cuony
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+
+
+// High-precisions delay (with approximations)
+
+
+// Thoses functions works only if interupts are disabled
+void delay_us(uint32_t micros);
+void delay_ms(uint32_t millis);
+
+void delay_init();
diff --git a/src/common/includes/Core/fsm.h b/src/common/includes/Core/fsm.h
new file mode 100644
index 0000000..41f0503
--- /dev/null
+++ b/src/common/includes/Core/fsm.h
@@ -0,0 +1,103 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Matthias P. Braendli
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+
+#ifndef _FSM_H_
+#define _FSM_H_
+
+// List of all states the FSM of the relay can be in
+enum fsm_state_e {
+ FSM_OISIF = 0, // Idle
+ FSM_OPEN1, // 1750 Hz received and squelch open
+ FSM_OPEN2, // Squelch closed
+ FSM_LETTRE, // Transmit single status letter
+ FSM_ECOUTE, // Repeater open, waiting for QSO
+ FSM_ATTENTE, // No QSO after a short while
+ FSM_QSO, // QSO ongoing
+ FSM_ANTI_BAVARD, // QSO too long, cut transmission
+ FSM_BLOQUE, // Backoff after ANTI_BAVARD
+ FSM_TEXTE_73, // Transmit 73 after QSO
+ FSM_TEXTE_HB9G, // Transmit HB9G after QSO
+ FSM_TEXTE_LONG, // Transmit either HB9G JN36BK or HB9G 1628M after QSO
+ FSM_BALISE_LONGUE, // Full-length 2-hour beacon
+ FSM_BALISE_SPECIALE, // 2-hour beacon when in QRP or with high power return mode
+ FSM_BALISE_COURTE, // Short intermittent beacon
+ _NUM_FSM_STATES // Dummy state to count the number of states
+};
+
+typedef enum fsm_state_e fsm_state_t;
+
+// All signals that the FSM can read, most of them are actually booleans
+struct fsm_input_signals_t {
+ /* Signals coming from repeater electronics */
+ int sq; // Squelch detection
+ int discrim_u; // FM discriminator says RX is too high in frequency
+ int qrp; // The relay is currently running with low power
+ int start_tm; // 2-hour pulse
+ float temp; // temperature in degrees C
+ float humidity; // relative humidity, range [0-100] %
+ int wind_generator_ok; // false if the generator is folded out of the wind
+ int discrim_d; // FM discriminator says RX is too low in frequency
+ int tone_1750; // Detect 1750Hz tone
+ int sstv_mode; // The 1750Hz filter is disabled, permitting SSTV usage
+
+ /* Signals coming from CW and PSK generator */
+ int cw_psk31_done; // The CW and PSK generator has finished transmitting the message
+
+ /* Signal coming from the standing wave ratio meter */
+ int swr_high; // We see a lot of return power
+
+};
+
+// All signals the FSM has to control
+struct fsm_output_signals_t {
+ /* Signals to the repeater electronics */
+ int qrp; // Place the repeater in QRP mode // TODO move out of FSM
+ int tx_on; // Enable TX circuitry
+ int modulation; // Enable repeater RX to TX modulation
+
+ /* Signals to the CW and PSK generator */
+ const char* msg; // The message to transmit
+ int msg_frequency; // What audio frequency for the CW or PSK message
+ int cw_dit_duration; // CW speed, dit duration in ms
+ int cw_psk31_trigger; // Set to true to trigger a CW or PSK31 transmission.
+ // PSK31 is sent if cw_dit_duration is 0
+
+ /* Acknowledgements for input signals */
+ int ack_start_tm; // Set to 1 to clear start_tm
+};
+
+// Initialise local structures
+void fsm_init();
+
+// Call the FSM once and update the internal state
+void fsm_update();
+
+// Setter for inputs
+void fsm_update_inputs(struct fsm_input_signals_t* inputs);
+
+// Getter for outputs
+void fsm_get_outputs(struct fsm_output_signals_t* out);
+
+#endif // _FSM_H_
+
diff --git a/src/common/includes/GPIO/pio.h b/src/common/includes/GPIO/pio.h
new file mode 100644
index 0000000..19d3e15
--- /dev/null
+++ b/src/common/includes/GPIO/pio.h
@@ -0,0 +1,47 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2015 Matthias P. Braendli
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+
+#ifndef _PIO_H_
+#define _PIO_H_
+
+#include <stddef.h>
+#include <stdint.h>
+#include "Core/fsm.h"
+
+/* Analog inputs */
+// TODO: SWR forward power
+// TODO: SWR reflected power
+
+void pio_init(void);
+
+void pio_set_tx(int on);
+void pio_set_mod_off(int mod_off);
+void pio_set_qrp(int on);
+
+void pio_set_fsm_signals(struct fsm_input_signals_t* sig);
+
+int pio_read_button();
+
+#endif // _PIO_H_
+
diff --git a/src/common/includes/GPIO/usart.h b/src/common/includes/GPIO/usart.h
index 62c86c9..21936d7 100644
--- a/src/common/includes/GPIO/usart.h
+++ b/src/common/includes/GPIO/usart.h
@@ -48,6 +48,7 @@ void usart_debug(const char *format, ...);
// Send a string to the PC
void usart_debug_puts(const char* str);
+void usart_debug_puts_no_header(const char* str);
// Get a MAX_NMEA_SENTENCE_LEN sized NMEA sentence
// Return 1 on success