From 02296e9197dc4fb259624a316919415c9f115ffe Mon Sep 17 00:00:00 2001 From: sq2ips Date: Sun, 16 Mar 2025 20:39:11 +0100 Subject: [PATCH] added CW morse, small fixes and cleanup of main loop. --- .vscode/settings.json | 7 +- m20/Core/Inc/config.h | 46 ++++++--- m20/Core/Inc/main.h | 5 +- m20/Core/Inc/morse.h | 14 +++ m20/Core/Src/fsk4.c | 7 +- m20/Core/Src/main.c | 146 ++++++++++++++++++---------- m20/Core/Src/morse.c | 184 ++++++++++++++++++++++++++++++++++++ m20/Core/Src/stm32l0xx_it.c | 8 ++ m20/Makefile | 7 +- 9 files changed, 354 insertions(+), 70 deletions(-) create mode 100644 m20/Core/Inc/morse.h create mode 100644 m20/Core/Src/morse.c diff --git a/.vscode/settings.json b/.vscode/settings.json index b33b0d8..0414c69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -56,5 +56,10 @@ "C_Cpp_Runner.showCompilationTime": false, "C_Cpp_Runner.useLinkTimeOptimization": false, "C_Cpp_Runner.msvcSecureNoWarnings": false, - "cortex-debug.variableUseNaturalFormat": true + "cortex-debug.variableUseNaturalFormat": true, + "files.associations": { + "cstdint": "cpp", + "string.h": "c", + "compare": "c" + } } \ No newline at end of file diff --git a/m20/Core/Inc/config.h b/m20/Core/Inc/config.h index 163dc6e..742b284 100644 --- a/m20/Core/Inc/config.h +++ b/m20/Core/Inc/config.h @@ -3,37 +3,60 @@ #ifndef INC_CONFIG_H_ #define INC_CONFIG_H_ -//#define DEBUG - /*-----------------------------------------------------------------*/ -// Sonde configuration, parameters that should be changed +/*---- Sonde configuration, parameters that should be changed ----*/ #define PAYLOAD_ID 256 // Sonde payload ID 256 - for 4FSKTEST-V2 -#define TIME_PERIOD 6 // Time betwen starts of transmissions (in seconds) (must be more than 3) +#define CALLSIGN "SQ2IPS" + +#define TIME_PERIOD 20 // Time betwen starts of transmissions (in seconds) (must be more than 3) #define GPS_TYPE 1 // Type of GPS module: 1 - u-blox | 2 - XM1110 -#define QRG_FSK4 435100000 // Frequency fo horus modulation (in Hz) +#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 QRG_FSK4 435100000 // Frequency fo horus modulation (in Hz) #define PA_FSK4 10 // RF power setting for horus transmission values 0-63 -#define RF_BOOST_ACTIVE 1 // RF booster enabled for transmissions about 15dB gain, but more power consumed - normally should be ON(1). +/*---------------------*/ + +/* CW morse settings */ +#define CW_EN 1 // 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 + +#define MORSE_GRID_SIZE 3 // number of QTH elements to generate 1 for each group for example 3 for AB12CD etc, max is 5 + +#define MORSE_MS 50 // Length of one morse period in ms +#define MORSE_UNITS_DOT 1 +#define MORSE_UNITS_DASH 3 +#define MORSE_UNITS_GAP 3 +#define MORSE_UNITS_SPACE 7 +/*-------------------*/ + +/* LED settings */ +#define LED_MODE 1 // 0 - disabled, 1 - flashes when prepairing tx data before transmit, 2 - GPS fix indication +#define LED_PERIOD 5 // time between LED lighting +#define LED_DISABLE_ALT 1000 // disable led when certain altitude is reached, 0 for always enable +/*--------------*/ #define ADF_FREQ_CORRECTION 19 // correction of frequency from crystal inaccuracy in 270Hz steps. To be individually set for each sonde. -#define LED_MODE 2 // 0 - disabled, 1 - flashes when prepairing tx data before transmit, 2 - GPS fix indication -#define LED_PERIOD 5 // time between LED lighting -#define LED_DISABLE_ALT 1000 // disable led when certain altitude is reached, 0 for always enable - /*-----------------------------------------------------------------*/ -// the rest of parameters should not be changed normally +/*----- the rest of parameters should not be changed normally -----*/ +#define DEBUG // debug information on USART1 + +/* 4FSK settings */ #define FSK4_BAUD 100 // Baudrate for horus 4FSK #define FSK4_SPACE_MULTIPLIER 1 // Tone spacing multiplier - 1 for 244Hz, 2 for 488, etc. #define ADF_CLOCK 8000000 // Clock speed of adf7012 chip coming from STM32 (in Hz) (set to HSE 8MHz oscilator) #define FSK4_HEADER_LENGTH 8 // Length in bytes of 4FSK header +/*---------------*/ /* Horus encoding config */ #define INTERLEAVER @@ -49,6 +72,7 @@ #define AscentRateTime 10 // Time of ascent rate mesure // type 1 +// TODO: check needed max values #define DATA_SIZE 35 // Max number of NMEA sentences in one parsing #define SENTENCE_SIZE 82+1 // Max lenght of a NMEA sentence is 82 characters #define MAX_SENTENCE_ELEMENTS 10 // Max number of NMEA sentence elements (no element with number bigger than 9 is used) diff --git a/m20/Core/Inc/main.h b/m20/Core/Inc/main.h index 502a751..ae9a1fe 100644 --- a/m20/Core/Inc/main.h +++ b/m20/Core/Inc/main.h @@ -52,11 +52,14 @@ extern "C" { /* USER CODE BEGIN Includes */ #include "stm32l0xx_it.h" #include "fsk4.h" +#include "morse.h" + +#include /* USER CODE END Includes */ /* Exported types ------------------------------------------------------------*/ /* USER CODE BEGIN ET */ -typedef enum { false, true } bool; + /* USER CODE END ET */ /* Exported constants --------------------------------------------------------*/ diff --git a/m20/Core/Inc/morse.h b/m20/Core/Inc/morse.h new file mode 100644 index 0000000..8d3828b --- /dev/null +++ b/m20/Core/Inc/morse.h @@ -0,0 +1,14 @@ +#ifndef __INC_CW_H_ +#define __INC_CW_H_ + +#include "main.h" + +uint8_t CW_is_active(); +void CW_start_TX(char *buff, uint8_t lenn); +void CW_stop_TX(); +void CW_timer_handler(); +void get_time_table(uint8_t letter); + +uint8_t get_mh(float lat, float lon, uint8_t size, char *buffer); + +#endif \ No newline at end of file diff --git a/m20/Core/Src/fsk4.c b/m20/Core/Src/fsk4.c index e05c658..57ed8ca 100644 --- a/m20/Core/Src/fsk4.c +++ b/m20/Core/Src/fsk4.c @@ -5,7 +5,6 @@ #include "fsk4.h" #include "adf.h" -#include "main.h" #include "config.h" // In this file i will try to prepare procedure for transmitting earlier prepared message using 4fsk @@ -86,11 +85,11 @@ void FSK4_start_TX(char* buff, uint8_t len) { adf_RF_on(QRG_FSK4, PA_FSK4); //turn on radio TX FSK_Active = 1; //change status TIM2->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); // Disable the TIM Counter - uint16_t timer2StartValue = (100000 / FSK4_BAUD) - 1; //timer value calculated according to baud rate 999 for 100bd - TIM2->ARR = timer2StartValue; //set timer counter max value to pre-set value for baudrate (auto-reload register) + uint16_t timer2ReloadValue = (100000 / FSK4_BAUD) - 1; //timer value calculated according to baud rate 999 for 100bd + TIM2->ARR = 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 - FSK4_timer_handler(buff); //force execution of procedure responsible for interrupt handling + FSK4_timer_handler(); //force execution of procedure responsible for interrupt handling } diff --git a/m20/Core/Src/main.c b/m20/Core/Src/main.c index 7a10a11..7c1d3a0 100644 --- a/m20/Core/Src/main.c +++ b/m20/Core/Src/main.c @@ -14,14 +14,24 @@ #elif GPS_TYPE == 2 #include "xm_gps.h" #endif -#include "horus.h" + #include "adf.h" + +#if HORUS_EN == 1 +#include "horus.h" #include "fsk4.h" +#endif + +#if CW_EN == 1 +#include "morse.h" +#endif + #include "lps22hb.h" #include -#ifdef DEBUG #include + +#ifdef DEBUG #include #endif /* USER CODE END Includes */ @@ -50,7 +60,7 @@ bool GpsBufferReady = false; #if GPS_TYPE == 1 NMEA NmeaData; -static uint8_t GPS_fix_ublox[19] = {0xB5, 0x62, 0x06, 0x8A, 0x09, 0x00, 0x01, 0x01, 0x00, 0x00, 0x11, 0x00, 0x11, 0x20, 0x02, 0xDF, 0x04,0x0D, 0x0A}; +static uint8_t GPS_fix_ublox[19] = {0xB5, 0x62, 0x06, 0x8A, 0x09, 0x00, 0x01, 0x01, 0x00, 0x00, 0x11, 0x00, 0x11, 0x20, 0x02, 0xDF, 0x04, 0x0D, 0x0A}; static uint8_t GPS_airborn[19] = {0xB5, 0x62, 0x06, 0x8A, 0x09, 0x00, 0x01, 0x01, 0x00, 0x00, 0x21, 0x00, 0x11, 0x20, 0x07, 0xF4, 0x59, 0x0D, 0x0A}; #elif GPS_TYPE == 2 XMDATA GpsData; @@ -58,10 +68,18 @@ XMDATA GpsData; uint8_t lps_init; +#if HORUS_EN == 1 HorusBinaryPacket HorusPacket; +#endif -char HorusCodedBuffer[100]; -uint16_t HorusCodedLen; +char PacketCodedBuffer[100]; +uint16_t PacketCodedLen; + +uint16_t BatVoltageRaw = 0; + +float LpsTemp = 0; +float LpsPress = 0; +float NTC_Temp = 0; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ @@ -115,13 +133,53 @@ void main_loop(void) #if LED_MODE == 1 LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); #endif + #if HORUS_EN == 1 #ifdef DEBUG printf("\r\nFrame: %d\r\n", HorusPacket.PacketCount); #endif + #endif - // Payload ID - HorusPacket.PayloadID = PAYLOAD_ID; + // LPS22HB sensor + if (lps_init == 0) + { + LpsTemp = LPS22_GetTemp(); + LpsPress = LPS22_GetPress(); + #ifdef DEBUG + printf("temp: %d, press: %d\r\n", (int8_t)round(LPS22_GetTemp()), (uint16_t)round(LPS22_GetPress())); + #endif + } + + // Bat voltage + LL_ADC_REG_SetSequencerChannels(ADC1, LL_ADC_CHANNEL_8); + LL_ADC_REG_StartConversion(ADC1); + while (LL_ADC_IsActiveFlag_EOC(ADC1) == 0){} + BatVoltageRaw = LL_ADC_REG_ReadConversionData12(ADC1); + LL_ADC_ClearFlag_EOS(ADC1); + #ifdef DEBUG + printf("Bat voltage: %d\r\n", BatVoltageRaw); + #endif + // NTC temp reading + LL_GPIO_SetOutputPin(NTC_GPIO_Port, NTC_Pin); + LL_mDelay(2); + + LL_ADC_REG_SetSequencerChannels(ADC1, LL_ADC_CHANNEL_14); + LL_ADC_REG_StartConversion(ADC1); + while (LL_ADC_IsActiveFlag_EOC(ADC1) == 0){} + uint16_t temp_adc_raw = LL_ADC_REG_ReadConversionData12(ADC1); + LL_ADC_ClearFlag_EOS(ADC1); + + LL_GPIO_ResetOutputPin(NTC_GPIO_Port, NTC_Pin); + + // External temp calculating + // Rntc = Vout * R1 / Vin - Vout + float NTC_R = ((temp_adc_raw * 36500) / (4096 - temp_adc_raw)); + NTC_Temp = 1 / (-0.000400644 + (0.000490078 * log(NTC_R)) + (-0.000000720 * pow(log(NTC_R), 3))) - 273.15; + #ifdef DEBUG + printf("NTC: raw: %d, Temp: %d\r\n", temp_adc_raw, (int16_t)round(NTC_Temp * 10.0)); + #endif + + #if HORUS_EN == 1 // GPS type 1 data #if GPS_TYPE == 1 HorusPacket.Hours = NmeaData.Hours; @@ -154,58 +212,41 @@ void main_loop(void) #endif #endif - // LPS22HB sensor - if (lps_init == 0) - { + HorusPacket.BatVoltage = (BatVoltageRaw * 187) / 4549; + HorusPacket.ExtTemp = (int16_t)round(NTC_Temp * 10.0); + + if(lps_init == 0){ HorusPacket.Temp = (int8_t)round(LPS22_GetTemp()); HorusPacket.Press = (uint16_t)round(LPS22_GetPress() * 10.0); } - #ifdef DEBUG - printf("temp: %d, press: %d\r\n", HorusPacket.Temp, HorusPacket.Press); - #endif - - // Bat voltage - LL_ADC_REG_SetSequencerChannels(ADC1, LL_ADC_CHANNEL_8); - LL_ADC_REG_StartConversion(ADC1); - while (LL_ADC_IsActiveFlag_EOC(ADC1) == 0){} - HorusPacket.BatVoltage = (LL_ADC_REG_ReadConversionData12(ADC1) * 187) / 4549; - LL_ADC_ClearFlag_EOS(ADC1); - - #ifdef DEBUG - printf("Bat voltage: %d\r\n", HorusPacket.BatVoltage); - #endif - - // NTC temp reading - LL_GPIO_SetOutputPin(NTC_GPIO_Port, NTC_Pin); - LL_mDelay(2); - - LL_ADC_REG_SetSequencerChannels(ADC1, LL_ADC_CHANNEL_14); - LL_ADC_REG_StartConversion(ADC1); - while (LL_ADC_IsActiveFlag_EOC(ADC1) == 0){} - uint16_t temp_adc_raw = LL_ADC_REG_ReadConversionData12(ADC1); - LL_ADC_ClearFlag_EOS(ADC1); - - LL_GPIO_ResetOutputPin(NTC_GPIO_Port, NTC_Pin); - - // External temp calculating - // Rntc = Vout * R1 / Vin - Vout - float NTC_R = ((temp_adc_raw * 36500) / (4096 - temp_adc_raw)); - float NTC_T = 1 / (-0.000400644 + (0.000490078 * log(NTC_R)) + (-0.000000720 * pow(log(NTC_R), 3))) - 273.15; - HorusPacket.ExtTemp = (int16_t)round(NTC_T * 10.0); - #ifdef DEBUG - printf("NTC: raw: %d, Temp: %d\r\n", temp_adc_raw, HorusPacket.ExtTemp); - #endif - // Horus checksum HorusPacket.Checksum = (uint16_t)crc16((char *)&HorusPacket, sizeof(HorusPacket) - 2); - HorusCodedLen = horus_l2_encode_tx_packet((unsigned char *)HorusCodedBuffer, (unsigned char *)&HorusPacket, sizeof(HorusPacket)); + PacketCodedLen = horus_l2_encode_tx_packet((unsigned char *)PacketCodedBuffer, (unsigned char *)&HorusPacket, sizeof(HorusPacket)); // Transmit - FSK4_start_TX(HorusCodedBuffer, HorusCodedLen); + FSK4_start_TX(PacketCodedBuffer, PacketCodedLen); + #endif + + #if CW_EN == 1 + PacketCodedLen = 0; + PacketCodedLen+=strlen(CALLSIGN); + strncpy(PacketCodedBuffer, CALLSIGN, PacketCodedLen); + PacketCodedBuffer[PacketCodedLen] = 32; + PacketCodedLen++; + #if GPS_TYPE == 1 + PacketCodedLen += get_mh(NmeaData.Lat, NmeaData.Lon, MORSE_GRID_SIZE, PacketCodedBuffer+PacketCodedLen); + #elif GPS_TYPE == 2 + PacketCodedLen = get_mh(GpsData.Lat, GpsData.Lon, MORSE_GRID_SIZE, PacketCodedBuffer); + #endif + + CW_start_TX(PacketCodedBuffer, PacketCodedLen); + #endif // Packet counter + #if HORUS_EN == 1 HorusPacket.PacketCount++; - + #endif + // LED #if LED_MODE == 1 LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); @@ -302,6 +343,11 @@ int main(void) MX_IWDG_Init(); MX_TIM6_Init(); /* USER CODE BEGIN 2 */ + // Payload ID + #if HORUS_EN == 1 + HorusPacket.PayloadID = PAYLOAD_ID; + #endif + LL_GPIO_SetOutputPin(POWER_ON_GPIO_Port, POWER_ON_Pin); LL_GPIO_SetOutputPin(GPS_ON_GPIO_Port, GPS_ON_Pin); LL_GPIO_SetOutputPin(RADIO_EN_GPIO_Port, RADIO_EN_Pin); @@ -325,7 +371,7 @@ int main(void) LL_LPUART_EnableIT_RXNE(LPUART1); LL_LPUART_Enable(LPUART1); - #if GPS_TYPE == 1 + #if GPS_TYPE == 1 LL_mDelay(100); for (uint8_t ig = 0; ig < 19; ig++){ while (!LL_LPUART_IsActiveFlag_TXE(LPUART1)){} diff --git a/m20/Core/Src/morse.c b/m20/Core/Src/morse.c new file mode 100644 index 0000000..2f690ff --- /dev/null +++ b/m20/Core/Src/morse.c @@ -0,0 +1,184 @@ +#include "morse.h" +#include "config.h" +#include "main.h" +#include "adf.h" + +#include +#include + +//morse code table. table - 0 to Z as per ascii - dec 48 +//first digit - dash"-" coded as 1, dot "." coded as 0, unused bits as 0 +//nd digit - number of dash-dots in symbol + +const uint8_t morse_code[][2] = { + { 0b11111000, 5}, //0 + { 0b01111000, 5}, //1 + { 0b00111000, 5}, //2 + { 0b00011000, 5}, //3 + { 0b00001000, 5}, //4 + { 0b00000000, 5}, //5 + { 0b10000000, 5}, //6 + { 0b11000000, 5}, //7 + { 0b11100000, 5}, //8 + { 0b11110000, 5}, //9 + { 0b01000000, 2}, //A + { 0b10000000, 4}, //B + { 0b10100000, 4}, //C + { 0b10000000, 3}, //D + { 0b00000000, 1}, //E + { 0b00100000, 4}, //F + { 0b11000000, 3}, //G + { 0b00000000, 4}, //H + { 0b00000000, 2}, //I + { 0b01110000, 4}, //J + { 0b10100000, 3}, //K + { 0b01000000, 4}, //L + { 0b11000000, 2}, //M + { 0b10000000, 2}, //N + { 0b11100000, 3}, //O + { 0b01100000, 4}, //P + { 0b11010000, 4}, //Q + { 0b01000000, 3}, //R + { 0b00000000, 3}, //S + { 0b10000000, 1}, //T + { 0b00100000, 3}, //U + { 0b00010000, 4}, //V + { 0b01100000, 3}, //W + { 0b10010000, 4}, //X + { 0b10110000, 4}, //Y + { 0b11000000, 4}, //Z + { 0b10101101, 8}, // [ - but it is CQ + { 0b10000000, 4} // | - but it is DE +}; + +uint8_t CW_active = 0; +char *CW_buffer; +uint8_t CW_buffer_len = 0; + +uint8_t CW_buffer_pos = 0; +uint8_t wait_counter = 0; + +uint8_t time_table[20]; // TODO check max len +uint8_t time_table_len = 0; +uint8_t time_table_pos = 0; + +uint16_t CW_timer2ReloadValueMultip; + +uint8_t CW_is_active(){ + return CW_active; +} + +uint8_t get_symbol_code(uint8_t letter){ + uint8_t symbol_code = 255; + uint8_t symbol = letter; + + if (symbol == 32) return symbol; + + if ((symbol > 96 ) && (symbol < 123)) //we have lower case + { symbol_code= symbol - 32;} //make it into upper case + + if ((symbol > 47) && (symbol < 59)) // digits + { symbol_code = symbol-48;} + if ((symbol > 64 ) && (symbol < 93)) // letters + { symbol_code = symbol - 55;} + + return symbol_code; +} + +void get_time_table(uint8_t letter){ + uint8_t symbol_code = get_symbol_code(letter); + uint8_t symbol_len = morse_code[symbol_code][1]; + uint8_t symbol = morse_code[symbol_code][0]; + uint8_t pos = 0; + if(symbol_code == 32){ + time_table[pos] = MORSE_UNITS_SPACE; + pos++; + }else{ + for(uint8_t cnt = 0; cntCNT = 0; + adf_RF_off(); + if(time_table_pos == time_table_len){ + time_table_pos = 0; + if(time_table_len != 0){ + CW_buffer_pos++; + } + if(CW_buffer_pos == CW_buffer_len){ + CW_active = 0; + }else{ + get_time_table(CW_buffer[CW_buffer_pos]); + } + } + if(CW_active == 1){ + if((time_table[time_table_pos] & 128) == 128){ + adf_RF_on(QRG_CW, PA_CW); + } + TIM2->ARR = CW_timer2ReloadValueMultip * (time_table[time_table_pos] & 127); // change timer reload value according to wait time + time_table_pos++; + } +} + +void CW_start_TX(char *buff, uint8_t lenn){ + CW_buffer = buff; + CW_buffer_len = lenn; + + time_table_len = 0; + CW_buffer_pos = 0; + time_table_pos = 0; + + wait_counter = 0; + + CW_active = 1; + TIM2->CR1 &= (uint16_t)(~((uint16_t)TIM_CR1_CEN)); // Disable the TIM Counter + CW_timer2ReloadValueMultip = (MORSE_MS * 100) - 1; // initial timer value calculated according to MORSE_MS + TIM2->ARR = CW_timer2ReloadValueMultip; //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 + CW_timer_handler(); +} + +void CW_stop_TX(){ + TIM2->DIER &= ~(TIM_DIER_UIE); /* Disable the interrupt */ + adf_RF_off(); // ensure off + CW_active = 0; +} + +// based on https://github.com/sp6q/maidenhead/ +uint8_t get_mh(float lat, float lon, uint8_t size, char *locator) { + float LON_F[]={20,2.0,0.083333,0.008333,0.00034720833333}; + float LAT_F[]={10,1.0,0.0416665,0.004166,0.00017358333333}; + uint8_t i; + lon += 180; + lat += 90; + + if (size <= 0 || size > 5) size = 3; + + for (i = 0; i < size; i++){ + if (i % 2 == 1) { + locator[i*2] = (char) (lon/LON_F[i] + '0'); + locator[i*2+1] = (char) (lat/LAT_F[i] + '0'); + } else { + locator[i*2] = (char) ((uint8_t) (lon/LON_F[i]) + 65); + locator[i*2+1] = (char) ((uint8_t) (lat/LAT_F[i] + 65)); + } + lon = fmod(lon, LON_F[i]); + lat = fmod(lat, LAT_F[i]); + } + locator[i*2]=0; + return size * 2; +} \ No newline at end of file diff --git a/m20/Core/Src/stm32l0xx_it.c b/m20/Core/Src/stm32l0xx_it.c index 785bac4..7ae7f86 100644 --- a/m20/Core/Src/stm32l0xx_it.c +++ b/m20/Core/Src/stm32l0xx_it.c @@ -22,6 +22,7 @@ #include "stm32l0xx_it.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ +#include "config.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -148,9 +149,16 @@ void TIM2_IRQHandler(void) 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 } /* USER CODE END TIM2_IRQn 0 */ /* USER CODE BEGIN TIM2_IRQn 1 */ diff --git a/m20/Makefile b/m20/Makefile index 9653be2..16705e7 100644 --- a/m20/Makefile +++ b/m20/Makefile @@ -47,6 +47,8 @@ Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_exti.c \ Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_usart.c \ Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_spi.c \ Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_tim.c \ +Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_adc.c \ +Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c \ Core/Src/system_stm32l0xx.c \ Core/Src/sysmem.c \ Core/Src/syscalls.c \ @@ -56,8 +58,7 @@ Core/Src/horus.c \ Core/Src/lps22hb.c \ Core/Src/nmea.c \ Core/Src/xm_gps.c \ -Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_adc.c \ -Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c +Core/Src/morse.c # ASM sources ASM_SOURCES = \ @@ -137,7 +138,7 @@ C_INCLUDES = \ # compile gcc flags ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections# -DNDEBUG -flto +CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -DNDEBUG -flto ifeq ($(DEBUG), 1) CFLAGS += -g -gdwarf-2