mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-21 06:13:41 +00:00
Fix further sweep timeout issues
This commit is contained in:
parent
4541dcb71b
commit
947a6b9d83
9 changed files with 53 additions and 14 deletions
|
|
@ -402,12 +402,23 @@ void FPGA::ResetADCLimits() {
|
|||
High(CS);
|
||||
}
|
||||
|
||||
void FPGA::ResumeHaltedSweep() {
|
||||
bool FPGA::ResumeHaltedSweep() {
|
||||
uint32_t start = HAL_GetTick();
|
||||
uint16_t cmd = 0x2000;
|
||||
uint16_t status;
|
||||
SwitchBytes(cmd);
|
||||
Low(CS);
|
||||
HAL_SPI_Transmit(&FPGA_SPI, (uint8_t*) &cmd, 2, 100);
|
||||
High(CS);
|
||||
do {
|
||||
if(HAL_GetTick() - start > 100) {
|
||||
LOG_WARN("Failed to resume sweep, timed out");
|
||||
return false;
|
||||
}
|
||||
Low(CS);
|
||||
HAL_SPI_TransmitReceive(&FPGA_SPI, (uint8_t*) &cmd, (uint8_t*) &status, 2, 100);
|
||||
High(CS);
|
||||
SwitchBytes(status);
|
||||
} while(status & 0x0010);
|
||||
// LOG_DEBUG("Status: 0x%04x", GetStatus());
|
||||
return true;
|
||||
}
|
||||
|
||||
void FPGA::SetupDFT(uint32_t f_firstBin, uint32_t f_binSpacing) {
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ void StartDFT();
|
|||
DFTResult ReadDFTResult();
|
||||
ADCLimits GetADCLimits();
|
||||
void ResetADCLimits();
|
||||
void ResumeHaltedSweep();
|
||||
bool ResumeHaltedSweep();
|
||||
uint16_t GetStatus();
|
||||
|
||||
void OverwriteHardware(uint8_t attenuation, LowpassFilter filter, bool lowband, bool port1_enabled, bool port2_enabled);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ void Log_Init() {
|
|||
#endif
|
||||
|
||||
/* USART interrupt Init */
|
||||
HAL_NVIC_SetPriority(NVIC_ISR, 0, 0);
|
||||
HAL_NVIC_SetPriority(NVIC_ISR, 3, 0);
|
||||
HAL_NVIC_EnableIRQ(NVIC_ISR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ void Delay::Init() {
|
|||
|
||||
// enable update interrupt
|
||||
TIM1->DIER |= TIM_DIER_UIE;
|
||||
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 6, 0);
|
||||
HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn);
|
||||
|
||||
TIM1->CR1 |= TIM_CR1_CEN;
|
||||
TIM1->CR1 |= TIM_CR1_CEN | TIM_CR1_UIFREMAP;
|
||||
}
|
||||
|
||||
uint64_t Delay::get_us() {
|
||||
|
|
@ -22,7 +22,7 @@ uint64_t Delay::get_us() {
|
|||
uint64_t ret;
|
||||
if(buf & 0x80000000) {
|
||||
// UIF bit set, timer overflow not handled yet
|
||||
ret = t_us + UINT16_MAX + timer_value;
|
||||
ret = t_us + UINT16_MAX + 1 + timer_value;
|
||||
} else {
|
||||
ret = t_us + timer_value;
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ void TIM1_UP_TIM16_IRQHandler() {
|
|||
// clear bit
|
||||
TIM1->SR &= ~TIM_SR_UIF;
|
||||
// update count
|
||||
t_us += UINT16_MAX;
|
||||
t_us += UINT16_MAX + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue