Further APRS implementation

develop
sq2ips 2025-03-20 17:02:12 +01:00
rodzic 02296e9197
commit cc70b7d6a2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: C383A71588BA55F5
9 zmienionych plików z 108 dodań i 21 usunięć

Wyświetl plik

@ -0,0 +1,11 @@
#ifndef __INC_AFSK_H_
#define __INC_AFSK_H_
#include "main.h"
uint8_t AFSK_is_active();
void AFSK_timer_handler();
void AFSK_start_TX(char* buff, uint8_t len);
void AFSK_stop_TX();
#endif

Wyświetl plik

@ -17,13 +17,21 @@
#define RF_BOOST_ACTIVE 0 // RF booster enabled for transmissions about 15dB gain, but more power consumed - normally should be ON(1).
/* Horus 4FSK settings */
#define HORUS_EN 0 // Horus 4FSK enable
#define HORUS_EN 1 // Horus 4FSK enable
#define QRG_FSK4 435100000 // Frequency fo horus modulation (in Hz)
#define PA_FSK4 10 // RF power setting for horus transmission values 0-63
/*---------------------*/
#define QRG_AFSK 435300000
#define PA_AFSK 10
#define AFSK_TONE_A 2200
#define AFSK_TONE_B 1200
#define ADF_DEVIATION 5
/* CW morse settings */
#define CW_EN 1 // Morse enable
#define CW_EN 0 // Morse enable
#define QRG_CW 435200000 // Frequency fo CW morse modulation (in Hz)
#define PA_CW 10 // RF power setting for CW morse transmission values 0-63

Wyświetl plik

@ -52,9 +52,12 @@ extern "C" {
/* USER CODE BEGIN Includes */
#include "stm32l0xx_it.h"
#include "fsk4.h"
#include "afsk.h"
#include "morse.h"
#include <stdbool.h>
#include <stdint.h>
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/

Wyświetl plik

@ -8,7 +8,7 @@
#ifndef INC_NMEA_H_
#define INC_NMEA_H_
#include <stdint.h>
#include "main.h"
typedef struct NMEA_DATA {
float Lat; //latitude in degrees with decimal places + for N - for S

Wyświetl plik

@ -108,7 +108,7 @@ void adf_reset_register_two(void) {
adf_config.r2.mod_control = ADF_MODULATION_FSK;
adf_config.r2.gook = ADF_OFF;
adf_config.r2.power_amplifier_level = 0; // power level
adf_config.r2.modulation_deviation = 2; //5= about 5k5Hz, 10=11kHz
adf_config.r2.modulation_deviation = ADF_DEVIATION; //5= about 5k5Hz, 10=11kHz
//adf_config.r2.modulation_deviation = 11;
adf_config.r2.gfsk_modulation_control = 0;
adf_config.r2.index_counter = 0;

Wyświetl plik

@ -0,0 +1,57 @@
#include "afsk.h"
#include "adf.h"
#include "config.h"
uint16_t AFSK_timer2ReloadValue = 0;
char *AFSK_buffer;
uint8_t AFSK_buffer_len = 0;
uint8_t AFSK_Active = 0;
uint32_t counter = 0;
uint8_t tone_state = 0;
uint8_t AFSK_is_active() { //returns 1 if transmitter is active for 4FSK
return AFSK_Active;
}
void AFSK_timer_handler(){
TIM2->CNT = 0;
LL_GPIO_TogglePin(ADF_TX_Data_GPIO_Port, ADF_TX_Data_Pin);
if(counter>=1000){
counter = 0;
if(tone_state == 0){
tone_state = 1;
AFSK_timer2ReloadValue = (50000 / AFSK_TONE_A) - 1;
TIM2->ARR = AFSK_timer2ReloadValue;
}else{
tone_state = 0;
AFSK_timer2ReloadValue = (50000 / AFSK_TONE_B) - 1;
TIM2->ARR = AFSK_timer2ReloadValue;
}
}
counter++;
}
void AFSK_start_TX(char* buff, uint8_t len) {
AFSK_buffer = buff;
AFSK_buffer_len = len;
adf_RF_on(QRG_AFSK, PA_AFSK); //turn on radio TX
AFSK_Active = 1; //change status
TIM2->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); // Disable the TIM Counter
AFSK_timer2ReloadValue = (50000 / AFSK_TONE_A) - 1; //timer value calculated according to baud rate 999 for 100bd
TIM2->ARR = AFSK_timer2ReloadValue; //set timer counter max value to pre-set value for baudrate (auto-reload register)
TIM2->CR1 |= TIM_CR1_CEN; //enable timer again
TIM2->DIER |= TIM_DIER_UIE; //Enable the interrupt
AFSK_timer_handler(); //force execution of procedure responsible for interrupt handling
}
void AFSK_stop_TX() {
TIM2->DIER &= ~(TIM_DIER_UIE); /* Disable the interrupt */
adf_RF_off(); //turn TX off
AFSK_Active = 0;
}

Wyświetl plik

@ -26,6 +26,8 @@
#include "morse.h"
#endif
#include "afsk.h"
#include "lps22hb.h"
#include <math.h>
@ -388,12 +390,14 @@ int main(void)
#endif
// main loop timer
LL_TIM_EnableCounter(TIM22);
LL_TIM_EnableIT_UPDATE(TIM22);
//LL_TIM_EnableCounter(TIM22);
//LL_TIM_EnableIT_UPDATE(TIM22);
// LED timer
LL_TIM_EnableCounter(TIM6);
LL_TIM_EnableIT_UPDATE(TIM6);
AFSK_start_TX(0, 0);
/* USER CODE END 2 */
/* Infinite loop */

Wyświetl plik

@ -146,20 +146,23 @@ void SysTick_Handler(void)
void TIM2_IRQHandler(void)
{
/* USER CODE BEGIN TIM2_IRQn 0 */
if(LL_TIM_IsActiveFlag_UPDATE(TIM2) == 1)
{
LL_TIM_ClearFlag_UPDATE(TIM2);
#if HORUS_EN == 1
if (FSK4_is_active()) { //check if we are transmitting in 4FSK mode
FSK4_timer_handler();
}
#endif
#if CW_EN == 1
if (CW_is_active()){
CW_timer_handler();
}
#endif
}
if(LL_TIM_IsActiveFlag_UPDATE(TIM2) == 1){
LL_TIM_ClearFlag_UPDATE(TIM2);
#if HORUS_EN == 1
if (FSK4_is_active()) { //check if we are transmitting in 4FSK mode
FSK4_timer_handler();
}
#endif
#if CW_EN == 1
if (CW_is_active()){
CW_timer_handler();
}
#endif
if(AFSK_is_active()){
AFSK_timer_handler();
}
}
/* USER CODE END TIM2_IRQn 0 */
/* USER CODE BEGIN TIM2_IRQn 1 */

Wyświetl plik

@ -58,7 +58,8 @@ Core/Src/horus.c \
Core/Src/lps22hb.c \
Core/Src/nmea.c \
Core/Src/xm_gps.c \
Core/Src/morse.c
Core/Src/morse.c \
Core/Src/afsk.c
# ASM sources
ASM_SOURCES = \