Ср июл 18, 2018 16:36:09
Ср июл 18, 2018 17:12:10
Ср июл 18, 2018 17:18:52
Ср июл 18, 2018 17:21:39
Ср июл 18, 2018 17:37:59
Ср июл 18, 2018 17:43:45
Ср июл 18, 2018 17:44:37
Особенность всех IDE, и условно стандартной обработки через make all - например в блокноте - подразумевает сборку всех .cpp файлов в .o - по условию %.cpp - отсюда проблема видимости разными классами - других классов, и упорядочить include - не представляется возможным, т.е.:
#include one
#include two
#include three
one не будет видеть two и three т.к. они вызываются позже, как не тусуй очередность - всегда будет задействован какой либо функционал еще не подключенного файла
#include one
#include two
#include three
...
one *Class1;
two *Class2;
three *Class3 ;
.....
Class1->init();
Class1->Dofunc1(&struct1);
Class1->exit();
delete Class1;
....
....
Ср июл 18, 2018 19:02:18
Ср июл 18, 2018 19:05:24
#ifndef HMC704T_H
#define HMC704T_H
namespace HMC704T_NAMESPACE
{
using namespace IOPORTS;
typedef PD_2 LE1;
typedef PC_15 LE2;
typedef PA_8 LE3;
typedef struct
{
uint8_t HiKcp;
uint8_t CP;
} HMC704_CP;
template <const uint8_t NUM, class LE_PIN>
class HMC704T
{
public:
HMC704T() { chan = 0; };
void SetHMCMode(void) { LE=1; __no_operation(); LE=0; };
void SetChannel(uint8_t);
auto GetChannel(void) { return chan; };
void FirstLoad(uint8_t);
private:
void SetFreq(uint16_t f);
void SetReg(uint8_t reg, uint32_t value);
uint8_t chan;
LE_PIN LE;
PC_10 SCK;
PC_12 DATA;
PC_13 SW3;
};
} //namespace HMC704T_NAMESPACE
namespace SNT=HMC704T_NAMESPACE;
#ifdef HMC704T_CPP
SNT::HMC704T<1,SNT::LE3> snt1; // Синтезатор ПРМ 10.0-13.0 ГГц (по схеме на LE3)
SNT::HMC704T<2,SNT::LE2> snt2; // Синтезатор ПРД 10.0 ГГц (по схеме на LE2)
SNT::HMC704T<3,SNT::LE1> snt3; // Синтезатор ПРД 10.0-11.5 ГГц (по схеме на LE1)
template class SNT::HMC704T<1,SNT::LE3>;
template class SNT::HMC704T<2,SNT::LE2>;
template class SNT::HMC704T<3,SNT::LE1>;
#else
extern SNT::HMC704T<1,SNT::LE3> snt1;
extern SNT::HMC704T<2,SNT::LE2> snt2;
extern SNT::HMC704T<3,SNT::LE1> snt3;
#endif //HMC704T_CPP
#endif //HMC704T_H
#define HMC704T_CPP
#include "main.h"
namespace HMC704T_NAMESPACE
{
// Задать номер канала 0-60
template <const uint8_t NUM, class LE_PIN>
void HMC704T<NUM,LE_PIN>::SetChannel(uint8_t channel)
{
if(NUM==1) //У синтезатора ПРМ переключаемый ГУН
{
if(channel>28) SW3=1; else SW3=0;
}
if(channel>60) channel=60;
SetFreq(channel*50+10000);
chan=channel;
}
// Первая загрузка с частотой из EEPROM
template <const uint8_t NUM, class LE_PIN>
void HMC704T<NUM,LE_PIN>::FirstLoad(uint8_t ch)
{
SetReg(0x00,(1<<5)); //Генерировать RESET
SetReg(0x01,(1<<1)); //Chip Enable
SetReg(0x02,2); //R=2
//SetReg(0x06,0x030F4A); //Frac
SetReg(0x06,0x0307CA); //Int
SetReg(0x07,0x00014D);
SetReg(0x08,0x09BEFF); //Analog EN
SetReg(0x0B,0x078071);
SetReg(0x0F,0x000001);
SetChannel(ch);
chan=ch;
};
extern const HMC704_CP cpVSfreq[];
// Задать частоту c шагом 1 МГц
template <const uint8_t NUM, class LE_PIN>
void HMC704T<NUM,LE_PIN>::SetFreq(uint16_t f)
{
uint8_t LEAK_MAG = 80; // 0.4 мА
uint8_t chan = (f-10000)/50;
uint8_t HiKcp = cpVSfreq[chan].HiKcp;
uint8_t CP = cpVSfreq[chan].CP;
uint8_t intg = f/200;
uint32_t frac = (f%200)*4194304L/50;
if(frac==0)
{
SetReg(0x06,0x0307CA); //Int
}
else
{
SetReg(0x06,0x030F4E); //Frac
}
SetReg(0x03,intg);
SetReg(0x04,frac);
SetReg(0x09, ((uint32_t)HiKcp<<23) | (1L<<22) | ((uint32_t)LEAK_MAG<<14) | (CP<<7)| CP); //CP_DN
};
template <const uint8_t NUM, class LE_PIN>
void HMC704T<NUM,LE_PIN>::SetReg(uint8_t reg, uint32_t value)
{
uint32_t tmp = ((uint32_t)(reg&0x3F)<<25)|((value&0x00FFFFFF)<<1);
LE=1;
for(auto mask=0x80000000U;mask;)
{
SCK=0;
DATA = (tmp & mask) ? 1 : 0;
mask >>=1;
SCK=1;
}
__no_operation(); __no_operation(); __no_operation();
SCK=0;
LE=0;
};
const HMC704_CP cpVSfreq[61] = { // { HiKcp, CP }
{ 1, 0 }, { 1, 5 }, { 1, 10 }, { 1, 15 }, // 10'000 10'050 10'100 10'150
{ 1, 20 }, { 1, 25 }, { 1, 30 }, { 1, 35 }, // 10'200 10'250 10'300 10'350
{ 1, 40 }, { 1, 45 }, { 1, 50 }, { 1, 50 }, // 10'400 10'450 10'500 10'550
{ 1, 50 }, { 1, 50 }, { 1, 50 }, { 1, 50 }, // 10'600 10'650 10'700 10'750
{ 1, 50 }, { 1, 50 }, { 1, 50 }, { 1, 50 }, // 10'800 10'850 10'900 10'950
{ 1, 65 }, { 1, 65 }, { 1, 65 }, { 1, 65 }, // 11'000 11'050 11'100 11'150
{ 1, 65 }, { 1, 75 }, { 1, 75 }, { 1, 75 }, // 11'200 11'250 11'300 11'350
{ 1, 75 }, { 1, 0 }, { 1, 0 }, { 1, 0 }, // 11'400 11'450 11'500 11'550
{ 1, 5 }, { 1, 5 }, { 1, 5 }, { 1, 5 }, // 11'600 11'650 11'700 11'750
{ 1, 5 }, { 1, 10 }, { 1, 15 }, { 1, 20 }, // 11'800 11'850 11'900 11'950
{ 1, 25 }, { 1, 25 }, { 1, 30 }, { 1, 30 }, // 12'000 12'050 12'100 12'150
{ 1, 35 }, { 1, 35 }, { 1, 40 }, { 1, 40 }, // 12'200 12'250 12'300 12'350
{ 1, 45 }, { 1, 45 }, { 1, 50 }, { 1, 50 }, // 12'400 12'450 12'500 12'550
{ 1, 55 }, { 1, 55 }, { 1, 60 }, { 1, 65 }, // 12'600 12'650 12'700 12'750
{ 1, 65 }, { 1, 65 }, { 1, 65 }, { 1, 65 }, // 12'800 12'850 12'900 12'950
{ 1, 65 } }; // 13'000
// 5=0,1 мА 25=0,5 мА 50=1,0 мА 65=1,3 мА 75=1,5 мА
}
#ifndef MAIN_H
#define MAIN_H
#include "stm32f107xc.h"
#include <intrinsics.h>
#include <stdint.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include "SEGGER_RTT_Conf.h"
#include "SEGGER_RTT.H"
#include "gpio_stm32f1.h"
#include "lcd.h"
#include "Keyboard.h"
#include "Eth_Adresses.h"
#include "Eth.h"
#include "hmc629.h"
#include "hmc704T.h"
#include "EEPROM.h"
#include "Delay.h"
#include "usb_interrupt.h"
#include "usb_device.h"
#include "usb_cdc.h"
#define HSE_VALUE 8'000'000UL
#define CPU_FREQ 72'000'000UL
#endif //MAIN_H
#include "main.h"
int main()
{
//Перевод hmc704 в режим HMC Mode
snt1.SetHMCMode();
snt2.SetHMCMode();
snt3.SetHMCMode();
snt1.FirstLoad(0);
snt2.FirstLoad(0);
snt3.FirstLoad(0);
for(;;)
{
if(usb.isCommandReceived()) tna.DoCommand();
};
}
Ср июл 18, 2018 22:29:33
Чт июл 19, 2018 05:38:59
Чт июл 19, 2018 15:06:45
Чт июл 19, 2018 15:13:27