![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
Global.c@181:0b022246c43c, 2016-07-08 (annotated)
- Committer:
- Kovalev_D
- Date:
- Fri Jul 08 14:58:17 2016 +0000
- Revision:
- 181:0b022246c43c
- Parent:
- 180:375dcd9c0cb6
- Child:
- 182:ebcd2bc3be8f
????
Who changed what in which revision?
User | Revision | Line number | New 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 | |
Kovalev_D | 89:a0d344db227e | 5 | unsigned int VibroReg = 0; //регистр состаяния вибропривода. |
Kovalev_D | 89:a0d344db227e | 6 | unsigned long Global_Time, Time_UART,Time_Sec,Time_vibro,Time_1kHz; |
Kovalev_D | 112:4a96133a1311 | 7 | |
Kovalev_D | 89:a0d344db227e | 8 | unsigned char BuffTemp[100]; |
Kovalev_D | 89:a0d344db227e | 9 | unsigned char Time[500]; |
Kovalev_D | 86:398da56ef751 | 10 | unsigned int Event1Hz; |
Kovalev_D | 124:9ae09249f842 | 11 | unsigned int Event500Hz; |
Kovalev_D | 88:b5c1d9d338d1 | 12 | unsigned int Event1K ; |
Kovalev_D | 88:b5c1d9d338d1 | 13 | unsigned int Event100K; |
Kovalev_D | 88:b5c1d9d338d1 | 14 | unsigned int EventVibro; |
Kovalev_D | 124:9ae09249f842 | 15 | |
Kovalev_D | 124:9ae09249f842 | 16 | unsigned int Time100K; |
Kovalev_D | 88:b5c1d9d338d1 | 17 | unsigned int Time1K; |
Kovalev_D | 124:9ae09249f842 | 18 | unsigned int Time500Hz; |
Kovalev_D | 88:b5c1d9d338d1 | 19 | unsigned int Time1Hz; |
Kovalev_D | 88:b5c1d9d338d1 | 20 | unsigned int Clock1Hz; |
Kovalev_D | 86:398da56ef751 | 21 | unsigned int ShiftD; |
Kovalev_D | 86:398da56ef751 | 22 | unsigned int ShiftL; |
Kovalev_D | 86:398da56ef751 | 23 | |
Kovalev_D | 140:1fbf117fc120 | 24 | |
Kovalev_D | 139:1716152517aa | 25 | |
Kovalev_D | 134:caf4c9cd5052 | 26 | __asm void boot_jump( uint32_t address ){ |
Kovalev_D | 134:caf4c9cd5052 | 27 | LDR SP, [R0] ;Load new stack pointer address |
Kovalev_D | 134:caf4c9cd5052 | 28 | LDR R0, [R0, #4] ;Load new program counter address |
Kovalev_D | 134:caf4c9cd5052 | 29 | BX R0 |
Kovalev_D | 134:caf4c9cd5052 | 30 | } |
Kovalev_D | 134:caf4c9cd5052 | 31 | |
Kovalev_D | 86:398da56ef751 | 32 | void GLD_Init(void) |
Kovalev_D | 86:398da56ef751 | 33 | { |
Kovalev_D | 181:0b022246c43c | 34 | |
Kovalev_D | 90:d9b6a4bc5065 | 35 | int Dummy; // инициализация мусорки для очистки буфера приема. |
Kovalev_D | 89:a0d344db227e | 36 | ///////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 37 | ///////////инициализация таймеров//////////// |
Kovalev_D | 89:a0d344db227e | 38 | ///////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 39 | Init_TIM1(TIME_INTERVAL ); //Timer 1: CCLK / 7812 = 12800.819Hz; Vibro: Timer1/32 = 400.025Hz; 10ms??? |
Kovalev_D | 89:a0d344db227e | 40 | Init_TIM2(); //Timer 2: CCLK / 4 / 250 = 100kHz |
Kovalev_D | 89:a0d344db227e | 41 | ///////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 42 | ///////////////////////////////////////////// |
Kovalev_D | 104:ab1cb4ff56b2 | 43 | Gyro.RgConA = 0xffff; |
Kovalev_D | 104:ab1cb4ff56b2 | 44 | Gyro.RgConB = 0xffff; |
Kovalev_D | 86:398da56ef751 | 45 | ///////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 46 | ///////////обнуление счетчиков/////////////// |
Kovalev_D | 86:398da56ef751 | 47 | ///////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 48 | Global_Time = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 49 | Time_UART = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 50 | Time_Sec = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 51 | Time_vibro = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 52 | Time_1kHz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 53 | Event1Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 54 | Event1K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 55 | Event100K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 56 | EventVibro = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 57 | Time1K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 58 | Time100K = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 59 | Time1Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 60 | Clock1Hz = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 61 | ShiftD = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 62 | ShiftL = 0; |
Kovalev_D | 124:9ae09249f842 | 63 | Event500Hz = 0; |
Kovalev_D | 124:9ae09249f842 | 64 | Time500Hz = 0; |
Kovalev_D | 139:1716152517aa | 65 | |
Kovalev_D | 86:398da56ef751 | 66 | ///////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 67 | ///////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 68 | |
Kovalev_D | 88:b5c1d9d338d1 | 69 | |
Kovalev_D | 88:b5c1d9d338d1 | 70 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 71 | /////////////обнуление переменых для///////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 72 | ///////////расчета значений буферов ВП/////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 73 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 74 | /////////////инициализация переменных в структ вибро///////////////// |
Kovalev_D | 132:2c7bec5cf6fe | 75 | Gyro.FlashMod=0; |
Kovalev_D | 179:2b4e6bc277df | 76 | Gyro.FrqHZ=406; |
Kovalev_D | 88:b5c1d9d338d1 | 77 | Gyro.Frq = Gyro.FrqHZ<<16; |
Kovalev_D | 180:375dcd9c0cb6 | 78 | Gyro.AmpPer=40; |
Kovalev_D | 88:b5c1d9d338d1 | 79 | Gyro.AmpPerDel=10; |
Kovalev_D | 88:b5c1d9d338d1 | 80 | Gyro.Amp = 10*65535; |
Kovalev_D | 180:375dcd9c0cb6 | 81 | Gyro.AmpMin =5;// минимальное значение AmpT; |
Kovalev_D | 88:b5c1d9d338d1 | 82 | Gyro.AmpTD =30;// максимальное значение AmpT; (AmpT частота ошумления) |
Kovalev_D | 88:b5c1d9d338d1 | 83 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 106:250ddd8629c6 | 84 | Gyro.CuruAngle = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 85 | Pulse_8Point = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 86 | Pulse_16Point = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 87 | Pulse_16PointD = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 88 | Pulse_32Point = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 89 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 90 | /////////////предварительное заполнение////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 91 | ////////////////буферов вибропривода///////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 92 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 93 | for (int i = 0; i < 32; i++ ) { |
Kovalev_D | 88:b5c1d9d338d1 | 94 | Buff_16Point[i] = 0x00; |
Kovalev_D | 88:b5c1d9d338d1 | 95 | Buff_8Point[i] = 0x00; |
Kovalev_D | 88:b5c1d9d338d1 | 96 | Buff_32Point[i] = 0x00; |
Kovalev_D | 88:b5c1d9d338d1 | 97 | Buff_16PointD[i] = 0x00; |
Kovalev_D | 129:406995a91322 | 98 | GyroP.Array[i] = 0x00; |
Kovalev_D | 129:406995a91322 | 99 | } |
Kovalev_D | 129:406995a91322 | 100 | |
Kovalev_D | 129:406995a91322 | 101 | for (int i = 0; i < 170; i++ ) { |
Kovalev_D | 129:406995a91322 | 102 | GyroP.Array[i] =i; |
Kovalev_D | 88:b5c1d9d338d1 | 103 | } |
Kovalev_D | 88:b5c1d9d338d1 | 104 | //////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 105 | //////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 106 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 107 | /////////////обнуление переменых для///////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 108 | //////////////////переменных АЦП///////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 109 | ///////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 110 | // Temp_AMP=0; |
Kovalev_D | 96:1c8536458119 | 111 | Temp_AMP64P=0; |
Kovalev_D | 88:b5c1d9d338d1 | 112 | Temp_ADC_2=0; |
Kovalev_D | 88:b5c1d9d338d1 | 113 | Temp_ADC_3=0; |
Kovalev_D | 88:b5c1d9d338d1 | 114 | Temp_ADC_4=0; |
Kovalev_D | 88:b5c1d9d338d1 | 115 | Temp_ADC_5=0; |
Kovalev_D | 88:b5c1d9d338d1 | 116 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 117 | /////////////предварительное заполнение////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 118 | /////////////////////буферов АЦП///////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 119 | ///////////////////////////////////////////////////// |
Kovalev_D | 95:dd51e577e114 | 120 | for (int i = 0; i < 32; i++ ) { |
Kovalev_D | 88:b5c1d9d338d1 | 121 | Buff_ADC_1[i] = 0; // ампл ацп. |
Kovalev_D | 88:b5c1d9d338d1 | 122 | Buff_ADC_2[i] = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 123 | Buff_ADC_3[i] = 0; |
Kovalev_D | 88:b5c1d9d338d1 | 124 | Buff_ADC_4[i] = 0; |
Kovalev_D | 95:dd51e577e114 | 125 | } |
Kovalev_D | 95:dd51e577e114 | 126 | for (int i = 0; i < 256; i++ ) { |
Kovalev_D | 95:dd51e577e114 | 127 | Buff_ADC_5[i]= 0; |
Kovalev_D | 88:b5c1d9d338d1 | 128 | } |
Kovalev_D | 96:1c8536458119 | 129 | for (int i = 0; i < 256; i++ ) { |
Kovalev_D | 96:1c8536458119 | 130 | Buff_AMP64P[i]= 0; |
Kovalev_D | 96:1c8536458119 | 131 | } |
Kovalev_D | 96:1c8536458119 | 132 | for (int i = 0; i < 256; i++ ) { |
Kovalev_D | 96:1c8536458119 | 133 | Buff_AMP[i]= 0; |
Kovalev_D | 96:1c8536458119 | 134 | } |
Kovalev_D | 88:b5c1d9d338d1 | 135 | //////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 136 | //////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 137 | |
Kovalev_D | 88:b5c1d9d338d1 | 138 | |
Kovalev_D | 88:b5c1d9d338d1 | 139 | |
Kovalev_D | 88:b5c1d9d338d1 | 140 | |
Kovalev_D | 88:b5c1d9d338d1 | 141 | |
Kovalev_D | 92:c892f0311aa7 | 142 | |
Kovalev_D | 88:b5c1d9d338d1 | 143 | Gyro.SOC_Out=0xDD; |
Kovalev_D | 163:affb5706d191 | 144 | Gyro.Firmware_Version =0x11; //версия программы |
Kovalev_D | 163:affb5706d191 | 145 | Gyro.GLD_Serial = 0xD7; //серийный номер |
Kovalev_D | 181:0b022246c43c | 146 | Gyro.My_Addres = 2; //адрес глд |
Kovalev_D | 86:398da56ef751 | 147 | Gyro.Discharg = StartDischarg; |
Kovalev_D | 86:398da56ef751 | 148 | Gyro.BackLight = StartBackLight; |
Kovalev_D | 92:c892f0311aa7 | 149 | |
Kovalev_D | 88:b5c1d9d338d1 | 150 | |
Kovalev_D | 89:a0d344db227e | 151 | |
Kovalev_D | 89:a0d344db227e | 152 | |
Kovalev_D | 88:b5c1d9d338d1 | 153 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 154 | //////инициализация цап_LPC (р0.26 цап выход)//////// |
Kovalev_D | 88:b5c1d9d338d1 | 155 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 156 | LPC_PINCON->PINSEL1 = 0x00200000; |
Kovalev_D | 88:b5c1d9d338d1 | 157 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 158 | ////////////начальное значение для цап/////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 159 | //////////////////середина шкалы///////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 160 | ///////////////////////////////////////////////////// |
Kovalev_D | 159:38f39c0c143f | 161 | |
Kovalev_D | 159:38f39c0c143f | 162 | // Spi.DAC_A = 20000; |
Kovalev_D | 159:38f39c0c143f | 163 | Spi.DAC_A = 0x7fff; |
Kovalev_D | 159:38f39c0c143f | 164 | //Spi.DAC_A = 44000; |
Kovalev_D | 159:38f39c0c143f | 165 | |
Kovalev_D | 157:1069c80f4944 | 166 | //Spi.DAC_B = 0x7fff; //старое начало |
Kovalev_D | 169:140743e3bb96 | 167 | Spi.DAC_B = 39200; //40000 |
Kovalev_D | 163:affb5706d191 | 168 | //Spi.DAC_B = 11000; //для просмотра мод |
Kovalev_D | 158:0c8342e1837a | 169 | |
Kovalev_D | 159:38f39c0c143f | 170 | Gyro.StrayHZ = 1000; |
Kovalev_D | 159:38f39c0c143f | 171 | Gyro.StrayHZ_flag = 0; |
Kovalev_D | 159:38f39c0c143f | 172 | Gyro.LogHZ = 0; |
Kovalev_D | 159:38f39c0c143f | 173 | |
Kovalev_D | 159:38f39c0c143f | 174 | Gyro.StrayPLC_Pls =1000; |
Kovalev_D | 159:38f39c0c143f | 175 | Gyro.StrayPLC_Mns = -1000; |
Kovalev_D | 159:38f39c0c143f | 176 | Gyro.StrayPLC_2Mode = 2000; |
Kovalev_D | 159:38f39c0c143f | 177 | Gyro.StrayPLC_flag = 0; |
Kovalev_D | 159:38f39c0c143f | 178 | Gyro.LogPLC = 0; |
Kovalev_D | 159:38f39c0c143f | 179 | Gyro.PLC_Lern = 0; |
Kovalev_D | 168:f4a6abb18358 | 180 | Gyro.ModJump = 0; |
Kovalev_D | 168:f4a6abb18358 | 181 | Gyro.PLC_Error2Mode =500; //для записи мод |
Kovalev_D | 159:38f39c0c143f | 182 | //Gyro.PLC_Error2Mode = 65; //стандартное включение прибора регулировка (65 начальная задержка для поиска АМП мах) |
Kovalev_D | 86:398da56ef751 | 183 | //////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 184 | /////////////поправочный коэффициент///////////////// |
Kovalev_D | 86:398da56ef751 | 185 | /////////для цапов (граници +-12.5 вольт)//////////// |
Kovalev_D | 86:398da56ef751 | 186 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 187 | K_DAC=65535.0/(65535.0+(deltaDAC+deltaDAC/2)); |
Kovalev_D | 86:398da56ef751 | 188 | K_DAC=0.8; |
Kovalev_D | 88:b5c1d9d338d1 | 189 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 190 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 191 | |
igor_v | 16:18e3fd7b92d0 | 192 | |
igor_v | 16:18e3fd7b92d0 | 193 | |
Kovalev_D | 86:398da56ef751 | 194 | secPuls =0;// переменная для конопки поджига аск глд(временная) |
Kovalev_D | 88:b5c1d9d338d1 | 195 | |
Kovalev_D | 86:398da56ef751 | 196 | |
Kovalev_D | 86:398da56ef751 | 197 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 198 | /////////////обнуление переменых для///////////////// |
Kovalev_D | 86:398da56ef751 | 199 | ///////////////переменных энкодера/////////////////// |
Kovalev_D | 86:398da56ef751 | 200 | ///////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 201 | Gyro.CaunPlus =0; |
Kovalev_D | 112:4a96133a1311 | 202 | Gyro.CaunMin =0; |
Kovalev_D | 88:b5c1d9d338d1 | 203 | Cur_QEI=0; |
Kovalev_D | 86:398da56ef751 | 204 | Last_QEI=0; |
Kovalev_D | 86:398da56ef751 | 205 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 206 | /////////////инициализация энкодера////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 207 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 208 | LPC_SC->PCONP |= (1<<18);//0x00040000; включение квадратурного энкодера. |
Kovalev_D | 170:d099c3025f87 | 209 | LPC_SC->PCLKSEL1 |= 0x00000001; // выбор частоты для кв.э. CLK=103MHz |
Kovalev_D | 87:7e575d26d6d0 | 210 | LPC_PINCON->PINSEL3 &= ~0x4100; |
Kovalev_D | 87:7e575d26d6d0 | 211 | LPC_PINCON->PINSEL3 |= 0x4100; //P1.20, p1.23 установить как входы кв.э |
Kovalev_D | 89:a0d344db227e | 212 | LPC_PINCON->PINMODE3 |= 0x3C300; //P1.20, p1.23 |
Kovalev_D | 86:398da56ef751 | 213 | |
Kovalev_D | 98:95b8e79f13e1 | 214 | |
Kovalev_D | 87:7e575d26d6d0 | 215 | LPC_QEI->MAXPOS = MAX_QEI_CNT; //LPC_QEI->"регистор максимального положения" = 2147483646 |
Kovalev_D | 89:a0d344db227e | 216 | LPC_QEI->FILTER = 2; // фильтр( ?? ) |
Kovalev_D | 87:7e575d26d6d0 | 217 | LPC_QEI->CON = 0xF; //сбросить в ноль все счетчики кв.э. (скорость, направление, позицию и тд) |
Kovalev_D | 87:7e575d26d6d0 | 218 | LPC_QEI->CONF = (0<<2) |(0<<1); //Quadrature inputs, no inverting,only A pulses are counted |
Kovalev_D | 87:7e575d26d6d0 | 219 | |
Kovalev_D | 87:7e575d26d6d0 | 220 | LPC_QEI->CLR = 0x1fff; //r. сбросить все прерывания |
Kovalev_D | 87:7e575d26d6d0 | 221 | LPC_QEI->IEC = 0x1fff; //r. запретить прерывание при изменении направления |
Kovalev_D | 87:7e575d26d6d0 | 222 | |
Kovalev_D | 98:95b8e79f13e1 | 223 | /*NVIC_SetPriority(QEI_IRQn, 0); |
Kovalev_D | 98:95b8e79f13e1 | 224 | NVIC_EnableIRQ(QEI_IRQn);*/ |
Kovalev_D | 88:b5c1d9d338d1 | 225 | ////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 226 | ////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 227 | |
Kovalev_D | 88:b5c1d9d338d1 | 228 | |
Kovalev_D | 89:a0d344db227e | 229 | ////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 230 | ///////////////////////I2C//////////////////////////// |
Kovalev_D | 89:a0d344db227e | 231 | ////////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 232 | |
Kovalev_D | 89:a0d344db227e | 233 | LPC_SC->PCONP |= (1 << 19);//включение интерфейса I2C. |
Kovalev_D | 88:b5c1d9d338d1 | 234 | |
Kovalev_D | 89:a0d344db227e | 235 | /* set PIO0.27 and PIO0.28 to I2C0 SDA and SCK */ |
Kovalev_D | 89:a0d344db227e | 236 | /* function to 01 on both SDA and SCK. */ |
Kovalev_D | 89:a0d344db227e | 237 | LPC_PINCON->PINSEL1 &= ~0x03C00000; //P0.27 - SDA. |
Kovalev_D | 89:a0d344db227e | 238 | LPC_PINCON->PINSEL1 |= 0x01400000; //P0.28 - SCK. |
Kovalev_D | 86:398da56ef751 | 239 | |
Kovalev_D | 89:a0d344db227e | 240 | // подтверждение Флаг флаг разрешения |
Kovalev_D | 89:a0d344db227e | 241 | /*сброс флагоф флага прерывания I2C старта интерфейса I2C */ |
Kovalev_D | 89:a0d344db227e | 242 | LPC_I2C0->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC; // установка микроконтроллера в режим мастера |
Kovalev_D | 86:398da56ef751 | 243 | |
Kovalev_D | 89:a0d344db227e | 244 | /*--- Reset registers ---*/ |
Kovalev_D | 89:a0d344db227e | 245 | LPC_I2C0->SCLL = I2SCLL_SCLL; // - счетчик scl low time period |
Kovalev_D | 89:a0d344db227e | 246 | LPC_I2C0->SCLH = I2SCLH_SCLH; // - счетчик scl high time period |
Kovalev_D | 99:3d8f206ceac2 | 247 | |
Kovalev_D | 99:3d8f206ceac2 | 248 | I2CMasterBuffer[0] = A_ADDRESS; |
Kovalev_D | 99:3d8f206ceac2 | 249 | I2CMasterBuffer[1] = WRITE_CMD; |
Kovalev_D | 99:3d8f206ceac2 | 250 | I2CMasterBuffer[3] = B_ADDRESS; |
Kovalev_D | 99:3d8f206ceac2 | 251 | I2CMasterBuffer[4] = WRITE_CMD; |
Kovalev_D | 99:3d8f206ceac2 | 252 | |
Kovalev_D | 89:a0d344db227e | 253 | LPC_I2C0->CONSET = I2CONSET_I2EN; //включение интерфейса I2C. |
Kovalev_D | 89:a0d344db227e | 254 | ////////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 255 | ////////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 256 | |
Kovalev_D | 86:398da56ef751 | 257 | |
Kovalev_D | 86:398da56ef751 | 258 | |
Kovalev_D | 92:c892f0311aa7 | 259 | |
Kovalev_D | 92:c892f0311aa7 | 260 | |
Kovalev_D | 92:c892f0311aa7 | 261 | |
Kovalev_D | 92:c892f0311aa7 | 262 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 263 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 264 | //////////////////////////SPI////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 265 | /////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 266 | Dummy = Dummy; |
Kovalev_D | 92:c892f0311aa7 | 267 | |
Kovalev_D | 92:c892f0311aa7 | 268 | /* Enable AHB clock to the SSP0, SSP1 */ |
Kovalev_D | 92:c892f0311aa7 | 269 | LPC_SC->PCONP |= (0x1<<21); // включение SSP0. |
Kovalev_D | 92:c892f0311aa7 | 270 | |
Kovalev_D | 92:c892f0311aa7 | 271 | /* выбор частоты для переферии используем по умолчания с делителем основной на 4 */ |
Kovalev_D | 92:c892f0311aa7 | 272 | LPC_SC->PCLKSEL1 &= ~(0x3<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/8 |
Kovalev_D | 92:c892f0311aa7 | 273 | LPC_SC->PCLKSEL1 |= (0x0<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/ |
Kovalev_D | 92:c892f0311aa7 | 274 | |
Kovalev_D | 92:c892f0311aa7 | 275 | // P0.15~0.18 as SSP0 |
Kovalev_D | 92:c892f0311aa7 | 276 | LPC_PINCON->PINSEL0 &= ~(0x3UL<<30); //установит Р 0.15 |
Kovalev_D | 92:c892f0311aa7 | 277 | LPC_PINCON->PINSEL0 |= (0x2UL<<30); //частота для синхронизациии Master - slave |
Kovalev_D | 92:c892f0311aa7 | 278 | |
Kovalev_D | 92:c892f0311aa7 | 279 | LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)); // устанивоить Р 0.17 и Р 0.18 |
Kovalev_D | 92:c892f0311aa7 | 280 | LPC_PINCON->PINSEL1 |= ((0x2<<2)|(0x2<<4)); // как MISO0 и MOSI0 |
Kovalev_D | 92:c892f0311aa7 | 281 | |
Kovalev_D | 92:c892f0311aa7 | 282 | LPC_PINCON->PINMODE0 &= ~(0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 283 | LPC_PINCON->PINMODE0 |= (0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 284 | |
Kovalev_D | 92:c892f0311aa7 | 285 | LPC_PINCON->PINMODE1 &= ~((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 286 | LPC_PINCON->PINMODE1 |= ((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 92:c892f0311aa7 | 287 | |
Kovalev_D | 92:c892f0311aa7 | 288 | LPC_SSP0->CR0 = ((3<<8)|(0<<7)|(0<<4) |0xF); // (0xF)-установление DSS(Data sise select) в 16-битный формат, (3<<8 scr - выбор частоты), |
Kovalev_D | 92:c892f0311aa7 | 289 | // низкий уровень линии тактирования между кадрами, прикрепление передачи к первому нарастанию тактового мигнала |
Kovalev_D | 92:c892f0311aa7 | 290 | // формат кадра TI. |
Kovalev_D | 92:c892f0311aa7 | 291 | |
Kovalev_D | 92:c892f0311aa7 | 292 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */ |
Kovalev_D | 92:c892f0311aa7 | 293 | LPC_SSP0->CPSR = 0x2; // freq = CLK/(cpsdvr*(scr+1)) = 1.6 MHz |
Kovalev_D | 92:c892f0311aa7 | 294 | |
Kovalev_D | 92:c892f0311aa7 | 295 | /*SSP enable, master mode */ |
Kovalev_D | 92:c892f0311aa7 | 296 | LPC_SSP0->CR1 = SSPCR1_SSE; |
Kovalev_D | 92:c892f0311aa7 | 297 | // LPC_SSP1->CR1 = SSPCR1_SSE; |
Kovalev_D | 92:c892f0311aa7 | 298 | while (LPC_SSP0->SR & SSP_BUSY); |
Kovalev_D | 92:c892f0311aa7 | 299 | while (LPC_SSP0->SR & RX_SSP_notEMPT) /* clear the RxFIFO */ |
Kovalev_D | 92:c892f0311aa7 | 300 | Dummy = LPC_SSP0->DR; |
Kovalev_D | 92:c892f0311aa7 | 301 | //all pins after reset is in GPIO mode, so CS pins needn't to configure |
Kovalev_D | 92:c892f0311aa7 | 302 | LPC_GPIO0->FIODIR |= (1<<16); // P0.16 defined as CS for ADC |
Kovalev_D | 92:c892f0311aa7 | 303 | LPC_GPIO0->FIOSET |= (1<<16); // set CS for ADC |
Kovalev_D | 92:c892f0311aa7 | 304 | |
Kovalev_D | 92:c892f0311aa7 | 305 | LPC_GPIO0->FIODIR |= (1<<23); // P defined as CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 306 | LPC_GPIO0->FIOCLR |= (1<<23); // set CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 307 | while (LPC_SSP1->SR & RX_SSP_notEMPT) |
Kovalev_D | 92:c892f0311aa7 | 308 | Dummy = LPC_SSP1->DR; /* clear the RxFIFO */ |
Kovalev_D | 92:c892f0311aa7 | 309 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 310 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 311 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 92:c892f0311aa7 | 312 | |
Kovalev_D | 92:c892f0311aa7 | 313 | |
Kovalev_D | 92:c892f0311aa7 | 314 | |
Kovalev_D | 92:c892f0311aa7 | 315 | |
Kovalev_D | 86:398da56ef751 | 316 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 317 | /////////////////инициализация ног/////////////////// |
Kovalev_D | 86:398da56ef751 | 318 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 319 | |
Kovalev_D | 89:a0d344db227e | 320 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 321 | Gyro.PinRegOld = 0xffffffff; |
Kovalev_D | 88:b5c1d9d338d1 | 322 | Gyro.PinReg = 0; // всЁ выключенно |
Kovalev_D | 88:b5c1d9d338d1 | 323 | PinCheng(); |
Kovalev_D | 89:a0d344db227e | 324 | ///////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 325 | |
Kovalev_D | 87:7e575d26d6d0 | 326 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 327 | //////////////отладочный светодиод/////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 328 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 329 | |
Kovalev_D | 98:95b8e79f13e1 | 330 | LPC_PINCON->PINSEL0 &= ~(0x00<<28); |
Kovalev_D | 98:95b8e79f13e1 | 331 | LPC_PINCON->PINSEL0 |= (0x00<<28); // а нужно, ведь по умолчаниб у них 0 функция. попробоввать без них потом убрать |
Kovalev_D | 98:95b8e79f13e1 | 332 | LPC_PINCON->PINMODE0 |= (0x3<<28); |
Kovalev_D | 87:7e575d26d6d0 | 333 | LPC_GPIO1->FIODIR |= (1<<30); |
Kovalev_D | 87:7e575d26d6d0 | 334 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 335 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 336 | |
Kovalev_D | 88:b5c1d9d338d1 | 337 | |
Kovalev_D | 87:7e575d26d6d0 | 338 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 339 | ////////////////управление уартом//////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 340 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 341 | LPC_GPIO2->FIODIR |= (1<<7);//направление ноги uart enable |
Kovalev_D | 87:7e575d26d6d0 | 342 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 343 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 344 | |
Kovalev_D | 88:b5c1d9d338d1 | 345 | |
Kovalev_D | 88:b5c1d9d338d1 | 346 | |
Kovalev_D | 87:7e575d26d6d0 | 347 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 348 | ///////////////////////поджиг//////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 349 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 350 | LPC_PINCON->PINSEL0 &= ~(3<<8); //e. P0.4 is GPIO pin (запись ( 00 ) в 9:8 бит PISEL0 выбор P0.4 как GPIO) |
Kovalev_D | 98:95b8e79f13e1 | 351 | LPC_PINCON->PINMODE0 |= (3<<8); //e. P0.4 is GPIO pin (запись ( 11 ) в 9:8 бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 352 | LPC_GPIO0->FIODIR |= (1<<4); //e. P0.4 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.4 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 353 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 354 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 355 | |
Kovalev_D | 88:b5c1d9d338d1 | 356 | |
Kovalev_D | 88:b5c1d9d338d1 | 357 | |
Kovalev_D | 87:7e575d26d6d0 | 358 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 359 | /////////////////////вибро 1///////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 360 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 361 | LPC_PINCON->PINSEL3 &= ~(0x00<<18); //e. P1.25 is GPIO pin |
Kovalev_D | 98:95b8e79f13e1 | 362 | LPC_PINCON->PINSEL3 |= (0x00<<18); //e. P1.25 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 363 | LPC_PINCON->PINMODE3 |= (3<<18); //e. P1.25 (включениe подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 364 | LPC_GPIO1->FIODIR |= (1<<25); //e. P0.5 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 365 | LPC_GPIO1->FIOCLR |= (1<<25); |
Kovalev_D | 88:b5c1d9d338d1 | 366 | ////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 367 | //////////////////////вибро 2///////////////////////// |
Kovalev_D | 89:a0d344db227e | 368 | ////////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 369 | LPC_PINCON->PINSEL3 &= ~(0x00<<24); //e. P1.28 is GPIO pin |
Kovalev_D | 98:95b8e79f13e1 | 370 | LPC_PINCON->PINSEL3 |= (0x00<<24); //e. P1.28 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 371 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 372 | LPC_GPIO1->FIODIR |= (1<<28); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 373 | LPC_GPIO1->FIOCLR |= (1<<28); |
Kovalev_D | 87:7e575d26d6d0 | 374 | ///////////////////////////////////////////////////// |
Kovalev_D | 87:7e575d26d6d0 | 375 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 376 | |
Kovalev_D | 88:b5c1d9d338d1 | 377 | |
Kovalev_D | 88:b5c1d9d338d1 | 378 | |
Kovalev_D | 87:7e575d26d6d0 | 379 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 380 | /////////////инициализация подсветки///////////////// |
Kovalev_D | 87:7e575d26d6d0 | 381 | ///////////////////////////////////////////////////// |
Kovalev_D | 98:95b8e79f13e1 | 382 | LPC_PINCON->PINSEL2 &= ~(0x00<<24); |
Kovalev_D | 98:95b8e79f13e1 | 383 | LPC_PINCON->PINSEL2 |= (0x00<<24); //e. P2.12 is GPIO pin |
Kovalev_D | 87:7e575d26d6d0 | 384 | LPC_PINCON->PINMODE3 |= (3<<24); //e. P1.28 is GPIO pin (запись ( 11 ) в бит PINMODE0 "для включения подтягивающего резистора") |
Kovalev_D | 87:7e575d26d6d0 | 385 | LPC_GPIO2->FIODIR |= (1<<12); //e. P1.28 is output (запись ( 1 ) в 5 бит FIODIR выбор P0.5 как выход) |
Kovalev_D | 87:7e575d26d6d0 | 386 | LPC_GPIO2->FIOCLR |= (1<<12); |
Kovalev_D | 88:b5c1d9d338d1 | 387 | /////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 388 | /////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 389 | |
Kovalev_D | 88:b5c1d9d338d1 | 390 | |
Kovalev_D | 88:b5c1d9d338d1 | 391 | /////////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 392 | /////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 393 | ///////////////////включение таймеров////////////////// |
Kovalev_D | 89:a0d344db227e | 394 | /////////////////////////////////////////////////////// |
Kovalev_D | 86:398da56ef751 | 395 | enable_timer1(); |
Kovalev_D | 86:398da56ef751 | 396 | enable_timer2(); |
Kovalev_D | 89:a0d344db227e | 397 | /////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 398 | |
Kovalev_D | 89:a0d344db227e | 399 | ////////////////////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 400 | // LPC_GPIO0->FIOCLR = (1<<5);/////////////отключение поджига |
Kovalev_D | 90:d9b6a4bc5065 | 401 | |
Kovalev_D | 90:d9b6a4bc5065 | 402 | |
Kovalev_D | 90:d9b6a4bc5065 | 403 | |
Kovalev_D | 90:d9b6a4bc5065 | 404 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 405 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 406 | //////////////////////////SPI////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 407 | /////////////////////////////////////////////////////// |
Kovalev_D | 90:d9b6a4bc5065 | 408 | Dummy = Dummy; |
Kovalev_D | 90:d9b6a4bc5065 | 409 | |
Kovalev_D | 90:d9b6a4bc5065 | 410 | /* Enable AHB clock to the SSP0, SSP1 */ |
Kovalev_D | 90:d9b6a4bc5065 | 411 | LPC_SC->PCONP |= (0x1<<21); // включение SSP0. |
Kovalev_D | 90:d9b6a4bc5065 | 412 | |
Kovalev_D | 90:d9b6a4bc5065 | 413 | /* выбор частоты для переферии используем по умолчания с делителем основной на 4 */ |
Kovalev_D | 90:d9b6a4bc5065 | 414 | LPC_SC->PCLKSEL1 &= ~(0x3<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/8 |
Kovalev_D | 90:d9b6a4bc5065 | 415 | LPC_SC->PCLKSEL1 |= (0x0<<10); //00 CLK/4; 1 CLK; 2 CLK/2; 3 CLK/ |
Kovalev_D | 90:d9b6a4bc5065 | 416 | |
Kovalev_D | 90:d9b6a4bc5065 | 417 | // P0.15~0.18 as SSP0 |
Kovalev_D | 90:d9b6a4bc5065 | 418 | LPC_PINCON->PINSEL0 &= ~(0x3UL<<30); //установит Р 0.15 |
Kovalev_D | 90:d9b6a4bc5065 | 419 | LPC_PINCON->PINSEL0 |= (0x2UL<<30); //частота для синхронизациии Master - slave |
Kovalev_D | 90:d9b6a4bc5065 | 420 | |
Kovalev_D | 90:d9b6a4bc5065 | 421 | LPC_PINCON->PINSEL1 &= ~((0x3<<0)|(0x3<<2)|(0x3<<4)); // устанивоить Р 0.17 и Р 0.18 |
Kovalev_D | 90:d9b6a4bc5065 | 422 | LPC_PINCON->PINSEL1 |= ((0x2<<2)|(0x2<<4)); // как MISO0 и MOSI0 |
Kovalev_D | 90:d9b6a4bc5065 | 423 | |
Kovalev_D | 90:d9b6a4bc5065 | 424 | LPC_PINCON->PINMODE0 &= ~(0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 425 | LPC_PINCON->PINMODE0 |= (0x3UL<<30);// ? установление на Р 0.15 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 426 | |
Kovalev_D | 90:d9b6a4bc5065 | 427 | LPC_PINCON->PINMODE1 &= ~((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 428 | LPC_PINCON->PINMODE1 |= ((0x3<<2)|(0x3<<4));// ? установление на Р 0.17 и Р 0.18 режима On-Chip pull-down resistor enabled |
Kovalev_D | 90:d9b6a4bc5065 | 429 | |
Kovalev_D | 90:d9b6a4bc5065 | 430 | LPC_SSP0->CR0 = ((3<<8)|(0<<7)|(0<<4) |0xF); // (0xF)-установление DSS(Data sise select) в 16-битный формат, (3<<8 scr - выбор частоты), |
Kovalev_D | 90:d9b6a4bc5065 | 431 | // низкий уровень линии тактирования между кадрами, прикрепление передачи к первому нарастанию тактового мигнала |
Kovalev_D | 90:d9b6a4bc5065 | 432 | // формат кадра TI. |
Kovalev_D | 90:d9b6a4bc5065 | 433 | |
Kovalev_D | 90:d9b6a4bc5065 | 434 | /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */ |
Kovalev_D | 90:d9b6a4bc5065 | 435 | LPC_SSP0->CPSR = 0x2; // freq = CLK/(cpsdvr*(scr+1)) = 1.6 MHz |
Kovalev_D | 90:d9b6a4bc5065 | 436 | |
Kovalev_D | 90:d9b6a4bc5065 | 437 | /*SSP enable, master mode */ |
Kovalev_D | 90:d9b6a4bc5065 | 438 | LPC_SSP0->CR1 = SSPCR1_SSE; |
Kovalev_D | 90:d9b6a4bc5065 | 439 | // LPC_SSP1->CR1 = SSPCR1_SSE; |
Kovalev_D | 90:d9b6a4bc5065 | 440 | while (LPC_SSP0->SR & SSP_BUSY); |
Kovalev_D | 170:d099c3025f87 | 441 | while (LPC_SSP0->SR & RX_SSP_notEMPT) /* clear the RxFIFO */ |
Kovalev_D | 90:d9b6a4bc5065 | 442 | Dummy = LPC_SSP0->DR; |
Kovalev_D | 90:d9b6a4bc5065 | 443 | //all pins after reset is in GPIO mode, so CS pins needn't to configure |
Kovalev_D | 90:d9b6a4bc5065 | 444 | LPC_GPIO0->FIODIR |= (1<<16); // P0.16 defined as CS for ADC |
Kovalev_D | 90:d9b6a4bc5065 | 445 | LPC_GPIO0->FIOSET |= (1<<16); // set CS for ADC |
Kovalev_D | 90:d9b6a4bc5065 | 446 | |
Kovalev_D | 92:c892f0311aa7 | 447 | LPC_GPIO0->FIODIR |= (1<<23); // P defined as CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 448 | LPC_GPIO0->FIOCLR |= (1<<23); // set CS for DAC |
Kovalev_D | 92:c892f0311aa7 | 449 | while (LPC_SSP1->SR & RX_SSP_notEMPT) |
Kovalev_D | 92:c892f0311aa7 | 450 | Dummy = LPC_SSP1->DR; /* clear the RxFIFO */ |
Kovalev_D | 90:d9b6a4bc5065 | 451 | |
Kovalev_D | 86:398da56ef751 | 452 | } |
igor_v | 13:e2a1d18677b8 | 453 | |
igor_v | 0:8ad47e2b6f00 | 454 | |
igor_v | 0:8ad47e2b6f00 | 455 | |
igor_v | 0:8ad47e2b6f00 | 456 | |
igor_v | 0:8ad47e2b6f00 | 457 |