![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fork
Fork of LG by
SPI.c@96:1c8536458119, 2016-03-28 (annotated)
- Committer:
- Kovalev_D
- Date:
- Mon Mar 28 15:23:40 2016 +0000
- Revision:
- 96:1c8536458119
- Parent:
- 95:dd51e577e114
- Child:
- 99:3d8f206ceac2
1
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 | struct SPI Spi; |
Kovalev_D | 86:398da56ef751 | 3 | unsigned int Temp_AMP; |
Kovalev_D | 96:1c8536458119 | 4 | unsigned int Temp_AMP64P; |
igor_v | 31:c783288001b5 | 5 | |
Kovalev_D | 86:398da56ef751 | 6 | unsigned int Temp_ADC_2; |
Kovalev_D | 86:398da56ef751 | 7 | unsigned int Temp_ADC_3; |
Kovalev_D | 86:398da56ef751 | 8 | unsigned int Temp_ADC_4; |
Kovalev_D | 86:398da56ef751 | 9 | unsigned int Temp_ADC_5; |
igor_v | 31:c783288001b5 | 10 | |
igor_v | 31:c783288001b5 | 11 | |
Kovalev_D | 95:dd51e577e114 | 12 | unsigned int Buff_ADC_1 [32]; |
Kovalev_D | 95:dd51e577e114 | 13 | unsigned int Buff_ADC_2 [32]; |
Kovalev_D | 95:dd51e577e114 | 14 | unsigned int Buff_ADC_3 [32]; |
Kovalev_D | 95:dd51e577e114 | 15 | unsigned int Buff_ADC_4 [32]; |
igor_v | 51:81f47b817071 | 16 | |
igor_v | 31:c783288001b5 | 17 | unsigned int Buff_ADC_5 [256]; |
igor_v | 31:c783288001b5 | 18 | unsigned int Buff_AMP [256]; |
Kovalev_D | 96:1c8536458119 | 19 | unsigned int Buff_AMP64P [256]; |
igor_v | 31:c783288001b5 | 20 | unsigned int SinPLC[64]= {1023, 1016, 1006, 993, 976, 954, 904, 874, 841, 806, 768, 728, |
igor_v | 31:c783288001b5 | 21 | 687, 645, 601, 557, 500, 379, 337, 296, 256, 219, 183, 150, |
igor_v | 31:c783288001b5 | 22 | 120, 93, 69, 48, 31, 18, 8, 0, 8, 18, 31, 48, |
igor_v | 31:c783288001b5 | 23 | 69, 93, 120, 150, 183, 219, 256, 296, 337, 379, 468, 512, 557, |
igor_v | 31:c783288001b5 | 24 | 601, 645, 687, 728, 768, 806, 841, 874, 904, 954, 976, 993, 1006, |
igor_v | 31:c783288001b5 | 25 | 1016, 1023 |
igor_v | 31:c783288001b5 | 26 | }; |
Kovalev_D | 86:398da56ef751 | 27 | |
Kovalev_D | 89:a0d344db227e | 28 | void SPI_Exchange(void) |
igor_v | 0:8ad47e2b6f00 | 29 | { |
Kovalev_D | 89:a0d344db227e | 30 | unsigned int DummySPI; |
igor_v | 31:c783288001b5 | 31 | |
igor_v | 31:c783288001b5 | 32 | Spi.ADC5 = LPC_SSP0->DR; |
igor_v | 31:c783288001b5 | 33 | Spi.ADC4 = LPC_SSP0->DR; |
igor_v | 31:c783288001b5 | 34 | Spi.ADC3 = LPC_SSP0->DR; |
igor_v | 31:c783288001b5 | 35 | Spi.ADC2 = LPC_SSP0->DR; |
igor_v | 31:c783288001b5 | 36 | Spi.ADC1 = LPC_SSP0->DR; |
igor_v | 31:c783288001b5 | 37 | |
igor_v | 31:c783288001b5 | 38 | Input.ArrayIn[2]= Spi.ADC5; |
igor_v | 0:8ad47e2b6f00 | 39 | |
igor_v | 31:c783288001b5 | 40 | LPC_SSP0->DR=0x5555; |
igor_v | 31:c783288001b5 | 41 | LPC_SSP0->DR=0x5555; |
igor_v | 31:c783288001b5 | 42 | LPC_SSP0->DR=0x5555; |
igor_v | 0:8ad47e2b6f00 | 43 | |
igor_v | 31:c783288001b5 | 44 | if (CountV31 & 1) { //если нечетный такт то |
igor_v | 31:c783288001b5 | 45 | LPC_SSP0->DR = WRITE_DAC0; //e.команда для ЦАП_0 передавать. |
igor_v | 31:c783288001b5 | 46 | LPC_SSP0->DR = (Spi.DAC_A); //e. передача 12 бит |
igor_v | 31:c783288001b5 | 47 | } else { //если такт четный. |
igor_v | 31:c783288001b5 | 48 | LPC_SSP0->DR = WRITE_DAC1 ; //e.команда для ЦАП_1 передавать. |
igor_v | 31:c783288001b5 | 49 | LPC_SSP0->DR = (Spi.DAC_B); //e. передача 12 бит |
igor_v | 31:c783288001b5 | 50 | } |
igor_v | 0:8ad47e2b6f00 | 51 | |
Kovalev_D | 96:1c8536458119 | 52 | LPC_DAC->CR = (((SinPLC[CountV64]*35)+24300));// модулятор |
Kovalev_D | 89:a0d344db227e | 53 | while (LPC_SSP0->SR & RX_SSP_notEMPT) //если буфер SPI не пуст. |
Kovalev_D | 89:a0d344db227e | 54 | DummySPI = LPC_SSP0->DR; //очистить буфер. |
igor_v | 31:c783288001b5 | 55 | |
igor_v | 31:c783288001b5 | 56 | |
Kovalev_D | 95:dd51e577e114 | 57 | Buff_ADC_1 [CountV31] = Spi.ADC1; |
Kovalev_D | 95:dd51e577e114 | 58 | Buff_ADC_2 [CountV31] = Spi.ADC2; |
Kovalev_D | 95:dd51e577e114 | 59 | Buff_ADC_3 [CountV31] = Spi.ADC3; |
Kovalev_D | 95:dd51e577e114 | 60 | Buff_ADC_4 [CountV31] = Spi.ADC4; |
Kovalev_D | 95:dd51e577e114 | 61 | Buff_ADC_5 [CountV255] = Spi.ADC5; // ампл ацп. |
Kovalev_D | 95:dd51e577e114 | 62 | |
Kovalev_D | 95:dd51e577e114 | 63 | |
Kovalev_D | 96:1c8536458119 | 64 | // Temp_AMP += Buff_ADC_5[CountV255]; |
Kovalev_D | 96:1c8536458119 | 65 | // Temp_AMP -= Buff_ADC_5[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов |
Kovalev_D | 96:1c8536458119 | 66 | // Buff_AMP[CountV255] = (unsigned int) (Temp_AMP); |
Kovalev_D | 96:1c8536458119 | 67 | |
Kovalev_D | 96:1c8536458119 | 68 | Temp_AMP += Buff_ADC_5[CountV255]; |
Kovalev_D | 96:1c8536458119 | 69 | Temp_AMP -= Buff_ADC_5[(CountV255-32) & 0xff]; // з |
Kovalev_D | 96:1c8536458119 | 70 | Temp_AMP += Buff_ADC_5[(CountV255-64) & 0xff]; // |
Kovalev_D | 96:1c8536458119 | 71 | Temp_AMP -= Buff_ADC_5[(CountV255-96) & 0xff]; // з |
Kovalev_D | 96:1c8536458119 | 72 | Buff_AMP[CountV255] = (unsigned int) (Temp_AMP); |
Kovalev_D | 96:1c8536458119 | 73 | |
Kovalev_D | 96:1c8536458119 | 74 | |
Kovalev_D | 96:1c8536458119 | 75 | Temp_AMP64P += Buff_ADC_5[CountV255]; |
Kovalev_D | 96:1c8536458119 | 76 | Temp_AMP64P -= Buff_ADC_5[(CountV255-64) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов |
Kovalev_D | 96:1c8536458119 | 77 | Buff_AMP64P[CountV255] = (unsigned int) (Temp_AMP64P); |
Kovalev_D | 96:1c8536458119 | 78 | |
igor_v | 31:c783288001b5 | 79 | |
Kovalev_D | 47:d902ef6f7564 | 80 | Temp_ADC_2 += Buff_ADC_2[CountV31]; |
Kovalev_D | 47:d902ef6f7564 | 81 | Temp_ADC_2 -= Buff_ADC_2[(CountV31-32) & 0xff]; |
igor_v | 31:c783288001b5 | 82 | |
Kovalev_D | 47:d902ef6f7564 | 83 | Temp_ADC_3 += Buff_ADC_3[CountV31]; |
Kovalev_D | 95:dd51e577e114 | 84 | Temp_ADC_3 -= Buff_ADC_3[(CountV31-32) & 0xff]; |
igor_v | 31:c783288001b5 | 85 | |
Kovalev_D | 47:d902ef6f7564 | 86 | Temp_ADC_4 += Buff_ADC_4[CountV31]; |
Kovalev_D | 47:d902ef6f7564 | 87 | Temp_ADC_4 -= Buff_ADC_4[(CountV31-32) & 0xff]; |
igor_v | 31:c783288001b5 | 88 | |
igor_v | 31:c783288001b5 | 89 | Temp_ADC_5 += Buff_ADC_1[CountV255]; |
igor_v | 31:c783288001b5 | 90 | Temp_ADC_5 -= Buff_ADC_1[(CountV255-32) & 0xff]; |
igor_v | 21:bc8c1cec3da6 | 91 | } |