Skip to content

Commit

Permalink
Merge pull request #10 from msalinoh/aprs_task_integration
Browse files Browse the repository at this point in the history
APRS Recovery Task
  • Loading branch information
kgrewal26 authored Jul 25, 2023
2 parents ba695a8 + f1529db commit 269dd32
Show file tree
Hide file tree
Showing 12 changed files with 440 additions and 278 deletions.
24 changes: 24 additions & 0 deletions TagV3.0_U575VGT/Core/Inc/Lib Inc/timing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* timing.h
*
* Created on: Jul 5, 2023
* Author: Kaveet
*
* A library file containing helpful functions, macros and constants related to timing. This could include RTOS Software Timers, delays, etc.
*/

#ifndef INC_LIB_INC_TIMING_H_
#define INC_LIB_INC_TIMING_H_

#include "tx_user.h"

//A macro for converting seconds to threadX ticks. This can be used to feed into software timers, task sleeps, etc.
#define tx_s_to_ticks(S) ((S) * (TX_TIMER_TICKS_PER_SECOND))

//A macro for converting milliseconds to threadX ticks. This can be used to feed into software timers, task sleeps, etc.
#define tx_ms_to_ticks(MS) ((MS) * (TX_TIMER_TICKS_PER_SECOND) / 1000)

//A macro for converting microseconds to threadX ticks. This can be used to feed into software timers, task sleeps, etc.
#define tx_us_to_ticks(US) ((US) * (TX_TIMER_TICKS_PER_SECOND) / 1000000)

#endif /* INC_LIB_INC_TIMING_H_ */
46 changes: 14 additions & 32 deletions TagV3.0_U575VGT/Core/Inc/Recovery Inc/Aprs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,36 @@
*
* Created on: May 26, 2023
* Author: Kaveet
*/

#ifndef INC_RECOVERY_INC_APRS_H_
#define INC_RECOVERY_INC_APRS_H_

/*
*
* This file contains the main APRS thread responsible for board recovery.
*
* It receives the GPS data from the GPS functions, and then calls the appropriate library functions
* to break up the data into an array and transmit it to the VHF module
*
* Library Functions/Files:
* - AprsTransmit -> handles the transmission of the sine wave
* - AprsPacket -> breaks the GPS data into appropriate packets
* Library Functions/Files:
* - AprsTransmit -> handles the transmission of the sine wave
* - AprsPacket -> breaks the GPS data into appropriate packets
*/

//Library includes
#include "tx_api.h"

#define APRS_FLAG 0x7e
#define APRS_CONTROL_FIELD 0x03
#define APRS_PROTOCOL_ID 0xF0
#ifndef INC_RECOVERY_INC_APRS_H_
#define INC_RECOVERY_INC_APRS_H_

#define APRS_SOURCE_CALLSIGN "J75Y"
#define APRS_SOURCE_SSID 1
/*
#define APRS_SYMBOL "/C"
#define APRS_DESTINATION_CALLSIGN "APRS"
#define APRS_DESTINATION_SSID 0
*/
#include "tx_api.h"

#define APRS_DIGI_PATH "WIDE2"
#define APRS_DIGI_SSID 2
#define APRS_PACKET_MAX_LENGTH 255

#define APRS_COMMENT "Build Demonstration"
#define APRS_PACKET_LENGTH 224

#define APRS_CALLSIGN_LENGTH 6
#define GPS_SLEEP_LENGTH tx_s_to_ticks(10)

#define APRS_DT_POS_CHARACTER '!'
#define APRS_SYM_TABLE_CHAR '1'
#define APRS_SYM_CODE_CHAR 's'
#define APRS_BASE_SLEEP_LENGTH tx_s_to_ticks(60)

#define APRS_LATITUDE_LENGTH 9
#define APRS_LONGITUDE_LENGTH 10
#define NUM_TX_ATTEMPTS 3

//Main thread entry
void aprs_thread_entry(ULONG aprs_thread_input);

//generates an aprs packet given the latitude and longitude
void aprs_generate_packet(float lat, float lon);

#endif /* INC_RECOVERY_INC_APRS_H_ */
49 changes: 49 additions & 0 deletions TagV3.0_U575VGT/Core/Inc/Recovery Inc/AprsPacket.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* AprsPacket.h
*
* Created on: Jul 5, 2023
* Author: Kaveet
*
* This file contains the appropriate functions and definitons to create an APRS packet. Requires the caller to pass in a buffer and the latitude and longitude.
*
* There are various static functions defined in the C file to help create this packet.
*
* The APRS task should call this after it receives its GPS data. It will then use this packet to transmit through the VHF module.
*/

#ifndef INC_RECOVERY_INC_APRSPACKET_H_
#define INC_RECOVERY_INC_APRSPACKET_H_

//Library includes
#include "tx_api.h"
#include <stdint.h>

#define APRS_FLAG 0x7e
#define APRS_CONTROL_FIELD 0x03
#define APRS_PROTOCOL_ID 0xF0

#define APRS_SOURCE_CALLSIGN "J75Y"
#define APRS_SOURCE_SSID 1

#define APRS_SYMBOL "/C"
#define APRS_DESTINATION_CALLSIGN "APRS"
#define APRS_DESTINATION_SSID 0

#define APRS_DIGI_PATH "WIDE2"
#define APRS_DIGI_SSID 2

#define APRS_COMMENT "Build Demonstration"

#define APRS_CALLSIGN_LENGTH 6

#define APRS_DT_POS_CHARACTER '!'
#define APRS_SYM_TABLE_CHAR '1'
#define APRS_SYM_CODE_CHAR 's'

#define APRS_LATITUDE_LENGTH 9
#define APRS_LONGITUDE_LENGTH 10

//generates an aprs packet given the latitude and longitude
void aprs_generate_packet(uint8_t * buffer, float lat, float lon);

#endif /* INC_RECOVERY_INC_APRSPACKET_H_ */
26 changes: 13 additions & 13 deletions TagV3.0_U575VGT/Core/Inc/Recovery Inc/AprsTransmit.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@
*
* Created on: May 26, 2023
* Author: Kaveet
*/

#ifndef INC_RECOVERY_INC_APRSTRANSMIT_H_
#define INC_RECOVERY_INC_APRSTRANSMIT_H_


/*
*
* This file handles the transmission of the APRS sine wave to the VHF module.
*
* This includes:
* - Tell the VHF module we will start talking to it
* - Generate the sine wave and appropriately apply the frequency modulation to it
* - Generating the sine wave and appropriately apply the frequency modulation to it
*
* Parameters:
* - The raw data array to transmit (received from main APRS task)
*
* It uses the DAC to transmit a sine wave through DMA. The frequency of the wave is controlled by a hardware timer (changing the period changes the frequency).
*
* There is a software timer that cycles through bits, changing the frequency appropriately.
*
* Returns:
* - Whether or not the transmission was successful
* A "0" bit indicates a change in frequency, while a "1" bit will keep the same frequency. We toggle between 1200 and 2200 Hz.
*
* During the main data/payload, there must be a stuffed bit (forced transition) after 5 consecutive 1's.
*/

#ifndef INC_RECOVERY_INC_APRSTRANSMIT_H_
#define INC_RECOVERY_INC_APRSTRANSMIT_H_

//Includes
#include <stdbool.h>
#include <stdint.h>
#include "tx_api.h"
#include "Lib Inc/timing.h"

//Defines
//The time to transmit each bit for
//Each ThreadX tick is 100us -> 9 ticks makes it 900us. Based off the PICO code for the old recovery boards, where the bit time is 832us.
#define APRS_TRANSMIT_BIT_TIME 17
//Each ThreadX tick is 50us -> 17 ticks makes it 850us. Based off the PICO code for the old recovery boards, where the bit time is 832us.
#define APRS_TRANSMIT_BIT_TIME tx_us_to_ticks(850)

//The hardware timer periods for 1200Hz and 2400Hz signals
#define APRS_TRANSMIT_PERIOD_1200HZ 84
Expand Down
3 changes: 2 additions & 1 deletion TagV3.0_U575VGT/Core/Inc/Recovery Inc/GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*
* Integration Manual: https://content.u-blox.com/sites/default/files/NEO-M9N_Integrationmanual_UBX-19014286.pdf
* Interface Description: https://content.u-blox.com/sites/default/files/u-blox-M9-SPG-4.04_InterfaceDescription_UBX-21022436.pdf
*
*/

#ifndef INC_RECOVERY_INC_GPS_H_
Expand All @@ -35,6 +34,8 @@
#define DEFAULT_LAT 15.31383
#define DEFAULT_LON -61.30075

#define DOMINICA_LAT_BOUNDARY 17.71468

typedef enum __GPS_MESSAGE_TYPES {
GPS_SIM = 0,
GPS_GLL = 1,
Expand Down
15 changes: 11 additions & 4 deletions TagV3.0_U575VGT/Core/Inc/Recovery Inc/VHF.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* This file outlines the UART driver for the VHF module (DRA818V).
*
* It initializes, configures and manages the VHF module used in recovery mode.
*
* The VHF module attached our input signal (DAC) to the carrier wave. The carrier wave has a configurable frequency.
*/

#ifndef INC_RECOVERY_INC_VHF_H_
Expand All @@ -16,8 +18,13 @@
#include <stdbool.h>

//Defines

//Useful Frequencies
#define TX_FREQ "144.3900"
#define RX_FREQ "144.3900"
#define DOMINICA_TX_FREQ "145.0500"
#define DOMINICA_RX_FREQ "145.0500"

#define VHF_VOLUME_LEVEL 4

//Lengths of messages used to configure the VHF module
Expand Down Expand Up @@ -48,7 +55,7 @@
-huart - UART handler to talk to the module
-isHigh: whether or not to use high power (1W) or low power (0.5W). Passing true means high power.
*/
HAL_StatusTypeDef initialize_vhf(UART_HandleTypeDef huart, bool isHigh);
HAL_StatusTypeDef initialize_vhf(UART_HandleTypeDef huart, bool is_high, char * tx_freq, char * rx_freq);

/*Configure the VHF module over UART
Parameters:
Expand All @@ -58,13 +65,13 @@ HAL_StatusTypeDef initialize_vhf(UART_HandleTypeDef huart, bool isHigh);
-lpf: Apply a low-pass-filter on the signals.
-hps: Apply a high-pass-filter on the signals.
*/
HAL_StatusTypeDef configure_dra818v(UART_HandleTypeDef huart, bool emphasis, bool lpf, bool hpf);
HAL_StatusTypeDef configure_dra818v(UART_HandleTypeDef huart, bool emphasis, bool lpf, bool hpf, char * tx_freq, char * rx_freq);

//Enables or disbles the push-to-talk pin. Setting true lets us talk to the module (i.e., transmit signals).
void set_ptt(bool isTx);
void set_ptt(bool is_tx);

//Toggles the power level on the module from high (1W) and low (0.5W).
void set_power_level(bool isHigh);
void set_power_level(bool is_high);

//Puts the VHF module to sleep
void sleep_vhf();
Expand Down
Loading

0 comments on commit 269dd32

Please sign in to comment.