![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
SPI.c
- Committer:
- Kovalev_D
- Date:
- 2016-03-28
- Revision:
- 95:dd51e577e114
- Parent:
- 92:c892f0311aa7
- Child:
- 96:1c8536458119
File content as of revision 95:dd51e577e114:
#include "Global.h" struct SPI Spi; unsigned int Temp_AMP; unsigned int Temp_ADC_2; unsigned int Temp_ADC_3; unsigned int Temp_ADC_4; unsigned int Temp_ADC_5; unsigned int Buff_ADC_1 [32]; unsigned int Buff_ADC_2 [32]; unsigned int Buff_ADC_3 [32]; unsigned int Buff_ADC_4 [32]; unsigned int Buff_ADC_5 [256]; unsigned int Buff_AMP [256]; unsigned int SinPLC[64]= {1023, 1016, 1006, 993, 976, 954, 904, 874, 841, 806, 768, 728, 687, 645, 601, 557, 500, 379, 337, 296, 256, 219, 183, 150, 120, 93, 69, 48, 31, 18, 8, 0, 8, 18, 31, 48, 69, 93, 120, 150, 183, 219, 256, 296, 337, 379, 468, 512, 557, 601, 645, 687, 728, 768, 806, 841, 874, 904, 954, 976, 993, 1006, 1016, 1023 }; void SPI_Exchange(void) { unsigned int DummySPI; Spi.ADC5 = LPC_SSP0->DR; Spi.ADC4 = LPC_SSP0->DR; Spi.ADC3 = LPC_SSP0->DR; Spi.ADC2 = LPC_SSP0->DR; Spi.ADC1 = LPC_SSP0->DR; Input.ArrayIn[2]= Spi.ADC5; LPC_SSP0->DR=0x5555; LPC_SSP0->DR=0x5555; LPC_SSP0->DR=0x5555; if (CountV31 & 1) { //если нечетный такт то LPC_SSP0->DR = WRITE_DAC0; //e.команда для ЦАП_0 передавать. LPC_SSP0->DR = (Spi.DAC_A); //e. передача 12 бит } else { //если такт четный. LPC_SSP0->DR = WRITE_DAC1 ; //e.команда для ЦАП_1 передавать. LPC_SSP0->DR = (Spi.DAC_B); //e. передача 12 бит } //LPC_DAC->CR = (((SinPLC[CountV64]*35)+24300));// модулятор while (LPC_SSP0->SR & RX_SSP_notEMPT) //если буфер SPI не пуст. DummySPI = LPC_SSP0->DR; //очистить буфер. Buff_ADC_1 [CountV31] = Spi.ADC1; Buff_ADC_2 [CountV31] = Spi.ADC2; Buff_ADC_3 [CountV31] = Spi.ADC3; Buff_ADC_4 [CountV31] = Spi.ADC4; Buff_ADC_5 [CountV255] = Spi.ADC5; // ампл ацп. Temp_AMP += Buff_ADC_5[CountV255]; Temp_AMP -= Buff_ADC_5[(CountV255-32) & 0xff]; // заполнение буфера накопленых приращений за 8 тактов Buff_AMP[CountV255] = (unsigned int) (Temp_AMP); Temp_ADC_2 += Buff_ADC_2[CountV31]; Temp_ADC_2 -= Buff_ADC_2[(CountV31-32) & 0xff]; Temp_ADC_3 += Buff_ADC_3[CountV31]; Temp_ADC_3 -= Buff_ADC_3[(CountV31-32) & 0xff]; Temp_ADC_4 += Buff_ADC_4[CountV31]; Temp_ADC_4 -= Buff_ADC_4[(CountV31-32) & 0xff]; Temp_ADC_5 += Buff_ADC_1[CountV255]; Temp_ADC_5 -= Buff_ADC_1[(CountV255-32) & 0xff]; }