kopia lustrzana https://github.com/mobilinkd/NucleoTNC
More TNC3 codebase alignment.
rodzic
acb142cecb
commit
4d097e8a66
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
<cconfiguration id="com.atollic.truestudio.exe.debug.1518366166">
|
<cconfiguration id="com.atollic.truestudio.exe.debug.1518366166">
|
||||||
|
|
7
.project
7
.project
|
@ -1,12 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>Nucleo_L432KC_TNC</name>
|
<name>Nucleo_L432KC_TNC</name>
|
||||||
<comment />
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||||
|
<triggers>clean,full,incremental,</triggers>
|
||||||
<arguments>
|
<arguments>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>?children?</key>
|
<key>?children?</key>
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>?name?</key>
|
<key>?name?</key>
|
||||||
<value />
|
<value></value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||||
|
@ -22,7 +23,7 @@
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||||
<value />
|
<value></value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||||
|
|
|
@ -104,7 +104,7 @@ FREERTOS.FootprintOK=true
|
||||||
FREERTOS.HEAP_NUMBER=4
|
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.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.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.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.configCHECK_FOR_STACK_OVERFLOW=2
|
||||||
FREERTOS.configTOTAL_HEAP_SIZE=4096
|
FREERTOS.configTOTAL_HEAP_SIZE=4096
|
||||||
|
|
|
@ -4,8 +4,8 @@ ENTRY(Reset_Handler)
|
||||||
/* Highest address of the user mode stack */
|
/* Highest address of the user mode stack */
|
||||||
_estack = 0x2000C000; /* end of RAM */
|
_estack = 0x2000C000; /* end of RAM */
|
||||||
/* Generate a link error if heap and stack don't fit into RAM */
|
/* Generate a link error if heap and stack don't fit into RAM */
|
||||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
_Min_Heap_Size = 0x1000; /* required amount of heap */
|
||||||
_Min_Stack_Size = 0x800; /* required amount of stack */
|
_Min_Stack_Size = 0x400; /* required amount of stack */
|
||||||
|
|
||||||
/* Specify the memory areas */
|
/* Specify the memory areas */
|
||||||
MEMORY
|
MEMORY
|
||||||
|
|
30
Src/main.c
30
Src/main.c
|
@ -90,7 +90,7 @@ osThreadId ioEventTaskHandle;
|
||||||
uint32_t ioEventTaskBuffer[ 384 ];
|
uint32_t ioEventTaskBuffer[ 384 ];
|
||||||
osStaticThreadDef_t ioEventTaskControlBlock;
|
osStaticThreadDef_t ioEventTaskControlBlock;
|
||||||
osThreadId audioInputTaskHandle;
|
osThreadId audioInputTaskHandle;
|
||||||
uint32_t audioInputTaskBuffer[ 768 ];
|
uint32_t audioInputTaskBuffer[ 640 ];
|
||||||
osStaticThreadDef_t audioInputTaskControlBlock;
|
osStaticThreadDef_t audioInputTaskControlBlock;
|
||||||
osThreadId modulatorTaskHandle;
|
osThreadId modulatorTaskHandle;
|
||||||
uint32_t modulatorTaskBuffer[ 384 ];
|
uint32_t modulatorTaskBuffer[ 384 ];
|
||||||
|
@ -105,7 +105,7 @@ osMessageQId serialOutputQueueHandle;
|
||||||
uint8_t serialOutputQueueBuffer[ 16 * sizeof( uint32_t ) ];
|
uint8_t serialOutputQueueBuffer[ 16 * sizeof( uint32_t ) ];
|
||||||
osStaticMessageQDef_t serialOutputQueueControlBlock;
|
osStaticMessageQDef_t serialOutputQueueControlBlock;
|
||||||
osMessageQId audioInputQueueHandle;
|
osMessageQId audioInputQueueHandle;
|
||||||
uint8_t audioInputQueueBuffer[ 8 * sizeof( uint8_t ) ];
|
uint8_t audioInputQueueBuffer[ 8 * sizeof( uint32_t ) ];
|
||||||
osStaticMessageQDef_t audioInputQueueControlBlock;
|
osStaticMessageQDef_t audioInputQueueControlBlock;
|
||||||
osMessageQId hdlcInputQueueHandle;
|
osMessageQId hdlcInputQueueHandle;
|
||||||
uint8_t hdlcInputQueueBuffer[ 3 * sizeof( uint32_t ) ];
|
uint8_t hdlcInputQueueBuffer[ 3 * sizeof( uint32_t ) ];
|
||||||
|
@ -148,6 +148,7 @@ void startDefaultTask(void const * argument);
|
||||||
extern void startIOEventTask(void const * argument);
|
extern void startIOEventTask(void const * argument);
|
||||||
extern void startAudioInputTask(void const * argument);
|
extern void startAudioInputTask(void const * argument);
|
||||||
extern void startModulatorTask(void const * argument);
|
extern void startModulatorTask(void const * argument);
|
||||||
|
void encode_serial_number(void);
|
||||||
|
|
||||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||||
|
|
||||||
|
@ -249,6 +250,8 @@ int main(void)
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
||||||
/* add 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 END RTOS_SEMAPHORES */
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_TIMERS */
|
/* USER CODE BEGIN RTOS_TIMERS */
|
||||||
|
@ -265,7 +268,7 @@ int main(void)
|
||||||
ioEventTaskHandle = osThreadCreate(osThread(ioEventTask), NULL);
|
ioEventTaskHandle = osThreadCreate(osThread(ioEventTask), NULL);
|
||||||
|
|
||||||
/* definition and creation of audioInputTask */
|
/* 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);
|
audioInputTaskHandle = osThreadCreate(osThread(audioInputTask), NULL);
|
||||||
|
|
||||||
/* definition and creation of modulatorTask */
|
/* definition and creation of modulatorTask */
|
||||||
|
@ -290,7 +293,7 @@ int main(void)
|
||||||
serialOutputQueueHandle = osMessageCreate(osMessageQ(serialOutputQueue), NULL);
|
serialOutputQueueHandle = osMessageCreate(osMessageQ(serialOutputQueue), NULL);
|
||||||
|
|
||||||
/* definition and creation of audioInputQueue */
|
/* definition and creation of audioInputQueue */
|
||||||
osMessageQStaticDef(audioInputQueue, 8, uint8_t, audioInputQueueBuffer, &audioInputQueueControlBlock);
|
osMessageQStaticDef(audioInputQueue, 8, uint32_t, audioInputQueueBuffer, &audioInputQueueControlBlock);
|
||||||
audioInputQueueHandle = osMessageCreate(osMessageQ(audioInputQueue), NULL);
|
audioInputQueueHandle = osMessageCreate(osMessageQ(audioInputQueue), NULL);
|
||||||
|
|
||||||
/* definition and creation of hdlcInputQueue */
|
/* definition and creation of hdlcInputQueue */
|
||||||
|
@ -311,6 +314,8 @@ int main(void)
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_QUEUES */
|
/* USER CODE BEGIN RTOS_QUEUES */
|
||||||
/* add 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_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_DAC_Start(&hdac1, DAC_CHANNEL_2) != HAL_OK) Error_Handler();
|
||||||
if (HAL_OPAMP_SelfCalibrate(&hopamp1) != HAL_OK) Error_Handler();
|
if (HAL_OPAMP_SelfCalibrate(&hopamp1) != HAL_OK) Error_Handler();
|
||||||
|
@ -325,7 +330,7 @@ int main(void)
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
// Do not erase SRAM2 during reset.
|
// Do not erase SRAM2 during reset.
|
||||||
if ((obInit.USERConfig & FLASH_OPTR_SRAM2_RST) == RESET) {
|
if ((obInit.USERConfig & FLASH_OPTR_SRAM2_RST) == RESET) {
|
||||||
obInit.OptionType = OPTIONBYTE_USER;
|
obInit.OptionType = OPTIONBYTE_USER;
|
||||||
|
@ -518,7 +523,7 @@ static void MX_ADC1_Init(void)
|
||||||
*/
|
*/
|
||||||
sConfig.Channel = ADC_CHANNEL_8;
|
sConfig.Channel = ADC_CHANNEL_8;
|
||||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||||
sConfig.SamplingTime = ADC_SAMPLETIME_6CYCLES_5;
|
sConfig.SamplingTime = ADC_SAMPLETIME_12CYCLES_5;
|
||||||
sConfig.SingleDiff = ADC_SINGLE_ENDED;
|
sConfig.SingleDiff = ADC_SINGLE_ENDED;
|
||||||
sConfig.OffsetNumber = ADC_OFFSET_NONE;
|
sConfig.OffsetNumber = ADC_OFFSET_NONE;
|
||||||
sConfig.Offset = 0;
|
sConfig.Offset = 0;
|
||||||
|
@ -591,7 +596,7 @@ static void MX_I2C3_Init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
hi2c3.Instance = I2C3;
|
hi2c3.Instance = I2C3;
|
||||||
hi2c3.Init.Timing = 0x00300F33;
|
hi2c3.Init.Timing = 0x00702991;
|
||||||
hi2c3.Init.OwnAddress1 = 0;
|
hi2c3.Init.OwnAddress1 = 0;
|
||||||
hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||||
hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||||
|
@ -632,7 +637,7 @@ static void MX_OPAMP1_Init(void)
|
||||||
hopamp1.Init.PowerSupplyRange = OPAMP_POWERSUPPLY_HIGH;
|
hopamp1.Init.PowerSupplyRange = OPAMP_POWERSUPPLY_HIGH;
|
||||||
hopamp1.Init.Mode = OPAMP_PGA_MODE;
|
hopamp1.Init.Mode = OPAMP_PGA_MODE;
|
||||||
hopamp1.Init.NonInvertingInput = OPAMP_NONINVERTINGINPUT_IO0;
|
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.PgaGain = OPAMP_PGA_GAIN_2;
|
||||||
hopamp1.Init.PowerMode = OPAMP_POWERMODE_NORMAL;
|
hopamp1.Init.PowerMode = OPAMP_POWERMODE_NORMAL;
|
||||||
hopamp1.Init.UserTrimming = OPAMP_TRIMMING_FACTORY;
|
hopamp1.Init.UserTrimming = OPAMP_TRIMMING_FACTORY;
|
||||||
|
@ -997,7 +1002,7 @@ void startDefaultTask(void const * argument)
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
osDelay(1);
|
osDelay(osWaitForever);
|
||||||
}
|
}
|
||||||
/* USER CODE END 5 */
|
/* USER CODE END 5 */
|
||||||
}
|
}
|
||||||
|
@ -1036,9 +1041,10 @@ void _Error_Handler(char *file, int line)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN Error_Handler_Debug */
|
/* USER CODE BEGIN Error_Handler_Debug */
|
||||||
/* User can add his own implementation to report the HAL error return state */
|
/* 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 */
|
/* USER CODE END Error_Handler_Debug */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,13 @@ void AFSKModulator::init(const kiss::Hardware& hw)
|
||||||
|
|
||||||
SysClock48();
|
SysClock48();
|
||||||
|
|
||||||
|
#ifndef NUCLEOTNC
|
||||||
// Configure 48MHz clock for 26.4ksps.
|
// Configure 48MHz clock for 26.4ksps.
|
||||||
|
htim7.Init.Period = 1817;
|
||||||
|
#else
|
||||||
|
// Using an 80MHz clock on NucleoTNC.
|
||||||
htim7.Init.Period = 3029;
|
htim7.Init.Period = 3029;
|
||||||
|
#endif
|
||||||
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
|
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
|
||||||
{
|
{
|
||||||
ERROR("htim7 init failed");
|
ERROR("htim7 init failed");
|
||||||
|
|
|
@ -95,7 +95,6 @@ struct Afsk1200Demodulator : IDemodulator
|
||||||
sConfig.Offset = 0;
|
sConfig.Offset = 0;
|
||||||
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
CxxErrorHandler();
|
CxxErrorHandler();
|
||||||
|
|
||||||
#ifndef NUCLEOTNC
|
#ifndef NUCLEOTNC
|
||||||
startADC(1817, ADC_BLOCK_SIZE);
|
startADC(1817, ADC_BLOCK_SIZE);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -12,6 +12,9 @@ extern "C" {
|
||||||
void startIOEventTask(void const* argument);
|
void startIOEventTask(void const* argument);
|
||||||
|
|
||||||
extern osMessageQId ioEventQueueHandle;
|
extern osMessageQId ioEventQueueHandle;
|
||||||
|
#ifndef NUCLEOTNC
|
||||||
|
extern volatile int cdc_connected;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#include "ModulatorTask.hpp"
|
#include "ModulatorTask.hpp"
|
||||||
#include "Modulator.hpp"
|
#include "Modulator.hpp"
|
||||||
#include "HDLCEncoder.hpp"
|
#include "HDLCEncoder.hpp"
|
||||||
|
#ifndef NUCLEOTNC
|
||||||
|
#include "KissHardware.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -630,18 +633,19 @@ bool Hardware::load()
|
||||||
{
|
{
|
||||||
INFO("Loading settings from EEPROM");
|
INFO("Loading settings from EEPROM");
|
||||||
|
|
||||||
Hardware tmp;
|
auto tmp = std::make_unique<Hardware>();
|
||||||
|
|
||||||
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");
|
ERROR("EEPROM read failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmp.crc_ok())
|
if (tmp->crc_ok())
|
||||||
{
|
{
|
||||||
memcpy(this, &tmp, sizeof(Hardware));
|
memcpy(this, tmp.get(), sizeof(Hardware));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ERROR("EEPROM CRC error");
|
ERROR("EEPROM CRC error");
|
||||||
|
@ -657,7 +661,7 @@ bool Hardware::store() const
|
||||||
return false;
|
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();
|
return crc_ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_RX_REV_POLARITY 0x40 // Reverse Polarity on RX when set.
|
||||||
#define KISS_OPTION_TX_REV_POLARITY 0x80 // Reverse Polarity on TX 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.
|
const char TOCALL[] = "APML00"; // Update for every feature change.
|
||||||
|
#endif
|
||||||
|
|
||||||
} // hardware
|
} // hardware
|
||||||
|
|
||||||
|
@ -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));
|
void reply(uint8_t cmd, const uint8_t* data, uint16_t len) __attribute__((noinline));
|
||||||
|
|
||||||
|
|
||||||
}}} // mobilinkd::tnc::kiss
|
}}} // mobilinkd::tnc::kiss
|
||||||
|
|
|
@ -149,7 +149,7 @@ struct M17Demodulator : IDemodulator
|
||||||
case DemodState::FRAME_SYNC:
|
case DemodState::FRAME_SYNC:
|
||||||
if (!locked)
|
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(demodState), int(dt * 10000), int(evm * 1000),
|
||||||
int(evma * 1000), int((1.0 / estimated_deviation) * 1000),
|
int(evma * 1000), int((1.0 / estimated_deviation) * 1000),
|
||||||
int(estimated_frequency_offset * 1000),
|
int(estimated_frequency_offset * 1000),
|
||||||
|
@ -206,7 +206,7 @@ struct M17Demodulator : IDemodulator
|
||||||
}
|
}
|
||||||
if ((count++ % 192) == 0)
|
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(demodState), int(dt * 10000), int(evm * 1000),
|
||||||
int(evma * 1000), int((1.0 / estimated_deviation) * 1000),
|
int(evma * 1000), int((1.0 / estimated_deviation) * 1000),
|
||||||
int(estimated_frequency_offset * 1000),
|
int(estimated_frequency_offset * 1000),
|
||||||
|
@ -256,7 +256,78 @@ struct M17Demodulator : IDemodulator
|
||||||
|
|
||||||
uint32_t readBatteryLevel() override
|
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;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ void M17Encoder::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
evt = osMessagePeek(input_queue, 0);
|
evt = osMessagePeek(input_queue, 0);
|
||||||
back2back = evt.status == osEventMessage;
|
back2back = (evt.status == osEventMessage);
|
||||||
if (!back2back)
|
if (!back2back)
|
||||||
{
|
{
|
||||||
osMessagePut(audioInputQueueHandle, tnc::audio::DEMODULATOR,
|
osMessagePut(audioInputQueueHandle, tnc::audio::DEMODULATOR,
|
||||||
|
|
|
@ -30,18 +30,17 @@ struct NullPort : PortInterface
|
||||||
open_ = false;
|
open_ = false;
|
||||||
}
|
}
|
||||||
virtual osMessageQId queue() const { return 0; }
|
virtual osMessageQId queue() const { return 0; }
|
||||||
virtual bool write(const uint8_t* data, uint32_t size, uint8_t type,
|
virtual bool write(const uint8_t*, uint32_t, uint8_t, uint32_t)
|
||||||
uint32_t timeout)
|
|
||||||
{
|
{
|
||||||
return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
virtual bool write(hdlc::IoFrame* frame, uint32_t = osWaitForever)
|
virtual bool write(hdlc::IoFrame* frame, uint32_t = osWaitForever)
|
||||||
{
|
{
|
||||||
hdlc::ioFramePool().release(frame);
|
hdlc::release(frame);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#ifndef NUCLEOTNC
|
#ifndef NUCLEOTNC
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "bm78.h"
|
||||||
#endif
|
#endif
|
||||||
#include "SerialPort.hpp"
|
#include "SerialPort.hpp"
|
||||||
#include "PortInterface.h"
|
#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_Receive_DMA(&huart_serial, rxBuffer, RX_BUFFER_SIZE * 2);
|
||||||
__HAL_UART_ENABLE_IT(&huart_serial, UART_IT_IDLE);
|
__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) {
|
while (true) {
|
||||||
osEvent evt = osMessageGet(serialPort->queue(), osWaitForever);
|
osEvent evt = osMessageGet(serialPort->queue(), osWaitForever);
|
||||||
|
|
||||||
|
@ -180,14 +177,12 @@ void startSerialTask(void const* arg)
|
||||||
reinterpret_cast<uint32_t>(frame),
|
reinterpret_cast<uint32_t>(frame),
|
||||||
osWaitForever) != osOK)
|
osWaitForever) != osOK)
|
||||||
{
|
{
|
||||||
WARN("Failed to send serial frame");
|
|
||||||
hdlc::release(frame);
|
hdlc::release(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hdlc::ioFramePool().size() < (hdlc::ioFramePool().capacity() / 4))
|
if (hdlc::ioFramePool().size() < (hdlc::ioFramePool().capacity() / 4))
|
||||||
{
|
{
|
||||||
UART_DMAPauseReceive(&huart_serial);
|
UART_DMAPauseReceive(&huart_serial);
|
||||||
WARN("Pausing UART RX");
|
|
||||||
while (hdlc::ioFramePool().size() < (hdlc::ioFramePool().capacity() / 2))
|
while (hdlc::ioFramePool().size() < (hdlc::ioFramePool().capacity() / 2))
|
||||||
{
|
{
|
||||||
osThreadYield();
|
osThreadYield();
|
||||||
|
|
Ładowanie…
Reference in New Issue