aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/includes/Core
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-06-29 18:48:05 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-06-29 18:48:05 +0200
commitcc0301784156543c7c9bec36b6f42df1d2adba28 (patch)
tree02b0d45518bfc53bafdf011320d4309b7f218ba0 /src/common/includes/Core
parentf19631d2a66d01c0cdd85134c5eb63a1da42b34a (diff)
downloadglutte-o-matic-cc0301784156543c7c9bec36b6f42df1d2adba28.tar.gz
glutte-o-matic-cc0301784156543c7c9bec36b6f42df1d2adba28.tar.bz2
glutte-o-matic-cc0301784156543c7c9bec36b6f42df1d2adba28.zip
Change common/ folder structure
Diffstat (limited to 'src/common/includes/Core')
-rw-r--r--src/common/includes/Core/common.h82
-rw-r--r--src/common/includes/Core/delay.h39
-rw-r--r--src/common/includes/Core/fsm.h135
3 files changed, 0 insertions, 256 deletions
diff --git a/src/common/includes/Core/common.h b/src/common/includes/Core/common.h
deleted file mode 100644
index 4918a5b..0000000
--- a/src/common/includes/Core/common.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.
-*/
-
-/* A set of common routines for internal timekeeping and a LFSR to generate
- * a random number
- */
-
-#pragma once
-
-#include <stdint.h>
-#include <time.h>
-
-/* Feature defines */
-#define ENABLE_PSK31 0
-
-#define FLOAT_PI 3.1415926535897932384f
-
-void common_init(void);
-
-// Return the current timestamp in milliseconds. Timestamps are monotonic, and not
-// wall clock time.
-uint64_t timestamp_now(void);
-
-// Calculate local time from GPS time, including daylight saving time
-// Return 1 on success, 0 on failure
-// A call to this function will invalidate the information inside 'time'
-// regardless of return value.
-int local_time(struct tm *time);
-
-// Try to calculate local time, based on a past valid local time and the current timestamp
-// Return 1 on success, 0 on failure
-int local_derived_time(struct tm *time);
-
-// Return either 0 or 1, somewhat randomly
-int random_bool(void);
-
-// Fault handling mechanism
-#define FAULT_SOURCE_MAIN 1
-#define FAULT_SOURCE_GPS 2
-#define FAULT_SOURCE_I2C 3
-#define FAULT_SOURCE_USART 4
-#define FAULT_SOURCE_TASK_OVERFLOW 5
-#define FAULT_SOURCE_CW_AUDIO_QUEUE 6
-#define FAULT_SOURCE_ADC1 7
-#define FAULT_SOURCE_TIM6_ISR 8
-#define FAULT_SOURCE_ADC2_QUEUE 9
-#define FAULT_SOURCE_ADC2_IRQ 10
-void trigger_fault(int source);
-
-int find_last_sunday(const struct tm*);
-
-#ifdef SIMULATOR
-void __disable_irq(void);
-#else
-void hard_fault_handler_c(uint32_t *);
-#endif
-
-// Round a value to the nearest 0.5
-float round_float_to_half_steps(float value);
-
-#define GPS_MS_TIMEOUT 2000ul
diff --git a/src/common/includes/Core/delay.h b/src/common/includes/Core/delay.h
deleted file mode 100644
index 4cc3f07..0000000
--- a/src/common/includes/Core/delay.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
-*/
-
-#pragma once
-#include <stdint.h>
-
-// High-precisions delay (with approximations)
-
-// These functions only work if interupts are disabled
-#ifdef SIMULATOR
-void delay_us(int micros);
-void delay_ms(int millis);
-#else
-void delay_us(uint32_t micros);
-void delay_ms(uint32_t millis);
-#endif
-
-void delay_init(void);
diff --git a/src/common/includes/Core/fsm.h b/src/common/includes/Core/fsm.h
deleted file mode 100644
index 37ca386..0000000
--- a/src/common/includes/Core/fsm.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-#include <stdint.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
- FSM_BALISE_COURTE_OPEN, // Short intermittent beacon, need to switch to OPEN
- _NUM_FSM_STATES // Dummy state to count the number of states
-};
-
-typedef enum fsm_state_e fsm_state_t;
-
-// List of all states the balise FSM of the relay can be in
-enum balise_fsm_state_e {
- BALISE_FSM_EVEN_HOUR = 0, // Even hours.
- BALISE_FSM_ODD_HOUR, // Odd hours
- BALISE_FSM_PENDING, // Waiting for transmission of balise
-};
-
-typedef enum balise_fsm_state_e balise_fsm_state_t;
-
-
-// List of all states the SSTV FSM of the relay can be in
-enum sstv_fsm_state_e {
- SSTV_FSM_OFF = 0,
- SSTV_FSM_ON,
-};
-
-typedef enum sstv_fsm_state_e sstv_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 hour_is_even; // 1 if hour is even
- 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 button_1750; // Front panel button 1750Hz
-
- /* Signals coming from FAX and 1750 detector */
- int fax_mode; // 1750Hz filter disabled for machine-generated modes
- int det_1750; // 1750Hz detected
- int long_1750; // 1750Hz detected for more than 5s
-
- /* 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 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
-
- /* Tone detector */
- int require_tone_detector; // Enables audio input and detector for DTMF and 1750
-};
-
-// Initialise local structures
-void fsm_init(void);
-
-// Call the FSM once and update the internal state
-void fsm_update(void);
-
-void fsm_balise_update(void);
-
-// Update the FAX/SSTV state machine and return 1 if the 1750 notch filter must be
-// disabled
-int fsm_sstv_update(void);
-
-// Force a BALISE
-void fsm_balise_force(void);
-
-// 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);
-
-// Announce a state change
-void fsm_state_switched(const char *new_state);