Compare commits
No commits in common. "66285cf2a3951e6c1179d83092373f372b87c67b" and "8027708b3ec78058842f90e83ace04c70f3fc860" have entirely different histories.
66285cf2a3
...
8027708b3e
10 changed files with 20 additions and 100 deletions
|
@ -1,15 +0,0 @@
|
||||||
#ifndef _PROJECT_CONFIG_H_
|
|
||||||
#define _PROJECT_CONFIG_H_
|
|
||||||
#define DEVEL_KIT
|
|
||||||
#ifdef DEVEL_KIT
|
|
||||||
#define DTR_LED GPIOA,0
|
|
||||||
#define DRQ_LED GPIOA,1
|
|
||||||
#define LED_ON false
|
|
||||||
#define LED_OFF true
|
|
||||||
#else
|
|
||||||
#define DTR_LED GPIOB,5
|
|
||||||
#define DRQ_LED GPIOB,4
|
|
||||||
#define LED_ON true
|
|
||||||
#define LED_OFF false
|
|
||||||
#endif
|
|
||||||
#endif // _PROJECT_CONFIG_H_
|
|
|
@ -1,15 +0,0 @@
|
||||||
#ifndef _PROJECT_CONFIG_H_
|
|
||||||
#define _PROJECT_CONFIG_H_
|
|
||||||
#define DEVEL_KIT
|
|
||||||
#ifdef DEVEL_KIT
|
|
||||||
#define DTR_LED GPIOA,0
|
|
||||||
#define DRQ_LED GPIOA,1
|
|
||||||
#define LED_ON false
|
|
||||||
#define LED_OFF true
|
|
||||||
#else
|
|
||||||
#define DTR_LED GPIOB,5
|
|
||||||
#define DRQ_LED GPIOB,4
|
|
||||||
#define LED_ON true
|
|
||||||
#define LED_OFF false
|
|
||||||
#endif
|
|
||||||
#endif // _PROJECT_CONFIG_H_
|
|
|
@ -41,7 +41,7 @@ static inline void EnableClock (void) noexcept {
|
||||||
r.B.DMA1EN = SET;
|
r.B.DMA1EN = SET;
|
||||||
return r.R;
|
return r.R;
|
||||||
});
|
});
|
||||||
// Enable ADC + GPIOA
|
// Enable ADC + GPIOC
|
||||||
RCC.APB2PCENR.modify([](RCC_Type::APB2PCENR_DEF & r) -> auto {
|
RCC.APB2PCENR.modify([](RCC_Type::APB2PCENR_DEF & r) -> auto {
|
||||||
r.B.ADC1EN = SET;
|
r.B.ADC1EN = SET;
|
||||||
r.B.IOPAEN = SET;
|
r.B.IOPAEN = SET;
|
||||||
|
@ -49,12 +49,12 @@ static inline void EnableClock (void) noexcept {
|
||||||
});
|
});
|
||||||
RCC.APB1PCENR.B.TIM3EN = SET; // Enable TIM3
|
RCC.APB1PCENR.B.TIM3EN = SET; // Enable TIM3
|
||||||
RCC.CFGR0.B.ADCPRE = 3u; // PCLK2 divided by 8 as ADC clock (18 MHz, ! pretaktovano 14 MHz max).
|
RCC.CFGR0.B.ADCPRE = 3u; // PCLK2 divided by 8 as ADC clock (18 MHz, ! pretaktovano 14 MHz max).
|
||||||
// PIN PA0, PA1 / A0,A1
|
// PIN PA2, PA3 / A2,A3
|
||||||
GPIOA.CFGLR.modify([](GPIOA_Type::CFGLR_DEF & r) -> auto {
|
GPIOA.CFGLR.modify([](GPIOA_Type::CFGLR_DEF & r) -> auto {
|
||||||
r.B.MODE0 = 0u;
|
r.B.MODE2 = 0u;
|
||||||
r.B.CNF0 = 0u;
|
r.B.CNF2 = 0u;
|
||||||
r.B.MODE1 = 0u;
|
r.B.MODE3 = 0u;
|
||||||
r.B.CNF1 = 0u;
|
r.B.CNF3 = 0u;
|
||||||
return r.R;
|
return r.R;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ static inline void AdcCalibrate (void) noexcept {
|
||||||
RCC.APB2PRSTR.B.ADC1RST = SET;
|
RCC.APB2PRSTR.B.ADC1RST = SET;
|
||||||
RCC.APB2PRSTR.B.ADC1RST = RESET;
|
RCC.APB2PRSTR.B.ADC1RST = RESET;
|
||||||
// set channels
|
// set channels
|
||||||
ADC1.RSQR3__CHANNEL.B.SQ1__CHSEL = 0u; // CH0
|
ADC1.RSQR3__CHANNEL.B.SQ1__CHSEL = 2u; // CH2
|
||||||
ADC1.RSQR3__CHANNEL.B.SQ2 = 1u; // CH1
|
ADC1.RSQR3__CHANNEL.B.SQ2 = 3u; // CH3
|
||||||
ADC1.RSQR1.B.L = ADC_MAXCHANNELS - 1U; // 2 regular conversion
|
ADC1.RSQR1.B.L = ADC_MAXCHANNELS - 1U; // 2 regular conversion
|
||||||
static constexpr unsigned ts = 0u;
|
static constexpr unsigned ts = 0u;
|
||||||
ADC1.SAMPTR2_CHARGE2.B.SMP2_TKCG2 = ts;
|
ADC1.SAMPTR2_CHARGE2.B.SMP2_TKCG2 = ts;
|
||||||
|
@ -150,7 +150,7 @@ void SampleRing::ReloadTimer(const unsigned int n) {
|
||||||
/* *********************************************************************************************/
|
/* *********************************************************************************************/
|
||||||
|
|
||||||
void AdcClass::drq() {
|
void AdcClass::drq() {
|
||||||
led << LED_ON;
|
led << false;
|
||||||
DMA1_Type::INTFR_DEF state (DMA1.INTFR);
|
DMA1_Type::INTFR_DEF state (DMA1.INTFR);
|
||||||
DMA1.INTFCR.R = state.R; // clear all
|
DMA1.INTFCR.R = state.R; // clear all
|
||||||
if (state.B.HTIF1 != RESET) {
|
if (state.B.HTIF1 != RESET) {
|
||||||
|
@ -158,7 +158,7 @@ void AdcClass::drq() {
|
||||||
} else if (state.B.TCIF1 != RESET) {
|
} else if (state.B.TCIF1 != RESET) {
|
||||||
ring.write (ptrh);
|
ring.write (ptrh);
|
||||||
}
|
}
|
||||||
led << LED_OFF;
|
led << true;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
[[gnu::interrupt]] extern void DMA1_Channel1_IRQHandler();
|
[[gnu::interrupt]] extern void DMA1_Channel1_IRQHandler();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "cdc_class.h"
|
#include "cdc_class.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "project_config.h"
|
|
||||||
typedef __SIZE_TYPE__ size_t;
|
typedef __SIZE_TYPE__ size_t;
|
||||||
/* Only one instance of this class ! */
|
/* Only one instance of this class ! */
|
||||||
static cdc_class * pInstance = nullptr;
|
static cdc_class * pInstance = nullptr;
|
||||||
|
@ -98,11 +97,11 @@ void cdc_class::USBFS_Device_Init( bool sta ) {
|
||||||
USBFSD->BASE_CTRL = 0x00;
|
USBFSD->BASE_CTRL = 0x00;
|
||||||
NVIC.DisableIRQ( USBFS_IRQn );
|
NVIC.DisableIRQ( USBFS_IRQn );
|
||||||
}
|
}
|
||||||
dtr << LED_OFF;
|
dtr << true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cdc_class::cdc_class() noexcept : BaseLayer(),
|
cdc_class::cdc_class() noexcept : BaseLayer(),
|
||||||
CtrlIface(nullptr), dtr (DTR_LED), TxRing(), Ready(false), LineCoding() {
|
CtrlIface(nullptr), dtr (GPIOA, 0), TxRing(), Ready(false), LineCoding() {
|
||||||
pInstance = this;
|
pInstance = this;
|
||||||
USBFS_DevConfig = 0;
|
USBFS_DevConfig = 0;
|
||||||
USBFS_DevAddr = 0;
|
USBFS_DevAddr = 0;
|
||||||
|
@ -247,8 +246,7 @@ union DtrRts {
|
||||||
if (CtrlIface) CtrlIface->IOCtrl(USB_USART_SET_DTR_RTS, tmp.bytes, 2);
|
if (CtrlIface) CtrlIface->IOCtrl(USB_USART_SET_DTR_RTS, tmp.bytes, 2);
|
||||||
const bool b = USBFS_SetupReqValue & 1;
|
const bool b = USBFS_SetupReqValue & 1;
|
||||||
Ready = b;
|
Ready = b;
|
||||||
if (b) dtr << LED_ON;
|
dtr << !b;
|
||||||
else dtr << LED_OFF;
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case CDC_SEND_BREAK:
|
case CDC_SEND_BREAK:
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "samplering.h"
|
#include "samplering.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
#include "project_config.h"
|
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
* @brief A/D převodník.
|
* @brief A/D převodník.
|
||||||
|
@ -20,7 +19,7 @@
|
||||||
|
|
||||||
class AdcClass {
|
class AdcClass {
|
||||||
public:
|
public:
|
||||||
AdcClass(SampleRing & r) : ring(r), led(DRQ_LED), ptrl (buffer), ptrh (buffer + DATA_HALF_LEN) {
|
AdcClass(SampleRing & r) : ring(r), led(GPIOA, 1), ptrl (buffer), ptrh (buffer + DATA_HALF_LEN) {
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief Inicializace ADC.
|
* @brief Inicializace ADC.
|
||||||
|
|
|
@ -17,11 +17,9 @@
|
||||||
static SampleRing ring;
|
static SampleRing ring;
|
||||||
static AdcClass adc (ring);
|
static AdcClass adc (ring);
|
||||||
static cdc_class cdc;
|
static cdc_class cdc;
|
||||||
static GpioClass power(GPIOB, 3);
|
|
||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
cdc.init();
|
cdc.init();
|
||||||
power << true;
|
|
||||||
adc.Init();
|
adc.Init();
|
||||||
ring += cdc;
|
ring += cdc;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#ifndef _PROJECT_CONFIG_H_
|
|
||||||
#define _PROJECT_CONFIG_H_
|
|
||||||
#ifdef DEVEL_KIT
|
|
||||||
#define DTR_LED GPIOA,0
|
|
||||||
#define DRQ_LED GPIOA,1
|
|
||||||
#define LED_ON false
|
|
||||||
#define LED_OFF true
|
|
||||||
#else
|
|
||||||
#define DTR_LED GPIOB,5
|
|
||||||
#define DRQ_LED GPIOB,4
|
|
||||||
#define LED_ON true
|
|
||||||
#define LED_OFF false
|
|
||||||
#endif
|
|
||||||
#endif // _PROJECT_CONFIG_H_
|
|
|
@ -11,10 +11,6 @@ static const double TimeBaseSteps [] = {
|
||||||
2.0e-6, 5.0e-6, 1.0e-5, 2.0e-5, 5.0e-5, 1.0e-4, 2.0e-4, 5.0e-4, 1.0e-3,
|
2.0e-6, 5.0e-6, 1.0e-5, 2.0e-5, 5.0e-5, 1.0e-4, 2.0e-4, 5.0e-4, 1.0e-3,
|
||||||
2.0e-3, 5.0e-3, 1.0e-2, 2.0e-2, 5.0e-2, 1.0e-1, 2.0e-1, 5.0e-1, 1.0,
|
2.0e-3, 5.0e-3, 1.0e-2, 2.0e-2, 5.0e-2, 1.0e-1, 2.0e-1, 5.0e-1, 1.0,
|
||||||
};
|
};
|
||||||
static const int TimeBaseCounts [] = {
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 10,
|
|
||||||
5, 2, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
};
|
|
||||||
static const double ChannelsSteps [] = {
|
static const double ChannelsSteps [] = {
|
||||||
0.1, 0.2, 0.5,
|
0.1, 0.2, 0.5,
|
||||||
1.0, 2.0, 5.0,
|
1.0, 2.0, 5.0,
|
||||||
|
@ -46,8 +42,6 @@ DisplayWidget::DisplayWidget(QWidget * p) : QWidget(p), pcol(), ACopy(), BCopy()
|
||||||
n = 0;
|
n = 0;
|
||||||
for (QPointF & e : ChB) { const QPointF p (n++, 0); e = p; }
|
for (QPointF & e : ChB) { const QPointF p (n++, 0); e = p; }
|
||||||
m_continual = false;
|
m_continual = false;
|
||||||
m_cont_limit = 0;
|
|
||||||
m_cont_pass = 0;
|
|
||||||
}
|
}
|
||||||
DisplayWidget::~DisplayWidget() {
|
DisplayWidget::~DisplayWidget() {
|
||||||
}
|
}
|
||||||
|
@ -195,9 +189,10 @@ void DisplayWidget::setTrigger(TrigerSettings * ts) {
|
||||||
void DisplayWidget::DispChannels(QVector<int> cha, QVector<int> chb) {
|
void DisplayWidget::DispChannels(QVector<int> cha, QVector<int> chb) {
|
||||||
ACopy = cha;
|
ACopy = cha;
|
||||||
BCopy = chb;
|
BCopy = chb;
|
||||||
if (reloadData()) update();
|
reloadData();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
bool DisplayWidget::reloadData () {
|
void DisplayWidget::reloadData () {
|
||||||
const size_t Alen = ACopy.size();
|
const size_t Alen = ACopy.size();
|
||||||
const size_t Blen = BCopy.size();
|
const size_t Blen = BCopy.size();
|
||||||
const size_t Amin = Alen < T_SIZE ? Alen : T_SIZE;
|
const size_t Amin = Alen < T_SIZE ? Alen : T_SIZE;
|
||||||
|
@ -209,13 +204,7 @@ bool DisplayWidget::reloadData () {
|
||||||
ChB[m_timeCount] = ptb;
|
ChB[m_timeCount] = ptb;
|
||||||
m_timeCount += 1u;
|
m_timeCount += 1u;
|
||||||
m_timeCount &= T_MASK;
|
m_timeCount &= T_MASK;
|
||||||
m_cont_pass += 1;
|
return;
|
||||||
if (m_cont_pass >= m_cont_limit) {
|
|
||||||
m_cont_pass = 0;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_continual = false;
|
m_continual = false;
|
||||||
for (unsigned n=0u; n<Amin; n++) {
|
for (unsigned n=0u; n<Amin; n++) {
|
||||||
|
@ -231,7 +220,6 @@ bool DisplayWidget::reloadData () {
|
||||||
x_lenght = l;
|
x_lenght = l;
|
||||||
reloadMatrix (size());
|
reloadMatrix (size());
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
void DisplayWidget::reloadMatrix(const QSize & sz) {
|
void DisplayWidget::reloadMatrix(const QSize & sz) {
|
||||||
const double xm = sz.width();
|
const double xm = sz.width();
|
||||||
|
@ -244,8 +232,6 @@ void DisplayWidget::reloadMatrix(const QSize & sz) {
|
||||||
}
|
}
|
||||||
void DisplayWidget::TimeBaseRange(int n) {
|
void DisplayWidget::TimeBaseRange(int n) {
|
||||||
m_timeBase = n;
|
m_timeBase = n;
|
||||||
m_cont_limit = TimeBaseCounts [m_timeBase];
|
|
||||||
//qDebug("count = %d", m_cont_limit);
|
|
||||||
reloadMatrix (size());
|
reloadMatrix (size());
|
||||||
drawBackground();
|
drawBackground();
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -46,8 +46,6 @@ class DisplayWidget : public QWidget {
|
||||||
} marker_type;
|
} marker_type;
|
||||||
unsigned m_timeCount;
|
unsigned m_timeCount;
|
||||||
bool m_continual;
|
bool m_continual;
|
||||||
int m_cont_limit;
|
|
||||||
int m_cont_pass;
|
|
||||||
public:
|
public:
|
||||||
explicit DisplayWidget (QWidget * p);
|
explicit DisplayWidget (QWidget * p);
|
||||||
virtual ~DisplayWidget ();
|
virtual ~DisplayWidget ();
|
||||||
|
@ -73,7 +71,7 @@ class DisplayWidget : public QWidget {
|
||||||
protected:
|
protected:
|
||||||
void drawCurrent (QPainter & p);
|
void drawCurrent (QPainter & p);
|
||||||
void drawBackground ();
|
void drawBackground ();
|
||||||
bool reloadData ();
|
void reloadData ();
|
||||||
void reloadMatrix (const QSize & sz);
|
void reloadMatrix (const QSize & sz);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
#ifndef _PROJECT_CONFIG_H_
|
|
||||||
#define _PROJECT_CONFIG_H_
|
|
||||||
#define DEVEL_KIT
|
|
||||||
#ifdef DEVEL_KIT
|
|
||||||
#define DTR_LED GPIOA,0
|
|
||||||
#define DRQ_LED GPIOA,1
|
|
||||||
#define LED_ON false
|
|
||||||
#define LED_OFF true
|
|
||||||
#else
|
|
||||||
#define DTR_LED GPIOB,5
|
|
||||||
#define DRQ_LED GPIOB,4
|
|
||||||
#define LED_ON true
|
|
||||||
#define LED_OFF false
|
|
||||||
#endif
|
|
||||||
#endif // _PROJECT_CONFIG_H_
|
|
Loading…
Reference in a new issue