fork

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
Kovalev_D
Date:
Wed Sep 27 13:09:24 2017 +0000
Revision:
219:2d3475d0dd1b
Parent:
99:3d8f206ceac2
hnjtfgyy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
igor_v 1:f2adcae3d304 1 #ifndef InputOutput_H
igor_v 1:f2adcae3d304 2 #define InputOutput_H
igor_v 0:8ad47e2b6f00 3
igor_v 0:8ad47e2b6f00 4
igor_v 0:8ad47e2b6f00 5 #include "stdint.h"
igor_v 0:8ad47e2b6f00 6
igor_v 21:bc8c1cec3da6 7 //******************************I2C*************************************************
igor_v 0:8ad47e2b6f00 8 #define I2C0
igor_v 0:8ad47e2b6f00 9
igor_v 0:8ad47e2b6f00 10 #define I2C_IDLE 1
igor_v 0:8ad47e2b6f00 11 #define I2C_BUSY 0
igor_v 0:8ad47e2b6f00 12
igor_v 0:8ad47e2b6f00 13 #define I2CONSET_I2EN 0x0000040 /* I2C Control Set Register */
igor_v 0:8ad47e2b6f00 14 #define I2CONSET_AA 0x0000004
igor_v 0:8ad47e2b6f00 15 #define I2CONSET_SI 0x0000008
igor_v 0:8ad47e2b6f00 16 #define I2CONSET_STO 0x0000010
igor_v 0:8ad47e2b6f00 17 #define I2CONSET_STA 0x0000020
igor_v 0:8ad47e2b6f00 18
igor_v 0:8ad47e2b6f00 19 #define I2CONCLR_AAC 0x0000004 /* I2C Control clear Register */
igor_v 0:8ad47e2b6f00 20 #define I2CONCLR_SIC 0x0000008
igor_v 0:8ad47e2b6f00 21 #define I2CONCLR_STAC 0x0000020
igor_v 0:8ad47e2b6f00 22 #define I2CONCLR_I2ENC 0x0000040
igor_v 0:8ad47e2b6f00 23
igor_v 0:8ad47e2b6f00 24 #define I2SCLH_SCLH 0x00000080 /* I2C SCL Duty Cycle High Reg */
igor_v 0:8ad47e2b6f00 25 #define I2SCLL_SCLL 0x00000080 /* I2C SCL Duty Cycle Low Reg */
igor_v 0:8ad47e2b6f00 26
igor_v 0:8ad47e2b6f00 27 #define I2C_WRITELENGTH 0x00000006 /*Buffer length*/
igor_v 0:8ad47e2b6f00 28 #define A_ADDRESS 0x0000005E /*address of slave potentiometer (table 6-2 of pot's manual)*/
igor_v 0:8ad47e2b6f00 29 #define B_ADDRESS 0x0000005C /*address of slave potentiometer (table 6-2 of pot's manual)*/
igor_v 0:8ad47e2b6f00 30 #define WRITE_CMD 0x00000000 /*address of wiper0 register in memory map*/
igor_v 0:8ad47e2b6f00 31
igor_v 0:8ad47e2b6f00 32 //********************************SPI************************************************
igor_v 0:8ad47e2b6f00 33 #define HALFWORDS_FOR_ADCs 3
igor_v 0:8ad47e2b6f00 34
igor_v 0:8ad47e2b6f00 35 #define WRITE_DAC0 0x00000030 //write data to DAC 0
igor_v 0:8ad47e2b6f00 36 #define WRITE_DAC1 0x00000031 //write data to DAC 1
igor_v 0:8ad47e2b6f00 37
igor_v 0:8ad47e2b6f00 38 #define DAC (1<<23) //DAC identifer
igor_v 0:8ad47e2b6f00 39 #define ADC (1<<16) //ADC identifer
igor_v 0:8ad47e2b6f00 40
igor_v 0:8ad47e2b6f00 41 #define SetCS(a) LPC_GPIO0->FIOSET = a //set CS signal for ADC or DAC
igor_v 0:8ad47e2b6f00 42 #define ResetCS(a) LPC_GPIO0->FIOCLR = a //reset CS signal for ADC or DAC
igor_v 0:8ad47e2b6f00 43 #define SetDAC(a) LPC_GPIO0->FIOSET = a //set CS signal for ADC or DAC
igor_v 0:8ad47e2b6f00 44 #define ResetDAC(a) LPC_GPIO0->FIOCLR = a //reset CS signal for ADC or DAC
igor_v 0:8ad47e2b6f00 45
igor_v 0:8ad47e2b6f00 46
igor_v 0:8ad47e2b6f00 47
igor_v 0:8ad47e2b6f00 48 #define SSPCR1_SSE 0x00000002
igor_v 0:8ad47e2b6f00 49
igor_v 0:8ad47e2b6f00 50 #define TX_SSP_EMPT 0x00000001
igor_v 0:8ad47e2b6f00 51 #define RX_SSP_notEMPT 0x00000004
igor_v 0:8ad47e2b6f00 52 #define TX_SSP_notFULL 0x00000002
igor_v 0:8ad47e2b6f00 53 #define RX_SSP_FULL 0x00000008
igor_v 0:8ad47e2b6f00 54 #define SSP_BUSY 0x00000010
igor_v 0:8ad47e2b6f00 55
igor_v 0:8ad47e2b6f00 56 #define ADC_ERR_MSK 0x00000001
igor_v 0:8ad47e2b6f00 57 #define DAC_ERR_MSK 0x00000002
igor_v 0:8ad47e2b6f00 58
igor_v 0:8ad47e2b6f00 59 #define TIMEOUT 1000
igor_v 0:8ad47e2b6f00 60
igor_v 21:bc8c1cec3da6 61 typedef union
igor_v 21:bc8c1cec3da6 62 {
igor_v 21:bc8c1cec3da6 63 int ArrayOut[31];
igor_v 21:bc8c1cec3da6 64 struct {
igor_v 21:bc8c1cec3da6 65 int WP_reg; //e. PLC output voltage
igor_v 21:bc8c1cec3da6 66 int WP_sin; //r. сигнал поиска СРП - синус 250 Гц
igor_v 21:bc8c1cec3da6 67 int WP_pll; //r. выход XOR ФД контура СРП
Kovalev_D 90:d9b6a4bc5065 68 int HF_reg; //e. HFO output voltage
igor_v 21:bc8c1cec3da6 69
igor_v 21:bc8c1cec3da6 70 int HF_dif;
igor_v 0:8ad47e2b6f00 71
igor_v 21:bc8c1cec3da6 72 int WP_Phase_Det_Array[8]; //e. arrays for "worms" output //r. массивы для вывода "червячков"
igor_v 21:bc8c1cec3da6 73 int WP_sin_Array[8];
igor_v 21:bc8c1cec3da6 74 int WP_scope1, WP_scope2; //e. temporary variables for Rate3 monitoring //r. временные переменные для наблюдения в Rate3
igor_v 21:bc8c1cec3da6 75
igor_v 21:bc8c1cec3da6 76 uint32_t F_ras; //e. really output frequency, divided by 16 (for transmission)
igor_v 21:bc8c1cec3da6 77 uint32_t L_Vibro; //e. period of oscillation of the dither drive //r. период колебания вибропривода
igor_v 21:bc8c1cec3da6 78 uint32_t T_Vibro; //e. pulse width of the dither drive //r. длительность импульса вибропривода
igor_v 21:bc8c1cec3da6 79 uint32_t T_VB_pll; //e. PD output of the frequency regulator of the dither drive //r. выход ФД регулятора частоты вибропривода
igor_v 0:8ad47e2b6f00 80
igor_v 21:bc8c1cec3da6 81 int PS_dif;
igor_v 21:bc8c1cec3da6 82 int BINS_dif;
igor_v 21:bc8c1cec3da6 83 int Cnt_Dif;
igor_v 21:bc8c1cec3da6 84 int Cnt_Pls;
igor_v 21:bc8c1cec3da6 85 int Cnt_Mns;
igor_v 21:bc8c1cec3da6 86 int Tmp_Out[6];
igor_v 0:8ad47e2b6f00 87
igor_v 21:bc8c1cec3da6 88 __int64 SF_dif;
igor_v 21:bc8c1cec3da6 89
igor_v 21:bc8c1cec3da6 90 } Str;
igor_v 21:bc8c1cec3da6 91 } OUTPUT;
igor_v 0:8ad47e2b6f00 92
igor_v 0:8ad47e2b6f00 93
igor_v 21:bc8c1cec3da6 94 typedef union
igor_v 21:bc8c1cec3da6 95 {
igor_v 21:bc8c1cec3da6 96 int ArrayIn[3];
igor_v 21:bc8c1cec3da6 97 struct {
igor_v 21:bc8c1cec3da6 98 int Tmp_in[2];
igor_v 21:bc8c1cec3da6 99 int HF_out;
igor_v 21:bc8c1cec3da6 100 int WP_sel;
igor_v 21:bc8c1cec3da6 101 }StrIn;
igor_v 21:bc8c1cec3da6 102 } INPUT;
igor_v 0:8ad47e2b6f00 103
igor_v 0:8ad47e2b6f00 104 extern INPUT Input;
igor_v 0:8ad47e2b6f00 105 extern OUTPUT Output;
Kovalev_D 99:3d8f206ceac2 106 extern volatile uint32_t I2CMasterState;
Kovalev_D 99:3d8f206ceac2 107 extern volatile uint32_t I2CMasterBuffer[];
igor_v 0:8ad47e2b6f00 108 void DAC_ADC_Exchange_Init(void);
igor_v 0:8ad47e2b6f00 109 void DAC_ADC_Exchange(void);
igor_v 0:8ad47e2b6f00 110 void ADC_Input(void);
igor_v 0:8ad47e2b6f00 111
igor_v 0:8ad47e2b6f00 112 void clc_HFO(void);
igor_v 0:8ad47e2b6f00 113
igor_v 0:8ad47e2b6f00 114 int clc_WP_sin(void);
igor_v 0:8ad47e2b6f00 115 void clc_PLC(void);
igor_v 0:8ad47e2b6f00 116 void init_PLC(void);
igor_v 0:8ad47e2b6f00 117
igor_v 0:8ad47e2b6f00 118 void clc_Pulses(void);
igor_v 0:8ad47e2b6f00 119 void SOI_Init(void);
igor_v 0:8ad47e2b6f00 120
igor_v 0:8ad47e2b6f00 121 void VibroDither_SwitchOn(void);
igor_v 0:8ad47e2b6f00 122 void VibroDither_SwitchOff(void);
igor_v 0:8ad47e2b6f00 123 void VibroDither_Set(void);
igor_v 0:8ad47e2b6f00 124 void DACInit(void);
igor_v 0:8ad47e2b6f00 125 void DAC_Output(int);
igor_v 0:8ad47e2b6f00 126 void clc_ThermoSensors(void);
igor_v 0:8ad47e2b6f00 127
igor_v 0:8ad47e2b6f00 128 void Out_G_photo(unsigned, unsigned);
Kovalev_D 89:a0d344db227e 129
igor_v 0:8ad47e2b6f00 130 void G_Photo_Exchange(void);
igor_v 0:8ad47e2b6f00 131
igor_v 21:bc8c1cec3da6 132 //endof file
igor_v 21:bc8c1cec3da6 133
igor_v 1:f2adcae3d304 134 #endif // InputOutput_H
igor_v 0:8ad47e2b6f00 135