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