![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LG2 by
SPI.c
- Committer:
- igor_v
- Date:
- 2016-01-30
- Revision:
- 0:8ad47e2b6f00
- Child:
- 21:bc8c1cec3da6
File content as of revision 0:8ad47e2b6f00:
#include "Global.h" #include "SPI.h" #include "stdlib.h" #include "LPC17xx.h" #include "InputOutput.h" #include "MTimer.h" struct SPI Spi; unsigned int Temp_AMP=0; unsigned int Temp_ADC_2=0; unsigned int Temp_ADC_3=0; unsigned int Temp_ADC_4=0; unsigned int Temp_ADC_5=0; unsigned int Buff_ADC_1 [256]; unsigned int Buff_ADC_2 [256]; unsigned int Buff_ADC_3 [256]; unsigned int Buff_ADC_4 [256]; unsigned int Buff_ADC_5 [256]; unsigned int Buff_AMP [256]; void SPI_Exchange() { unsigned int Dummy; 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 ��� } while (LPC_SSP0->SR & RX_SSP_notEMPT) //���� ����� SPI �� ����. Dummy = LPC_SSP0->DR; //�������� �����. Buff_ADC_1 [CountV255] = Spi.ADC1; // ���� ���. Buff_ADC_2 [CountV255] = Spi.ADC2; Buff_ADC_3 [CountV255] = Spi.ADC3; Buff_ADC_4 [CountV255] = 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[CountV255]; Temp_ADC_2 -= Buff_ADC_2[(CountV255-32) & 0xff]; Temp_ADC_3 += Buff_ADC_3[CountV255]; Temp_ADC_3 -= Buff_ADC_3[(CountV255-32) & 0xff]; Temp_ADC_4 += Buff_ADC_4[CountV255]; Temp_ADC_4 -= Buff_ADC_4[(CountV255-32) & 0xff]; Temp_ADC_5 += Buff_ADC_1[CountV255]; Temp_ADC_5 -= Buff_ADC_1[(CountV255-32) & 0xff]; } void Init_SPI_Exchange() { ResetCS(ADC); //prepare ADC for sampling SetDAC(DAC); LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED //LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED //LPC_GPIO2->FIOSET |= 0x0000004; // turn on the LED SetCS(ADC); //start ADC sampling ResetDAC(DAC); }