#include #include "lpc17xx_gpio.h" #include "lpc17xx_adc.h" #include "lpc17xx_pinsel.h" #include "lpc17xx_uart.h" #include "hardware.h" #include "Delay_RIT.h" #define N 2 uint8_t data[N]; uint32_t volatile Index=0; void UART_IntReceive(void) { data[Index]=UART_ReceiveByte(LPC_UART3); Index++; if (Index>=N) Index=0; //UART_SendByte(LPC_UART3,data); } int main() { uint8_t buffStr[50]; GPIO_SetDir(2,(1<<5),1); HW_Init(); while(1) { uint16_t data4=(data[0]-'0')*10+(data[1]-'0'); if(data[0]!=0&&Index==1) { data4=data[0]-'0'; Index=0; data[0]=0; data[1]=0; } if(data[0]==NULL&&data[1]==NULL) data4=0; // float temp1=HW_ADC_Read(1)/10.0F; float temp2=20.0F; uint8_t len=sprintf((char*)buffStr,"%f\n %u\n",temp2,data4); UART_Send(LPC_UART3,buffStr,len,BLOCKING); Delay_RIT_ms(1000); if(temp2>data4) GPIO_SetValue(2,(1<<5)); else if ( temp2<=data4) GPIO_ClearValue(2,(1<<5)) ; } }