From 4d097e8a663db0c98bda391dd0e346632faffdb7 Mon Sep 17 00:00:00 2001 From: Rob Riggs Date: Sun, 3 Jan 2021 15:55:15 -0600 Subject: [PATCH] More TNC3 codebase alignment. --- .cproject | 678 ++++++++++++++++++------------------ .project | 7 +- Nucleo_L432KC_TNC.ioc | 2 +- STM32L432KC_FLASH.ld | 4 +- Src/main.c | 30 +- TNC/AFSKModulator.cpp | 5 + TNC/Afsk1200Demodulator.hpp | 1 - TNC/IOEventTask.h | 3 + TNC/KissHardware.cpp | 16 +- TNC/KissHardware.hpp | 35 +- TNC/M17Demodulator.h | 75 +++- TNC/M17Encoder.cpp | 2 +- TNC/NullPort.hpp | 7 +- TNC/SerialPort.cpp | 7 +- 14 files changed, 479 insertions(+), 393 deletions(-) diff --git a/.cproject b/.cproject index 9cfe922..4995eee 100644 --- a/.cproject +++ b/.cproject @@ -1,561 +1,561 @@ - + - + - - - - - - - - - - + + + + + + + + + + - + - + - + - - - - - - + + + + + + - - - + + + - + - - - - - - - - - - + + + + + + + + + + - + - + - + - - - - - - + + + + + + - - - + + + - + - - - - + + + + - - - + + - + - - - - + + + + - - - + + - + - + - + - + - + - + - + - - - + + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + diff --git a/.project b/.project index c4dc607..5f9314d 100644 --- a/.project +++ b/.project @@ -1,12 +1,13 @@ Nucleo_L432KC_TNC - + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, ?children? @@ -14,7 +15,7 @@ ?name? - + org.eclipse.cdt.make.core.append_environment @@ -22,7 +23,7 @@ org.eclipse.cdt.make.core.buildArguments - + org.eclipse.cdt.make.core.buildCommand diff --git a/Nucleo_L432KC_TNC.ioc b/Nucleo_L432KC_TNC.ioc index a086dfd..4e06cfa 100644 --- a/Nucleo_L432KC_TNC.ioc +++ b/Nucleo_L432KC_TNC.ioc @@ -104,7 +104,7 @@ FREERTOS.FootprintOK=true FREERTOS.HEAP_NUMBER=4 FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_TICKLESS_IDLE,MEMORY_ALLOCATION,configTOTAL_HEAP_SIZE,HEAP_NUMBER,configUSE_TIMERS,Queues01,configCHECK_FOR_STACK_OVERFLOW FREERTOS.MEMORY_ALLOCATION=2 -FREERTOS.Queues01=ioEventQueue,16,uint32_t,0,Static,ioEventQueueBuffer,ioEventQueueControlBlock;serialInputQueue,16,uint32_t,0,Static,serialInputQueueBuffer,serialInputQueueControlBlock;serialOutputQueue,16,uint32_t,0,Static,serialOutputQueueBuffer,serialOutputQueueControlBlock;audioInputQueue,8,uint8_t,0,Static,audioInputQueueBuffer,audioInputQueueControlBlock;hdlcInputQueue,3,uint32_t,0,Static,hdlcInputQueueBuffer,hdlcInputQueueControlBlock;hdlcOutputQueue,3,uint32_t,0,Static,hdlcOutputQueueBuffer,hdlcOutputQueueControlBlock;dacOutputQueue,128,uint8_t,0,Static,dacOutputQueueBuffer,dacOutputQueueControlBlock;adcInputQueue,3,uint32_t,0,Static,adcInputQueueBuffer,adcInputQueueControlBlock +FREERTOS.Queues01=ioEventQueue,16,uint32_t,0,Static,ioEventQueueBuffer,ioEventQueueControlBlock;serialInputQueue,16,uint32_t,0,Static,serialInputQueueBuffer,serialInputQueueControlBlock;serialOutputQueue,16,uint32_t,0,Static,serialOutputQueueBuffer,serialOutputQueueControlBlock;audioInputQueue,8,uint32_t,0,Static,audioInputQueueBuffer,audioInputQueueControlBlock;hdlcInputQueue,3,uint32_t,0,Static,hdlcInputQueueBuffer,hdlcInputQueueControlBlock;hdlcOutputQueue,3,uint32_t,0,Static,hdlcOutputQueueBuffer,hdlcOutputQueueControlBlock;dacOutputQueue,128,uint8_t,0,Static,dacOutputQueueBuffer,dacOutputQueueControlBlock;adcInputQueue,3,uint32_t,0,Static,adcInputQueueBuffer,adcInputQueueControlBlock FREERTOS.Tasks01=defaultTask,-3,256,startDefaultTask,Default,NULL,Static,defaultTaskBuffer,defaultTaskControlBlock;ioEventTask,-2,384,startIOEventTask,As external,NULL,Static,ioEventTaskBuffer,ioEventTaskControlBlock;audioInputTask,1,512,startAudioInputTask,As external,NULL,Static,audioInputTaskBuffer,audioInputTaskControlBlock;modulatorTask,1,384,startModulatorTask,As external,NULL,Static,modulatorTaskBuffer,modulatorTaskControlBlock FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2 FREERTOS.configTOTAL_HEAP_SIZE=4096 diff --git a/STM32L432KC_FLASH.ld b/STM32L432KC_FLASH.ld index 51377b7..e5a5414 100644 --- a/STM32L432KC_FLASH.ld +++ b/STM32L432KC_FLASH.ld @@ -4,8 +4,8 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ _estack = 0x2000C000; /* end of RAM */ /* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x800; /* required amount of stack */ +_Min_Heap_Size = 0x1000; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ /* Specify the memory areas */ MEMORY diff --git a/Src/main.c b/Src/main.c index eaa90d2..4668a5e 100644 --- a/Src/main.c +++ b/Src/main.c @@ -90,7 +90,7 @@ osThreadId ioEventTaskHandle; uint32_t ioEventTaskBuffer[ 384 ]; osStaticThreadDef_t ioEventTaskControlBlock; osThreadId audioInputTaskHandle; -uint32_t audioInputTaskBuffer[ 768 ]; +uint32_t audioInputTaskBuffer[ 640 ]; osStaticThreadDef_t audioInputTaskControlBlock; osThreadId modulatorTaskHandle; uint32_t modulatorTaskBuffer[ 384 ]; @@ -105,7 +105,7 @@ osMessageQId serialOutputQueueHandle; uint8_t serialOutputQueueBuffer[ 16 * sizeof( uint32_t ) ]; osStaticMessageQDef_t serialOutputQueueControlBlock; osMessageQId audioInputQueueHandle; -uint8_t audioInputQueueBuffer[ 8 * sizeof( uint8_t ) ]; +uint8_t audioInputQueueBuffer[ 8 * sizeof( uint32_t ) ]; osStaticMessageQDef_t audioInputQueueControlBlock; osMessageQId hdlcInputQueueHandle; uint8_t hdlcInputQueueBuffer[ 3 * sizeof( uint32_t ) ]; @@ -148,6 +148,7 @@ void startDefaultTask(void const * argument); extern void startIOEventTask(void const * argument); extern void startAudioInputTask(void const * argument); extern void startModulatorTask(void const * argument); +void encode_serial_number(void); void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); @@ -249,6 +250,8 @@ int main(void) /* USER CODE BEGIN RTOS_SEMAPHORES */ /* add semaphores, ... */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wwrite-strings" // cmsis-os is not const-correct. /* USER CODE END RTOS_SEMAPHORES */ /* USER CODE BEGIN RTOS_TIMERS */ @@ -265,7 +268,7 @@ int main(void) ioEventTaskHandle = osThreadCreate(osThread(ioEventTask), NULL); /* definition and creation of audioInputTask */ - osThreadStaticDef(audioInputTask, startAudioInputTask, osPriorityAboveNormal, 0, 768, audioInputTaskBuffer, &audioInputTaskControlBlock); + osThreadStaticDef(audioInputTask, startAudioInputTask, osPriorityAboveNormal, 0, 640, audioInputTaskBuffer, &audioInputTaskControlBlock); audioInputTaskHandle = osThreadCreate(osThread(audioInputTask), NULL); /* definition and creation of modulatorTask */ @@ -290,7 +293,7 @@ int main(void) serialOutputQueueHandle = osMessageCreate(osMessageQ(serialOutputQueue), NULL); /* definition and creation of audioInputQueue */ - osMessageQStaticDef(audioInputQueue, 8, uint8_t, audioInputQueueBuffer, &audioInputQueueControlBlock); + osMessageQStaticDef(audioInputQueue, 8, uint32_t, audioInputQueueBuffer, &audioInputQueueControlBlock); audioInputQueueHandle = osMessageCreate(osMessageQ(audioInputQueue), NULL); /* definition and creation of hdlcInputQueue */ @@ -311,6 +314,8 @@ int main(void) /* USER CODE BEGIN RTOS_QUEUES */ /* add queues, ... */ +#pragma GCC diagnostic pop + if (HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_2, DAC_ALIGN_12B_R, 1024) != HAL_OK) Error_Handler(); if (HAL_DAC_Start(&hdac1, DAC_CHANNEL_2) != HAL_OK) Error_Handler(); if (HAL_OPAMP_SelfCalibrate(&hopamp1) != HAL_OK) Error_Handler(); @@ -325,7 +330,7 @@ int main(void) Error_Handler(); } -#if 0 +#if 1 // Do not erase SRAM2 during reset. if ((obInit.USERConfig & FLASH_OPTR_SRAM2_RST) == RESET) { obInit.OptionType = OPTIONBYTE_USER; @@ -518,7 +523,7 @@ static void MX_ADC1_Init(void) */ sConfig.Channel = ADC_CHANNEL_8; sConfig.Rank = ADC_REGULAR_RANK_1; - sConfig.SamplingTime = ADC_SAMPLETIME_6CYCLES_5; + sConfig.SamplingTime = ADC_SAMPLETIME_12CYCLES_5; sConfig.SingleDiff = ADC_SINGLE_ENDED; sConfig.OffsetNumber = ADC_OFFSET_NONE; sConfig.Offset = 0; @@ -591,7 +596,7 @@ static void MX_I2C3_Init(void) { hi2c3.Instance = I2C3; - hi2c3.Init.Timing = 0x00300F33; + hi2c3.Init.Timing = 0x00702991; hi2c3.Init.OwnAddress1 = 0; hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; @@ -632,7 +637,7 @@ static void MX_OPAMP1_Init(void) hopamp1.Init.PowerSupplyRange = OPAMP_POWERSUPPLY_HIGH; hopamp1.Init.Mode = OPAMP_PGA_MODE; hopamp1.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_IO0; - hopamp1.Init.InvertingInput = OPAMP_INVERTINGINPUT_IO0; + hopamp1.Init.InvertingInput = OPAMP_INVERTINGINPUT_CONNECT_NO; // Manually changed. hopamp1.Init.PgaGain = OPAMP_PGA_GAIN_2; hopamp1.Init.PowerMode = OPAMP_POWERMODE_NORMAL; hopamp1.Init.UserTrimming = OPAMP_TRIMMING_FACTORY; @@ -997,7 +1002,7 @@ void startDefaultTask(void const * argument) /* Infinite loop */ for(;;) { - osDelay(1); + osDelay(osWaitForever); } /* USER CODE END 5 */ } @@ -1036,9 +1041,10 @@ void _Error_Handler(char *file, int line) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ - while(1) - { - } + snprintf(error_message, sizeof(error_message), "Error: %s:%d\r\n", file, line); + error_message[sizeof(error_message) - 1] = 0; + + NVIC_SystemReset(); /* USER CODE END Error_Handler_Debug */ } diff --git a/TNC/AFSKModulator.cpp b/TNC/AFSKModulator.cpp index 3e8907a..3fb5271 100644 --- a/TNC/AFSKModulator.cpp +++ b/TNC/AFSKModulator.cpp @@ -11,8 +11,13 @@ void AFSKModulator::init(const kiss::Hardware& hw) SysClock48(); +#ifndef NUCLEOTNC // Configure 48MHz clock for 26.4ksps. + htim7.Init.Period = 1817; +#else + // Using an 80MHz clock on NucleoTNC. htim7.Init.Period = 3029; +#endif if (HAL_TIM_Base_Init(&htim7) != HAL_OK) { ERROR("htim7 init failed"); diff --git a/TNC/Afsk1200Demodulator.hpp b/TNC/Afsk1200Demodulator.hpp index f321ef4..cf00443 100644 --- a/TNC/Afsk1200Demodulator.hpp +++ b/TNC/Afsk1200Demodulator.hpp @@ -95,7 +95,6 @@ struct Afsk1200Demodulator : IDemodulator sConfig.Offset = 0; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) CxxErrorHandler(); - #ifndef NUCLEOTNC startADC(1817, ADC_BLOCK_SIZE); #else diff --git a/TNC/IOEventTask.h b/TNC/IOEventTask.h index a357bb6..97af720 100644 --- a/TNC/IOEventTask.h +++ b/TNC/IOEventTask.h @@ -12,6 +12,9 @@ extern "C" { void startIOEventTask(void const* argument); extern osMessageQId ioEventQueueHandle; +#ifndef NUCLEOTNC +extern volatile int cdc_connected; +#endif #ifdef __cplusplus } diff --git a/TNC/KissHardware.cpp b/TNC/KissHardware.cpp index 90748f5..9b39611 100644 --- a/TNC/KissHardware.cpp +++ b/TNC/KissHardware.cpp @@ -9,6 +9,9 @@ #include "ModulatorTask.hpp" #include "Modulator.hpp" #include "HDLCEncoder.hpp" +#ifndef NUCLEOTNC +#include "KissHardware.h" +#endif #include #include @@ -630,18 +633,19 @@ bool Hardware::load() { INFO("Loading settings from EEPROM"); - Hardware tmp; + auto tmp = std::make_unique(); - memset(&tmp, 0, sizeof(Hardware)); + if (!tmp) return false; + memset(tmp.get(), 0, sizeof(Hardware)); - if (!I2C_Storage::load(tmp)) { + if (!I2C_Storage::load(*tmp)) { ERROR("EEPROM read failed"); return false; } - if (tmp.crc_ok()) + if (tmp->crc_ok()) { - memcpy(this, &tmp, sizeof(Hardware)); + memcpy(this, tmp.get(), sizeof(Hardware)); return true; } ERROR("EEPROM CRC error"); @@ -657,7 +661,7 @@ bool Hardware::store() const return false; } - INFO("EEPROM saved checksum is: %04x (crc = %04x)", checksum, crc()); + INFO("EEPROM saved checksum is: %04hx (crc = %04hx)", checksum, crc()); return crc_ok(); } diff --git a/TNC/KissHardware.hpp b/TNC/KissHardware.hpp index 1d37a48..ecd1800 100644 --- a/TNC/KissHardware.hpp +++ b/TNC/KissHardware.hpp @@ -195,7 +195,11 @@ constexpr uint8_t MODEM_TYPE_M17 = 5; #define KISS_OPTION_RX_REV_POLARITY 0x40 // Reverse Polarity on RX when set. #define KISS_OPTION_TX_REV_POLARITY 0x80 // Reverse Polarity on TX when set. +#ifndef NUCLEOTNC +const char TOCALL[] = "APML30"; // Update for every feature change. +#else const char TOCALL[] = "APML00"; // Update for every feature change. +#endif } // hardware @@ -203,11 +207,11 @@ const size_t CALLSIGN_LEN = 8; using call_t = std::array; struct Alias { - call_t call; ///< Callsign. Pad unused with NUL. - bool set; ///< Alias is configured. - bool use; ///< Use this alias. - bool insert_id; ///< Tracing. - bool preempt; ///< Allow out of order pathing. + call_t call; ///< Callsign. Pad unused with NUL. + bool set; ///< Alias is configured. + bool use; ///< Use this alias. + bool insert_id; ///< Tracing. + bool preempt; ///< Allow out of order pathing. uint8_t hops; }; // size = 10 @@ -254,19 +258,19 @@ struct Hardware hardware::MODEM_TYPE_M17 }; - uint8_t txdelay; ///< How long in 10mS units to wait for TX to settle before starting data - uint8_t ppersist; ///< Likelihood of taking the channel when its not busy - uint8_t slot; ///< How long in 10mS units to wait between sampling the channel to see if free + uint8_t txdelay; ///< How long in 10mS units to wait for TX to settle before starting data + uint8_t ppersist; ///< Likelihood of taking the channel when its not busy + uint8_t slot; ///< How long in 10mS units to wait between sampling the channel to see if free uint8_t txtail; ///< How long in 10mS units to wait after the data before keying off the transmitter uint8_t duplex; ///< Ignore current channel activity - just key up - uint8_t modem_type; ///< Modem type. - uint16_t output_gain; ///< output volume (0-256). - uint16_t input_gain; ///< input volume (0-256). - int8_t tx_twist; ///< 0 to 100 (50 = even). - int8_t rx_twist; ///< 0, 3, 6 dB - uint8_t log_level; ///< Log level (0 - 4 : debug - severe). + uint8_t modem_type; ///< Modem type. + uint16_t output_gain; ///< output volume (0-256). + uint16_t input_gain; ///< input volume (0-256). + int8_t tx_twist; ///< 0 to 100 (50 = even). + int8_t rx_twist; ///< 0, 3, 6 dB + uint8_t log_level; ///< Log level (0 - 4 : debug - severe). - uint16_t options; ///< boolean options + uint16_t options; ///< boolean options /// Callsign. Pad unused with NUL. call_t mycall; @@ -427,5 +431,4 @@ void reply16(uint8_t cmd, uint16_t result) __attribute__((noinline)); void reply(uint8_t cmd, const uint8_t* data, uint16_t len) __attribute__((noinline)); - }}} // mobilinkd::tnc::kiss diff --git a/TNC/M17Demodulator.h b/TNC/M17Demodulator.h index d4240dc..9146558 100644 --- a/TNC/M17Demodulator.h +++ b/TNC/M17Demodulator.h @@ -149,7 +149,7 @@ struct M17Demodulator : IDemodulator case DemodState::FRAME_SYNC: if (!locked) { - DEBUG("state: %d, dt: %5d, evm: %5d, evma: %5d, dev: %5d, freq: %5d, locked: %d, ber: %d", + INFO("state: %d, dt: %5d, evm: %5d, evma: %5d, dev: %5d, freq: %5d, locked: %d, ber: %d", int(demodState), int(dt * 10000), int(evm * 1000), int(evma * 1000), int((1.0 / estimated_deviation) * 1000), int(estimated_frequency_offset * 1000), @@ -206,7 +206,7 @@ struct M17Demodulator : IDemodulator } if ((count++ % 192) == 0) { - DEBUG("state: %d, dt: %5d, evm: %5d, evma: %5d, dev: %5d, freq: %5d, locked: %d, ber: %d", + INFO("state: %d, dt: %5d, evm: %5d, evma: %5d, dev: %5d, freq: %5d, locked: %d, ber: %d", int(demodState), int(dt * 10000), int(evm * 1000), int(evma * 1000), int((1.0 / estimated_deviation) * 1000), int(estimated_frequency_offset * 1000), @@ -256,7 +256,78 @@ struct M17Demodulator : IDemodulator uint32_t readBatteryLevel() override { +#ifndef NUCLEOTNC + DEBUG("enter M17Demodulator::readBatteryLevel"); + + ADC_ChannelConfTypeDef sConfig; + + sConfig.Channel = ADC_CHANNEL_VREFINT; + sConfig.Rank = ADC_REGULAR_RANK_1; + sConfig.SingleDiff = ADC_SINGLE_ENDED; + sConfig.SamplingTime = ADC_SAMPLETIME_247CYCLES_5; + sConfig.OffsetNumber = ADC_OFFSET_NONE; + sConfig.Offset = 0; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + CxxErrorHandler(); + + htim6.Init.Period = 48000; + if (HAL_TIM_Base_Init(&htim6) != HAL_OK) CxxErrorHandler(); + + if (HAL_TIM_Base_Start(&htim6) != HAL_OK) + CxxErrorHandler(); + + if (HAL_ADC_Start(&hadc1) != HAL_OK) CxxErrorHandler(); + if (HAL_ADC_PollForConversion(&hadc1, 3) != HAL_OK) CxxErrorHandler(); + auto vrefint = HAL_ADC_GetValue(&hadc1); + if (HAL_ADC_Stop(&hadc1) != HAL_OK) CxxErrorHandler(); + + // Disable battery charging while measuring battery voltage. + auto usb_ce = gpio::USB_CE::get(); + gpio::USB_CE::on(); + + gpio::BAT_DIVIDER::off(); + HAL_Delay(1); + + sConfig.Channel = ADC_CHANNEL_15; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + CxxErrorHandler(); + + uint32_t vbat = 0; + if (HAL_ADC_Start(&hadc1) != HAL_OK) CxxErrorHandler(); + for (size_t i = 0; i != 8; ++i) + { + if (HAL_ADC_PollForConversion(&hadc1, 1) != HAL_OK) CxxErrorHandler(); + vbat += HAL_ADC_GetValue(&hadc1); + } + + vbat /= 8; + + if (HAL_ADC_Stop(&hadc1) != HAL_OK) CxxErrorHandler(); + if (HAL_TIM_Base_Stop(&htim6) != HAL_OK) + CxxErrorHandler(); + + gpio::BAT_DIVIDER::on(); + + // Restore battery charging state. + if (!usb_ce) gpio::USB_CE::off(); + + INFO("Vref = %lu", vrefint); + INFO("Vbat = %lu (raw)", vbat); + + // Order of operations is important to avoid underflow. + vbat *= 6600; + vbat /= (VREF + 1); + + uint32_t vref = ((vrefint * 3300) + (VREF / 2)) / VREF; + + INFO("Vref = %lumV", vref) + INFO("Vbat = %lumV", vbat); + + DEBUG("exit M17Demodulator::readBatteryLevel"); + return vbat; +#else return 0; +#endif } }; diff --git a/TNC/M17Encoder.cpp b/TNC/M17Encoder.cpp index 1750b17..85857dd 100644 --- a/TNC/M17Encoder.cpp +++ b/TNC/M17Encoder.cpp @@ -113,7 +113,7 @@ void M17Encoder::run() } evt = osMessagePeek(input_queue, 0); - back2back = evt.status == osEventMessage; + back2back = (evt.status == osEventMessage); if (!back2back) { osMessagePut(audioInputQueueHandle, tnc::audio::DEMODULATOR, diff --git a/TNC/NullPort.hpp b/TNC/NullPort.hpp index 961f108..48941b6 100644 --- a/TNC/NullPort.hpp +++ b/TNC/NullPort.hpp @@ -30,18 +30,17 @@ struct NullPort : PortInterface open_ = false; } virtual osMessageQId queue() const { return 0; } - virtual bool write(const uint8_t* data, uint32_t size, uint8_t type, - uint32_t timeout) + virtual bool write(const uint8_t*, uint32_t, uint8_t, uint32_t) { return true; } - virtual bool write(const uint8_t* data, uint32_t size, uint32_t timeout) + virtual bool write(const uint8_t*, uint32_t, uint32_t) { return true; } virtual bool write(hdlc::IoFrame* frame, uint32_t = osWaitForever) { - hdlc::ioFramePool().release(frame); + hdlc::release(frame); return true; } diff --git a/TNC/SerialPort.cpp b/TNC/SerialPort.cpp index f17920c..d270ed5 100644 --- a/TNC/SerialPort.cpp +++ b/TNC/SerialPort.cpp @@ -3,6 +3,7 @@ #ifndef NUCLEOTNC #include "Log.h" +#include "bm78.h" #endif #include "SerialPort.hpp" #include "PortInterface.h" @@ -128,10 +129,6 @@ void startSerialTask(void const* arg) HAL_UART_Receive_DMA(&huart_serial, rxBuffer, RX_BUFFER_SIZE * 2); __HAL_UART_ENABLE_IT(&huart_serial, UART_IT_IDLE); - uint32_t last_sent_time = osKernelSysTick(); - uint32_t current_sent_time = 0; - bool paused = false; - while (true) { osEvent evt = osMessageGet(serialPort->queue(), osWaitForever); @@ -180,14 +177,12 @@ void startSerialTask(void const* arg) reinterpret_cast(frame), osWaitForever) != osOK) { - WARN("Failed to send serial frame"); hdlc::release(frame); } if (hdlc::ioFramePool().size() < (hdlc::ioFramePool().capacity() / 4)) { UART_DMAPauseReceive(&huart_serial); - WARN("Pausing UART RX"); while (hdlc::ioFramePool().size() < (hdlc::ioFramePool().capacity() / 2)) { osThreadYield();