fork

Dependencies:   mbed

Fork of LG by igor Apu

Committer:
igor_v
Date:
Sat Jan 30 13:00:39 2016 +0000
Revision:
0:8ad47e2b6f00
Child:
21:bc8c1cec3da6
2016_01_30;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
igor_v 0:8ad47e2b6f00 1 #include "Global.h"
igor_v 0:8ad47e2b6f00 2
igor_v 0:8ad47e2b6f00 3
igor_v 0:8ad47e2b6f00 4 /******************************************************************************
igor_v 0:8ad47e2b6f00 5 ** Function name: LoadFlashParam
igor_v 0:8ad47e2b6f00 6 **
igor_v 0:8ad47e2b6f00 7 ** Descriptions: Load of the parameters from the flash memory
igor_v 0:8ad47e2b6f00 8 **
igor_v 0:8ad47e2b6f00 9 ** parameters: None
igor_v 0:8ad47e2b6f00 10 ** Returned value: None
igor_v 0:8ad47e2b6f00 11 **
igor_v 0:8ad47e2b6f00 12 ******************************************************************************/
igor_v 0:8ad47e2b6f00 13 void LoadFlashParam(unsigned source)
igor_v 0:8ad47e2b6f00 14 {
igor_v 0:8ad47e2b6f00 15 if (source == FromFLASH)
igor_v 0:8ad47e2b6f00 16 {
igor_v 0:8ad47e2b6f00 17 while (LPC_GPDMACH3->CConfig & (1<<17)); //e. wait while DMA channel3 is busy
igor_v 0:8ad47e2b6f00 18
igor_v 0:8ad47e2b6f00 19 if (LPC_GPDMA->RawIntErrStat & INT_ERR_TC)
igor_v 0:8ad47e2b6f00 20 LPC_GPDMA->IntErrClr |= INT_ERR_TC; //e. an errors found, reset interrupt
igor_v 0:8ad47e2b6f00 21
igor_v 0:8ad47e2b6f00 22 else if (LPC_GPDMA->RawIntTCStat & INT_ERR_TC)
igor_v 0:8ad47e2b6f00 23 { //e. successful loading complete
igor_v 0:8ad47e2b6f00 24 LPC_GPDMA->IntTCClear |= INT_ERR_TC;
igor_v 0:8ad47e2b6f00 25 if (Device_blk.Str.Header_Word == HEADER_WORD_CONST) //e. flash contain valid data
igor_v 0:8ad47e2b6f00 26 return;
igor_v 0:8ad47e2b6f00 27 }
igor_v 0:8ad47e2b6f00 28 else
igor_v 0:8ad47e2b6f00 29 { //e. transfer was not started, start it immediatly
igor_v 0:8ad47e2b6f00 30 FlashDMA_Init();
igor_v 0:8ad47e2b6f00 31 return;
igor_v 0:8ad47e2b6f00 32 }
igor_v 0:8ad47e2b6f00 33 init_DefaultParam(); //e. load parameters by default
igor_v 0:8ad47e2b6f00 34 }
igor_v 0:8ad47e2b6f00 35 else //e. source == ByDefault
igor_v 0:8ad47e2b6f00 36 init_DefaultParam(); //e. load parameters by default
igor_v 0:8ad47e2b6f00 37
igor_v 0:8ad47e2b6f00 38 blt_in_test = ((uint32_t)FIRMWARE_VER << 8) | (Device_blk.Str.Device_SerialNumber & 0x00FF);
igor_v 0:8ad47e2b6f00 39 }
igor_v 0:8ad47e2b6f00 40 /******************************************************************************
igor_v 0:8ad47e2b6f00 41 ** Function name: init_DefaultParam
igor_v 0:8ad47e2b6f00 42 **
igor_v 0:8ad47e2b6f00 43 ** Descriptions: Initialization of variables of computing procedures
igor_v 0:8ad47e2b6f00 44 **
igor_v 0:8ad47e2b6f00 45 ** parameters: None
igor_v 0:8ad47e2b6f00 46 ** Returned value: None
igor_v 0:8ad47e2b6f00 47 **
igor_v 0:8ad47e2b6f00 48 ******************************************************************************/
igor_v 0:8ad47e2b6f00 49 void init_DefaultParam(void)
igor_v 0:8ad47e2b6f00 50 {
igor_v 0:8ad47e2b6f00 51 int i;
igor_v 0:8ad47e2b6f00 52
igor_v 0:8ad47e2b6f00 53 Device_blk.Str.My_Addres = My_Addres_const; //r. 0x00; //e. direct set of the main device address //r. ������ ���������� ��������� ������ �-��
igor_v 0:8ad47e2b6f00 54
igor_v 0:8ad47e2b6f00 55 Device_blk.Str.HF_ref = HF_REF_CONST; //e. set the reference voltage of the HFO //r. ���������� ������� ���������� ���
igor_v 0:8ad47e2b6f00 56 Device_blk.Str.HF_scl = HF_SCL_CONST; //e. set the gain factor of HFO integrator to ~ 0.001 //r. ���������� �-� �������� ����������� ��� ~ 0.001
igor_v 0:8ad47e2b6f00 57 Device_blk.Str.HF_scl_2 = Device_blk.Str.HF_scl;
igor_v 0:8ad47e2b6f00 58 Device_blk.Str.HF_max = HF_MAX_CONST; //e. maximal value of the regulator //r. ������������ �������� ����������
igor_v 0:8ad47e2b6f00 59
igor_v 0:8ad47e2b6f00 60 Device_blk.Str.HF_min = HF_MIN_CONST; //e. minimal value //r. ����������� ��������
igor_v 0:8ad47e2b6f00 61 Device_blk.Str.RI_ref= RI_REF_CONST; //e. set the reference voltage of DS to (=) 1,5 V //r. ���������� ������� ���������� ��� = 1,5 �
igor_v 0:8ad47e2b6f00 62 Device_blk.Str.RI_scl= RI_SCL_CONST; //e. set the gain factor of DS integrator to ~ 0.01 //r. ���������� �-� �������� ����������� ��� ~ 0.01
igor_v 0:8ad47e2b6f00 63
igor_v 0:8ad47e2b6f00 64 Device_blk.Str.WP_ref = WP_REF_CONST; //e. set the reference signal of CPLC to ~ 0,01 of maximal input value //r. ���������� ������� ������ ��� ~ 0,01 �������� ����.
igor_v 0:8ad47e2b6f00 65 Device_blk.Str.WP_scl = WP_SCL_CONST; //e. the gain factor of the CPLC regulator ~ 0,001 //r. �-� �������� ������� ��� ~ 0,001
igor_v 0:8ad47e2b6f00 66 Device_blk.Str.WP_rup = WP_RUP_CONST; //e. upper value of the heater current //r. ������� �������� ���� �����������
igor_v 0:8ad47e2b6f00 67 Device_blk.Str.WP_rdw = WP_RDW_CONST; //e. lower value of the heater current //r. ������ �������� ���� �����������
igor_v 0:8ad47e2b6f00 68 Device_blk.Str.WP_mdy = WP_MDY_CONST; //e. maximal delay of the reset //r. ������������ �������� ���������
igor_v 0:8ad47e2b6f00 69
igor_v 0:8ad47e2b6f00 70 Device_blk.Str.VB_phs = VB_PHS_CONST; //e. the phase delay parameter of the PLL //r. �������� Phase_���.
igor_v 0:8ad47e2b6f00 71 Device_blk.Str.VB_scl = VB_SCL_CONST; //e. set the gain factor of the PLL of the dither drive //r. ���������� ����������� �������� ��� ������������
igor_v 0:8ad47e2b6f00 72 Device_blk.Str.VB_Fdf_Lo = VB_FDF_LO_CONST; //e. set the F_del parameter //r. ���������� �������� F���
igor_v 0:8ad47e2b6f00 73 Device_blk.Str.VB_Fdf_Hi = VB_FDF_HI_CONST; //e. set the F_del parameter (120000) //r. ���������� �������� F��� (120000)
igor_v 0:8ad47e2b6f00 74 Device_blk.Str.VB_Fsc = VB_FSC_CONST; //e. set the ScaleTau parameter //r. ���������� �������� ScaleTau
igor_v 0:8ad47e2b6f00 75 Device_blk.Str.VB_Tmin = VB_TMIN_CONST; //e. set minimal value of the Tau regulator //r. ����������� �������� ���������� Tau
igor_v 0:8ad47e2b6f00 76 Device_blk.Str.VB_Tmax = VB_TMAX_CONST; //e. set maximal value of the Tau reulator //r. ������������ �������� ���������� Tau
igor_v 0:8ad47e2b6f00 77
igor_v 0:8ad47e2b6f00 78 Device_blk.Str.VB_N = T_VIB_START; //e. ... dither drive //r. ������������
igor_v 0:8ad47e2b6f00 79 Device_blk.Str.VB_Nmin = T_VIB_START - T_VIB_DELTA; //e. minimal value of the N regulator //r. ����������� �������� ���������� N
igor_v 0:8ad47e2b6f00 80 Device_blk.Str.VB_Nmax = T_VIB_START + T_VIB_DELTA; //e. maximal value of the N regulator //r. ������������ �������� ���������� N
igor_v 0:8ad47e2b6f00 81 Device_blk.Str.VB_tau = L_VIB_START; //e. similarly load th pulse width of the dither drive //r. ���������� ��������� ������������ ��������� ������������
igor_v 0:8ad47e2b6f00 82
igor_v 0:8ad47e2b6f00 83 Device_blk.Str.VBN_Tzd = VBN_TZD_CONST; //e. adjusted period of {noise}[??] //r. �������� ������ ���������
igor_v 0:8ad47e2b6f00 84 Device_blk.Str.VBN_Ran = VBN_RAN_CONST; //e. the range of the random component //r. �������� ��������� ������������
igor_v 0:8ad47e2b6f00 85 Device_blk.Str.VBN_k = VBN_K_CONST; //e. ajusted of the {noise}[??] constant //r. �������� ��������� ���������
igor_v 0:8ad47e2b6f00 86
igor_v 0:8ad47e2b6f00 87 Device_blk.Str.PI_a0 = PI_A0_CONST; //e. a0 coefficient of the temperature correction //r. ����������� a0 ������������� ���������
igor_v 0:8ad47e2b6f00 88 Device_blk.Str.PI_a1 = PI_A1_CONST; //e. a1 coefficient of the temperature correction //r. ����������� a1 ������������� ���������
igor_v 0:8ad47e2b6f00 89 Device_blk.Str.PI_a2 = PI_A2_CONST; //e. a2 coefficient of the temperature correction //r. ����������� a2 ������������� ���������
igor_v 0:8ad47e2b6f00 90 Device_blk.Str.PI_a3 = PI_A3_CONST; //e. a3 coefficient of the temperature correction //r. ����������� a3 ������������� ���������
igor_v 0:8ad47e2b6f00 91 Device_blk.Str.PI_a4 = PI_A4_CONST; //e. a4 coefficient of the temperature correction //r. ����������� a4 ������������� ���������
igor_v 0:8ad47e2b6f00 92 Device_blk.Str.PI_a5 = PI_A5_CONST; //e. a5 coefficient of the temperature correction //r. ����������� a5 ������������� ���������
igor_v 0:8ad47e2b6f00 93 Device_blk.Str.PI_a6 = PI_A6_CONST; //e. a6 coefficient of the temperature correction //r. ����������� a6 ������������� ���������
igor_v 0:8ad47e2b6f00 94
igor_v 0:8ad47e2b6f00 95 Device_blk.Str.PI_b1 = PI_B1_CONST; //e. b1 coefficient of the temperature correction //r. ����������� b1 ������������� ���������
igor_v 0:8ad47e2b6f00 96 Device_blk.Str.PI_b2 = PI_B2_CONST; //e. b2 coefficient of the temperature correction //r. ����������� b2 ������������� ���������
igor_v 0:8ad47e2b6f00 97 Device_blk.Str.PI_b3 = PI_B3_CONST; //e. b3 coefficient of the temperature correction //r. ����������� b3 ������������� ���������
igor_v 0:8ad47e2b6f00 98 Device_blk.Str.PI_b4 = PI_B4_CONST; //e. b4 coefficient of the temperature correction //r. ����������� b4 ������������� ���������
igor_v 0:8ad47e2b6f00 99 Device_blk.Str.PI_b5 = PI_B5_CONST; //e. b5 coefficient of the temperature correction //r. ����������� b5 ������������� ���������
igor_v 0:8ad47e2b6f00 100 Device_blk.Str.PI_b6 = PI_B6_CONST; //e. b6 coefficient of the temperature correction //r. ����������� b6 ������������� ���������
igor_v 0:8ad47e2b6f00 101
igor_v 0:8ad47e2b6f00 102 Device_blk.Str.PI_Fsc = PI_FSC_CONST; //e. the S_ds scale parameter //r. ���������� ����������� S���
igor_v 0:8ad47e2b6f00 103 Device_blk.Str.PI_Fb0 = PI_FB0_CONST; //e. the B_ds zero shift of the DS //r. �������� ���� ���� B���
igor_v 0:8ad47e2b6f00 104 Device_blk.Str.PI_scl = PI_SCL_CONST; //e. the Scale scale coefficient of the gyro //r. ���������� �����. ��������� Scale
igor_v 0:8ad47e2b6f00 105 Device_blk.Str.PI_bia = PI_BIA_CONST; //e. the Bias zero shift of the gyro //r. �������� ���� ��������� Bias
igor_v 0:8ad47e2b6f00 106
igor_v 0:8ad47e2b6f00 107 for (i = 0; i <6 ; i++)
igor_v 0:8ad47e2b6f00 108 {
igor_v 0:8ad47e2b6f00 109 Device_blk.Str.Tmp_scal[i] = TMP_SCALE;
igor_v 0:8ad47e2b6f00 110 Device_blk.Str.Tmp_bias[i] = TMP_BIAS;
igor_v 0:8ad47e2b6f00 111 }
igor_v 0:8ad47e2b6f00 112 Device_blk.Str.WP_transition_step = WP_TRANS_STEP;
igor_v 0:8ad47e2b6f00 113 Device_blk.Str.WP_reset = WP_RESET_CONST; //e. default initial position = 0 //r. �������� ��������� �� ��������� = 0
igor_v 0:8ad47e2b6f00 114 Device_blk.Str.WP_reset2 = WP_RESET2_CONST;
igor_v 0:8ad47e2b6f00 115 Device_blk.Str.Gain_Ph_A = G_PHOTO_STRA; //e. load the initial value of the gain factor of photodetectors channels//r. ��������� ��������� �������� �-�� �������� ������� ��������������
igor_v 0:8ad47e2b6f00 116 Device_blk.Str.Gain_Ph_B = G_PHOTO_STRB;
igor_v 0:8ad47e2b6f00 117
igor_v 0:8ad47e2b6f00 118 Device_blk.Str.Device_SerialNumber = DEVICE_SN; //e. serial number of the device is by default written down in the register of self-testing //r. �������� ����� ������� �� ��������� ���������� � ������� ����������������
igor_v 0:8ad47e2b6f00 119
igor_v 0:8ad47e2b6f00 120 } // init_DefaultParam
igor_v 0:8ad47e2b6f00 121 /******************************************************************************
igor_v 0:8ad47e2b6f00 122 ** Function name: FlashDMA_Init
igor_v 0:8ad47e2b6f00 123 **
igor_v 0:8ad47e2b6f00 124 ** Descriptions: Initialisation of DMA channel for flash reading
igor_v 0:8ad47e2b6f00 125 **
igor_v 0:8ad47e2b6f00 126 ** parameters: None
igor_v 0:8ad47e2b6f00 127 ** Returned value: None
igor_v 0:8ad47e2b6f00 128 **
igor_v 0:8ad47e2b6f00 129 ******************************************************************************/
igor_v 0:8ad47e2b6f00 130 void FlashDMA_Init()
igor_v 0:8ad47e2b6f00 131 {
igor_v 0:8ad47e2b6f00 132 LPC_GPDMACH3->CConfig &= ~DMAChannelEn;
igor_v 0:8ad47e2b6f00 133
igor_v 0:8ad47e2b6f00 134 LPC_GPDMA->IntTCClear = DMA3_IntTCClear;
igor_v 0:8ad47e2b6f00 135 LPC_GPDMA->IntErrClr = DMA3_IntTCClear;
igor_v 0:8ad47e2b6f00 136
igor_v 0:8ad47e2b6f00 137 /* Ch3 set for M2M transfer from Flash to RAM. */
igor_v 0:8ad47e2b6f00 138 LPC_GPDMACH3->CSrcAddr = 0x40000; //e. address of device parameter block in flash memory (22 sec)
igor_v 0:8ad47e2b6f00 139 LPC_GPDMACH3->CDestAddr = (uint32_t)&(Device_blk.Array);//e. address of device parameter block in RAM
igor_v 0:8ad47e2b6f00 140
igor_v 0:8ad47e2b6f00 141 LPC_GPDMACH3->CControl = ((sizeof(Device_blk.Array))>>2)|SrcBSize_1 |DstBSize_1
igor_v 0:8ad47e2b6f00 142 |SrcWidth_32b |DstWidth_32b |SrcInc |DstInc |TCIntEnabl;
igor_v 0:8ad47e2b6f00 143
igor_v 0:8ad47e2b6f00 144 LPC_GPDMACH3->CConfig = MaskTCInt |MaskErrInt|DMA_MEMORY |DMA_MEMORY |(M2M << 11)| DMAChannelEn;
igor_v 0:8ad47e2b6f00 145
igor_v 0:8ad47e2b6f00 146 return;
igor_v 0:8ad47e2b6f00 147 }
igor_v 0:8ad47e2b6f00 148