diff options
Diffstat (limited to 'src/common/includes')
-rw-r--r-- | src/common/includes/Audio/audio.h | 58 | ||||
-rw-r--r-- | src/common/includes/Audio/audio_in.h | 40 | ||||
-rw-r--r-- | src/common/includes/Audio/cw.h | 53 | ||||
-rw-r--r-- | src/common/includes/Audio/tone.h | 53 | ||||
-rw-r--r-- | src/common/includes/Core/common.h | 82 | ||||
-rw-r--r-- | src/common/includes/Core/delay.h | 39 | ||||
-rw-r--r-- | src/common/includes/Core/fsm.h | 135 | ||||
-rw-r--r-- | src/common/includes/GPIO/analog.h | 50 | ||||
-rw-r--r-- | src/common/includes/GPIO/i2c.h | 53 | ||||
-rw-r--r-- | src/common/includes/GPIO/leds.h | 9 | ||||
-rw-r--r-- | src/common/includes/GPIO/pio.h | 47 | ||||
-rw-r--r-- | src/common/includes/GPIO/temperature.h | 40 | ||||
-rw-r--r-- | src/common/includes/GPIO/usart.h | 78 | ||||
-rw-r--r-- | src/common/includes/GPS/gps.h | 46 | ||||
-rw-r--r-- | src/common/includes/GPS/minmea.h | 252 |
15 files changed, 0 insertions, 1035 deletions
diff --git a/src/common/includes/Audio/audio.h b/src/common/includes/Audio/audio.h deleted file mode 100644 index d48cbe5..0000000 --- a/src/common/includes/Audio/audio.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __AUDIO_H__ -#define __AUDIO_H__ - -#include <stdint.h> -#include <stdbool.h> - -typedef void AudioCallbackFunction(void *context,int buffer); - -// Variables used by both glutt-o-logique and simulator -extern AudioCallbackFunction *callback_function; -extern void *callback_context; -extern int16_t *next_buffer_samples; -extern int next_buffer_length; -extern int buffer_number; -extern bool dma_running; - -void audio_initialize_platform(int plln, int pllr, int i2sdiv, int i2sodd, int rate); -void audio_start_dma_and_request_buffers(void); -void audio_stop_dma(void); - -#define Audio8000HzSettings 256,5,12,1,8000 -#define Audio16000HzSettings 213,2,13,0,16000 -#define Audio32000HzSettings 213,2,6,1,32000 -#define Audio48000HzSettings 258,3,3,1,48000 -#define Audio96000HzSettings 344,2,3,1,96000 -#define Audio22050HzSettings 429,4,9,1,22050 -#define Audio44100HzSettings 271,2,6,0,44100 -#define AudioVGAHSyncSettings 419,2,13,0,31475 // 31475.3606. Actual VGA timer is 31472.4616. - -#define AUDIO_BUF_LEN 4096 - - -// Initialize and power up audio hardware. Use the above defines for the parameters. -// Can probably only be called once. -void audio_initialize(int plln, int pllr, int i2sdiv, int i2sodd, int rate); - -// Power up and down the audio hardware. -void audio_put_codec_in_reset(void); -void audio_reinit_codec(void); - -// Set audio volume in steps of 0.5 dB. 0xff is +12 dB. -void audio_set_volume(int volume); - -// Start and stop audio playback using DMA. -// Callback is optional, and called whenever a new buffer is needed. -void audio_play_with_callback(AudioCallbackFunction *callback,void *context); - -// Provide a new buffer to the audio DMA. Output is double buffered, so -// at least two buffers must be maintained by the program. It is not allowed -// to overwrite the previously provided buffer until after the next callback -// invocation. -// Buffers must reside in DMA1-accessible memory, that is, the 128k RAM bank, -// or flash. -bool audio_provide_buffer_without_blocking(void *samples,int numsamples); - -void DMA1_Stream7_IRQHandler(void); - -#endif diff --git a/src/common/includes/Audio/audio_in.h b/src/common/includes/Audio/audio_in.h deleted file mode 100644 index 97a0f29..0000000 --- a/src/common/includes/Audio/audio_in.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 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 <stdio.h> -#include "FreeRTOS.h" - -#define AUDIO_IN_RATE 16000 -#define AUDIO_IN_BUF_LEN 1600 - -void audio_in_initialize(void); - -/* Enable or disable the audio input */ -void audio_in_enable(int enable); - -/* The audio input layer must call tone_detect_push_sample() to - * send the samples - */ diff --git a/src/common/includes/Audio/cw.h b/src/common/includes/Audio/cw.h deleted file mode 100644 index 39be9c5..0000000 --- a/src/common/includes/Audio/cw.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 __CW_H_ -#define __CW_H_ - -#include <stdint.h> -#include <stddef.h> - -// Setup the CW generator to create audio samples at the given -// samplerate. -void cw_psk31_init(unsigned int samplerate); - -// Append new CW or PSK31 text to transmit -// CW/PSK31 audio centre frequency in Hz -// if dit_duration == 0, message is sent in PSK31 -// otherwise it is sent in CW, with dit_duration in ms -// returns 0 on failure, 1 on success -int cw_psk31_push_message(const char* text, int frequency, int dit_duration); - -// Write the waveform into the buffer (stereo), both for cw and psk31 -size_t cw_psk31_fill_buffer(int16_t *buf, size_t bufsize); - -// Return 1 if the CW or PSK31 generator is running -int cw_psk31_busy(void); - -void cw_message_sent(const char*); - -size_t cw_symbol(uint8_t, uint8_t *, size_t); - -#endif // __CW_H_ - diff --git a/src/common/includes/Audio/tone.h b/src/common/includes/Audio/tone.h deleted file mode 100644 index ba05304..0000000 --- a/src/common/includes/Audio/tone.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 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. -*/ - -#ifndef __TONE_H_ -#define __TONE_H_ - -#include <stdio.h> -#include "Audio/audio_in.h" - -#define TONE_BUFFER_LEN AUDIO_IN_BUF_LEN - -void tone_init(void); - -void tone_detector_enable(int enable); - -/* Return 1 when 1750 detected, 0 otherwise */ -int tone_1750_status(void); - -/* Return 1 if 1750 is currently detected, and has been already for at - * least 5s */ -int tone_1750_for_5_seconds(void); - -/* The FAX status is 1 if the recently decoded DTMF is the 0-7-* sequence. */ -int tone_fax_status(void); - -/* Must be called by task to do the analysis */ -void tone_do_analysis(void); - -/* Push a sample from the ADC ISR or Pulseaudio task */ -void tone_detect_push_sample(const uint16_t sample, int is_irq); - -#endif 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); diff --git a/src/common/includes/GPIO/analog.h b/src/common/includes/GPIO/analog.h deleted file mode 100644 index ddc19ac..0000000 --- a/src/common/includes/GPIO/analog.h +++ /dev/null @@ -1,50 +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> - -void analog_init(void); - -/* Measure the 12V supply voltage, in 0.5V increments. - * Returns 0.0f in case of error - * - * Warning, do not run from interrupt context! - */ -float analog_measure_12v(void); - -/* Measure SWR, and return voltages in mV. - * Returns 0 in case of error, 1 in case of success - * - * Warning, do not run from interrupt context! - */ -int analog_measure_swr(int *forward_mv, int* reflected_mv); - -/* Keep an average of measurements, and decide if the repeater should enter - * QRP. Returns 1 if low power must be activated - * - * Warning, do not run from interrupt context! - */ -int analog_supply_too_low(void); - diff --git a/src/common/includes/GPIO/i2c.h b/src/common/includes/GPIO/i2c.h deleted file mode 100644 index 69a4ad2..0000000 --- a/src/common/includes/GPIO/i2c.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 __I2C_H_ -#define __I2C_H_ - -#include <stdint.h> - -/* Initialise I2C on the board for both the audio codec and the GPS receiver */ -void i2c_init(void); - -/* Do an I2C write, return 1 on success, 0 on failure */ -int i2c_write(uint8_t device, const uint8_t *txbuf, int len); - -/* Do an I2C read into rxbuf. - * Returns number of bytes received, or 0 in case of failure - */ -int i2c_read(uint8_t device, uint8_t *rxbuf, int len); - -/* Do an I2C write for the address, and then a read into rxbuf. - * Returns number of bytes received, or 0 in case of failure - */ -int i2c_read_from(uint8_t device, uint8_t address, uint8_t *rxbuf, int len); - -/* Start an I2C transaction, keeping exclusive access to I2C */ -void i2c_transaction_start(void); - -/* End an I2C transaction, unlocking the exclusive access to I2C */ -void i2c_transaction_end(void); - -#endif // __I2C_H_ - diff --git a/src/common/includes/GPIO/leds.h b/src/common/includes/GPIO/leds.h deleted file mode 100644 index 70c57d2..0000000 --- a/src/common/includes/GPIO/leds.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#define LED_GREEN 1 -#define LED_ORANGE 2 -#define LED_RED 3 -#define LED_BLUE 4 - -void leds_turn_off(int); -void leds_turn_on(int); diff --git a/src/common/includes/GPIO/pio.h b/src/common/includes/GPIO/pio.h deleted file mode 100644 index e118fc8..0000000 --- a/src/common/includes/GPIO/pio.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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" - -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_gps_epps(int on); -void pio_set_fax(int on); -void pio_set_det_1750(int on); -void pio_set_sq2(int on); - -void pio_set_fsm_signals(struct fsm_input_signals_t* sig); - -int pio_read_button(void); - -#endif // _PIO_H_ - diff --git a/src/common/includes/GPIO/temperature.h b/src/common/includes/GPIO/temperature.h deleted file mode 100644 index f49cc26..0000000 --- a/src/common/includes/GPIO/temperature.h +++ /dev/null @@ -1,40 +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> - -extern float _temperature_last_value; -extern int _temperature_valid; - -// Setup communication and temperature -void temperature_init(void); - -// Return 1 if the temperature is valid -int temperature_valid(void); - -// Get current temperature -float temperature_get(void); - -void temperature_task(void *); diff --git a/src/common/includes/GPIO/usart.h b/src/common/includes/GPIO/usart.h deleted file mode 100644 index 681d86f..0000000 --- a/src/common/includes/GPIO/usart.h +++ /dev/null @@ -1,78 +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. -*/ - -/* This handles the USART 3 to the GPS receiver, and fills a queue of - * NMEA messages. - * - * It also handles the debug USART 2 and allows sending messages to the PC. - */ - -#ifndef __USART_H_ -#define __USART_H_ - -#ifdef STM32F4XX -# include <stm32f4xx_usart.h> -#else -# define USART_TypeDef int -# define USART2 ((USART_TypeDef*)2) -# define USART3 ((USART_TypeDef*)3) -#endif - -#define MAX_NMEA_SENTENCE_LEN 256 - -// Initialise USART2 for PC debugging -void usart_init(void); - -// Initialise USART3 for GPS and NMEA queue -// Needs running scheduler -void usart_gps_init(void); - -// Take GPS out of RESET -void usart_gps_remove_reset(void); - -// Send the str to the GPS receiver -void usart_gps_puts(const char* str); - -// a printf to send data to the PC -void usart_debug(const char *format, ...); - -// Send a string to the PC -void usart_debug_puts(const char* str); -void usart_debug_puts_header(const char* hdr, const char* str); - -// Get a MAX_NMEA_SENTENCE_LEN sized NMEA sentence -// Return 1 on success -int usart_get_nmea_sentence(char* nmea); - -void usart_debug_timestamp(void); - -void usart_gps_specific_init(void); - -void usart_process_char(char); -void usart_gps_process_char(char); - -void usart_puts(USART_TypeDef*, const char*); - -#endif //__USART_H_ - diff --git a/src/common/includes/GPS/gps.h b/src/common/includes/GPS/gps.h deleted file mode 100644 index 8a2118f..0000000 --- a/src/common/includes/GPS/gps.h +++ /dev/null @@ -1,46 +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. -*/ - -#pragma once - -#include <stdint.h> -#include <time.h> - -/* Setup GPS receiver over USART and parse time */ - -/* USART connections: - * board TX to GPS RX on PD8 - * board RX to GPS TX on PD9 - */ - -// Setup communication and GPS receiver -void gps_init(void); - -// Return 1 of the GPS is receiving time -int gps_locked(void); - -// Get current time from GPS and number of satellite vehicles -// used for fix. -// Returns 1 if data is valid, 0 otherwise -int gps_utctime(struct tm *timeutc, int *num_sv_used); diff --git a/src/common/includes/GPS/minmea.h b/src/common/includes/GPS/minmea.h deleted file mode 100644 index ab770a6..0000000 --- a/src/common/includes/GPS/minmea.h +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright © 2014 Kosma Moczek <kosma@cloudyourcar.com> - * This program is free software. It comes without any warranty, to the extent - * permitted by applicable law. You can redistribute it and/or modify it under - * the terms of the Do What The Fuck You Want To Public License, Version 2, as - * published by Sam Hocevar. See the COPYING file for more details. - */ - -#ifndef MINMEA_H -#define MINMEA_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> -#include <stdint.h> -#include <stdbool.h> -#include <errno.h> -#include <time.h> -#include <math.h> - -#define MINMEA_MAX_LENGTH 80 - -enum minmea_sentence_id { - MINMEA_INVALID = -1, - MINMEA_UNKNOWN = 0, - MINMEA_SENTENCE_RMC, - MINMEA_SENTENCE_GGA, - MINMEA_SENTENCE_GSA, - MINMEA_SENTENCE_GLL, - MINMEA_SENTENCE_GST, - MINMEA_SENTENCE_GSV, - MINMEA_SENTENCE_TXT, -}; - -struct minmea_float { - int_least32_t value; - int_least32_t scale; -}; - -struct minmea_date { - int day; - int month; - int year; -}; - -struct minmea_time { - int hours; - int minutes; - int seconds; - int microseconds; -}; - -struct minmea_sentence_rmc { - struct minmea_time time; - bool valid; - struct minmea_float latitude; - struct minmea_float longitude; - struct minmea_float speed; - struct minmea_float course; - struct minmea_date date; - struct minmea_float variation; -}; - -struct minmea_sentence_gga { - struct minmea_time time; - struct minmea_float latitude; - struct minmea_float longitude; - int fix_quality; - int satellites_tracked; - struct minmea_float hdop; - struct minmea_float altitude; char altitude_units; - struct minmea_float height; char height_units; - int dgps_age; -}; - -enum minmea_gll_status { - MINMEA_GLL_STATUS_DATA_VALID = 'A', - MINMEA_GLL_STATUS_DATA_NOT_VALID = 'V', -}; - -enum minmea_gll_mode { - MINMEA_GLL_MODE_AUTONOMOUS = 'A', - MINMEA_GLL_MODE_DPGS = 'D', - MINMEA_GLL_MODE_DR = 'E', -}; - -struct minmea_sentence_gll { - struct minmea_float latitude; - struct minmea_float longitude; - struct minmea_time time; - char status; - char mode; -}; - -struct minmea_sentence_gst { - struct minmea_time time; - struct minmea_float rms_deviation; - struct minmea_float semi_major_deviation; - struct minmea_float semi_minor_deviation; - struct minmea_float semi_major_orientation; - struct minmea_float latitude_error_deviation; - struct minmea_float longitude_error_deviation; - struct minmea_float altitude_error_deviation; -}; - -enum minmea_gsa_mode { - MINMEA_GPGSA_MODE_AUTO = 'A', - MINMEA_GPGSA_MODE_FORCED = 'M', -}; - -enum minmea_gsa_fix_type { - MINMEA_GPGSA_FIX_NONE = 1, - MINMEA_GPGSA_FIX_2D = 2, - MINMEA_GPGSA_FIX_3D = 3, -}; - -struct minmea_sentence_gsa { - char mode; - int fix_type; - int sats[12]; - struct minmea_float pdop; - struct minmea_float hdop; - struct minmea_float vdop; -}; - -struct minmea_sat_info { - int nr; - int elevation; - int azimuth; - int snr; -}; - -struct minmea_sentence_gsv { - int total_msgs; - int msg_nr; - int total_sats; - struct minmea_sat_info sats[4]; -}; - -enum minmea_txt_msgtype { - MINMEA_GPTXT_ERROR = 0, - MINMEA_GPTXT_WARNING = 1, - MINMEA_GPTXT_NOTICE = 2 -}; - -#define MINMEA_TXT_START_IX 16 - -struct minmea_sentence_txt { - int num_msg; - int msg_num; - enum minmea_txt_msgtype msgtype; - const char* text; - int text_len; -}; - -/** - * Calculate raw sentence checksum. Does not check sentence integrity. - */ -uint8_t minmea_checksum(const char *sentence); - -/** - * Check sentence validity and checksum. Returns true for valid sentences. - */ -bool minmea_check(const char *sentence, bool strict); - -/** - * Determine talker identifier. - */ -bool minmea_talker_id(char talker[3], const char *sentence); - -/** - * Determine sentence identifier. - */ -enum minmea_sentence_id minmea_sentence_id(const char *sentence, bool strict); - -/** - * Scanf-like processor for NMEA sentences. Supports the following formats: - * c - single character (char *) - * d - direction, returned as 1/-1, default 0 (int *) - * f - fractional, returned as value + scale (int *, int *) - * i - decimal, default zero (int *) - * s - string (char *) - * t - talker identifier and type (char *) - * T - date/time stamp (int *, int *, int *) - * Returns true on success. See library source code for details. - */ -bool minmea_scan(const char *sentence, const char *format, ...); - -/* - * Parse a specific type of sentence. Return true on success. - */ -bool minmea_parse_rmc(struct minmea_sentence_rmc *frame, const char *sentence); -bool minmea_parse_gga(struct minmea_sentence_gga *frame, const char *sentence); -bool minmea_parse_gsa(struct minmea_sentence_gsa *frame, const char *sentence); -bool minmea_parse_gll(struct minmea_sentence_gll *frame, const char *sentence); -bool minmea_parse_gst(struct minmea_sentence_gst *frame, const char *sentence); -bool minmea_parse_gsv(struct minmea_sentence_gsv *frame, const char *sentence); -bool minmea_parse_txt(struct minmea_sentence_txt *frame, const char *sentence); - -/** - * Convert GPS UTC date/time representation to a UNIX timestamp. - */ -int minmea_gettime(struct timespec *ts, const struct minmea_date *date, const struct minmea_time *time_); - -/** - * Rescale a fixed-point value to a different scale. Rounds towards zero. - */ -static inline int_least32_t minmea_rescale(struct minmea_float *f, int_least32_t new_scale) -{ - if (f->scale == 0) - return 0; - if (f->scale == new_scale) - return f->value; - if (f->scale > new_scale) - return (f->value + ((f->value > 0) - (f->value < 0)) * f->scale/new_scale/2) / (f->scale/new_scale); - else - return f->value * (new_scale/f->scale); -} - -/** - * Convert a fixed-point value to a floating-point value. - * Returns NaN for "unknown" values. - */ -static inline float minmea_tofloat(struct minmea_float *f) -{ - if (f->scale == 0) - return NAN; - return (float) f->value / (float) f->scale; -} - -/** - * Convert a raw coordinate to a floating point DD.DDD... value. - * Returns NaN for "unknown" values. - */ -static inline float minmea_tocoord(struct minmea_float *f) -{ - if (f->scale == 0) - return NAN; - int_least32_t degrees = f->value / (f->scale * 100); - int_least32_t minutes = f->value % (f->scale * 100); - return (float) degrees + (float) minutes / (60 * f->scale); -} - -#ifdef __cplusplus -} -#endif - -#endif /* MINMEA_H */ - -/* vim: set ts=4 sw=4 et: */ |