mirror of https://github.com/g4klx/MMDVM.git
Add the analogue and interrupt processing.
This commit is contained in:
parent
07d54f74cc
commit
fb5ce0101d
|
@ -25,12 +25,11 @@
|
|||
#include "AX25Demodulator.h"
|
||||
#include "AX25Defines.h"
|
||||
|
||||
const float32_t SAMPLE_RATE = 24000.0F;
|
||||
const float32_t SYMBOL_RATE = 1200.0F;
|
||||
const uint32_t SYMBOL_RATE = 1200U;
|
||||
|
||||
const uint16_t DELAY_LEN = 11U;
|
||||
|
||||
const float32_t SAMPLES_PER_SYMBOL = SAMPLE_RATE / SYMBOL_RATE;
|
||||
const float32_t SAMPLES_PER_SYMBOL = float32_t(SAMPLE_RATE / SYMBOL_RATE);
|
||||
const float32_t PLL_LIMIT = SAMPLES_PER_SYMBOL / 2.0F;
|
||||
|
||||
const uint32_t LPF_FILTER_LEN = 48U;
|
||||
|
|
|
@ -100,6 +100,8 @@ const uint16_t RX_BLOCK_SIZE = 2U;
|
|||
const uint16_t TX_RINGBUFFER_SIZE = 500U;
|
||||
const uint16_t RX_RINGBUFFER_SIZE = 600U;
|
||||
|
||||
const uint32_t SAMPLE_RATE = 24000U;
|
||||
|
||||
#if defined(__MK20DX256__)
|
||||
const uint16_t TX_BUFFER_LEN = 2000U;
|
||||
#else
|
||||
|
|
39
src/IO.cpp
39
src/IO.cpp
|
@ -80,6 +80,7 @@ const uint16_t BOXCAR5_FILTER_LEN = 6U;
|
|||
const uint16_t DC_OFFSET = 2048U;
|
||||
|
||||
CIO::CIO() :
|
||||
m_timer(TIM2),
|
||||
m_started(false),
|
||||
m_rxBuffer(RX_RINGBUFFER_SIZE),
|
||||
m_txBuffer(TX_RINGBUFFER_SIZE),
|
||||
|
@ -335,7 +336,6 @@ void CIO::start()
|
|||
|
||||
void CIO::process()
|
||||
{
|
||||
m_ledCount++;
|
||||
if (m_started) {
|
||||
// Two seconds timeout
|
||||
if (m_watchdog >= 48000U) {
|
||||
|
@ -360,6 +360,7 @@ void CIO::process()
|
|||
}
|
||||
#endif
|
||||
} else {
|
||||
m_ledCount++;
|
||||
if (m_ledCount >= 240000U) {
|
||||
m_ledCount = 0U;
|
||||
m_ledValue = !m_ledValue;
|
||||
|
@ -846,6 +847,32 @@ bool CIO::hasLockout() const
|
|||
return m_lockout;
|
||||
}
|
||||
|
||||
void IRQHandler()
|
||||
{
|
||||
io.interrupt();
|
||||
}
|
||||
|
||||
void CIO::interrupt()
|
||||
{
|
||||
TSample sample = {DC_OFFSET, MARK_NONE};
|
||||
uint16_t rawRSSI = 0U;
|
||||
|
||||
m_txBuffer.get(sample);
|
||||
::analogWrite(PIN_TX, sample.sample);
|
||||
|
||||
sample.sample = ::analogRead(PIN_RX);
|
||||
|
||||
#if defined(SEND_RSSI_DATA)
|
||||
rawRSSI = ::analogRead(PIN_RSSI);
|
||||
#endif
|
||||
|
||||
m_rxBuffer.put(sample);
|
||||
m_rssiBuffer.put(rawRSSI);
|
||||
|
||||
m_ledCount++;
|
||||
m_watchdog++;
|
||||
}
|
||||
|
||||
void CIO::initHardware()
|
||||
{
|
||||
#if defined(PIN_COS)
|
||||
|
@ -888,11 +915,19 @@ void CIO::initHardware()
|
|||
::pinMode(PIN_M17, OUTPUT);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
::analogReadResolution(12);
|
||||
::analogWriteResolution(12);
|
||||
|
||||
m_timer.setPrescaleFactor((SystemCoreClock / (6 * SAMPLE_RATE)) - 1);
|
||||
m_timer.setOverflow(2);
|
||||
m_timer.attachInterrupt(IRQHandler);
|
||||
m_timer.refresh(); // Make register changes take effect
|
||||
}
|
||||
|
||||
void CIO::startHardware()
|
||||
{
|
||||
|
||||
m_timer.resume();
|
||||
}
|
||||
|
||||
bool CIO::getCOS()
|
||||
|
|
2
src/IO.h
2
src/IO.h
|
@ -61,6 +61,8 @@ public:
|
|||
void selfTest();
|
||||
|
||||
private:
|
||||
HardwareTimer m_timer;
|
||||
|
||||
bool m_started;
|
||||
|
||||
CRingBuffer<TSample> m_rxBuffer;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020,2021,2022 by Jonathan Naylor G4KLX
|
||||
* Copyright (C) 2020,2021,2022,2024 by Jonathan Naylor G4KLX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -19,7 +19,7 @@
|
|||
#if !defined(VERSION_H)
|
||||
#define VERSION_H
|
||||
|
||||
#define VERSION "20221121"
|
||||
#define VERSION "20241008"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue