prepare to new hardware
This commit is contained in:
parent
503e90b95a
commit
66285cf2a3
8 changed files with 78 additions and 14 deletions
15
V203/usb/adc/project_config.h
Normal file
15
V203/usb/adc/project_config.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#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_
|
15
V203/usb/cdc/project_config.h
Normal file
15
V203/usb/cdc/project_config.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#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;
|
||||
return r.R;
|
||||
});
|
||||
// Enable ADC + GPIOC
|
||||
// Enable ADC + GPIOA
|
||||
RCC.APB2PCENR.modify([](RCC_Type::APB2PCENR_DEF & r) -> auto {
|
||||
r.B.ADC1EN = SET;
|
||||
r.B.IOPAEN = SET;
|
||||
|
@ -49,12 +49,12 @@ static inline void EnableClock (void) noexcept {
|
|||
});
|
||||
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).
|
||||
// PIN PA2, PA3 / A2,A3
|
||||
// PIN PA0, PA1 / A0,A1
|
||||
GPIOA.CFGLR.modify([](GPIOA_Type::CFGLR_DEF & r) -> auto {
|
||||
r.B.MODE2 = 0u;
|
||||
r.B.CNF2 = 0u;
|
||||
r.B.MODE3 = 0u;
|
||||
r.B.CNF3 = 0u;
|
||||
r.B.MODE0 = 0u;
|
||||
r.B.CNF0 = 0u;
|
||||
r.B.MODE1 = 0u;
|
||||
r.B.CNF1 = 0u;
|
||||
return r.R;
|
||||
});
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ static inline void AdcCalibrate (void) noexcept {
|
|||
RCC.APB2PRSTR.B.ADC1RST = SET;
|
||||
RCC.APB2PRSTR.B.ADC1RST = RESET;
|
||||
// set channels
|
||||
ADC1.RSQR3__CHANNEL.B.SQ1__CHSEL = 2u; // CH2
|
||||
ADC1.RSQR3__CHANNEL.B.SQ2 = 3u; // CH3
|
||||
ADC1.RSQR3__CHANNEL.B.SQ1__CHSEL = 0u; // CH0
|
||||
ADC1.RSQR3__CHANNEL.B.SQ2 = 1u; // CH1
|
||||
ADC1.RSQR1.B.L = ADC_MAXCHANNELS - 1U; // 2 regular conversion
|
||||
static constexpr unsigned ts = 0u;
|
||||
ADC1.SAMPTR2_CHARGE2.B.SMP2_TKCG2 = ts;
|
||||
|
@ -150,7 +150,7 @@ void SampleRing::ReloadTimer(const unsigned int n) {
|
|||
/* *********************************************************************************************/
|
||||
|
||||
void AdcClass::drq() {
|
||||
led << false;
|
||||
led << LED_ON;
|
||||
DMA1_Type::INTFR_DEF state (DMA1.INTFR);
|
||||
DMA1.INTFCR.R = state.R; // clear all
|
||||
if (state.B.HTIF1 != RESET) {
|
||||
|
@ -158,7 +158,7 @@ void AdcClass::drq() {
|
|||
} else if (state.B.TCIF1 != RESET) {
|
||||
ring.write (ptrh);
|
||||
}
|
||||
led << true;
|
||||
led << LED_OFF;
|
||||
}
|
||||
extern "C" {
|
||||
[[gnu::interrupt]] extern void DMA1_Channel1_IRQHandler();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "cdc_class.h"
|
||||
#include "system.h"
|
||||
#include "project_config.h"
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
/* Only one instance of this class ! */
|
||||
static cdc_class * pInstance = nullptr;
|
||||
|
@ -97,11 +98,11 @@ void cdc_class::USBFS_Device_Init( bool sta ) {
|
|||
USBFSD->BASE_CTRL = 0x00;
|
||||
NVIC.DisableIRQ( USBFS_IRQn );
|
||||
}
|
||||
dtr << true;
|
||||
dtr << LED_OFF;
|
||||
}
|
||||
|
||||
cdc_class::cdc_class() noexcept : BaseLayer(),
|
||||
CtrlIface(nullptr), dtr (GPIOA, 0), TxRing(), Ready(false), LineCoding() {
|
||||
CtrlIface(nullptr), dtr (DTR_LED), TxRing(), Ready(false), LineCoding() {
|
||||
pInstance = this;
|
||||
USBFS_DevConfig = 0;
|
||||
USBFS_DevAddr = 0;
|
||||
|
@ -246,7 +247,8 @@ union DtrRts {
|
|||
if (CtrlIface) CtrlIface->IOCtrl(USB_USART_SET_DTR_RTS, tmp.bytes, 2);
|
||||
const bool b = USBFS_SetupReqValue & 1;
|
||||
Ready = b;
|
||||
dtr << !b;
|
||||
if (b) dtr << LED_ON;
|
||||
else dtr << LED_OFF;
|
||||
} break;
|
||||
|
||||
case CDC_SEND_BREAK:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include "samplering.h"
|
||||
#include "gpio.h"
|
||||
#include "project_config.h"
|
||||
|
||||
/** @file
|
||||
* @brief A/D převodník.
|
||||
|
@ -19,7 +20,7 @@
|
|||
|
||||
class AdcClass {
|
||||
public:
|
||||
AdcClass(SampleRing & r) : ring(r), led(GPIOA, 1), ptrl (buffer), ptrh (buffer + DATA_HALF_LEN) {
|
||||
AdcClass(SampleRing & r) : ring(r), led(DRQ_LED), ptrl (buffer), ptrh (buffer + DATA_HALF_LEN) {
|
||||
};
|
||||
/**
|
||||
* @brief Inicializace ADC.
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
static SampleRing ring;
|
||||
static AdcClass adc (ring);
|
||||
static cdc_class cdc;
|
||||
static GpioClass power(GPIOB, 3);
|
||||
|
||||
int main () {
|
||||
cdc.init();
|
||||
power << true;
|
||||
adc.Init();
|
||||
ring += cdc;
|
||||
for (;;) {
|
||||
|
|
14
V203/usb/scope/firmware/project_config.h
Normal file
14
V203/usb/scope/firmware/project_config.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#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_
|
15
V203/usb/usart/project_config.h
Normal file
15
V203/usb/usart/project_config.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#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