unsigned char SendReceiveByte (unsigned char data)
{
LPC_SPI->SPDR = data;
while ( 0 == (LPC_SPI->SPSR & 0x80)); /* 等待数据发送完毕 */
data = LPC_SPI->SPDR; /* 清除SPIF标志*/
return data;
}
void ad_get()
{
unsigned char dL=0,dH=0;
SendReceiveByte(0x43);
dH=SendReceiveByte(0xff);
dL=SendReceiveByte(0xff);
AD_VALUE=(dH<<8)|dL;
} |