// receive one byte of data and receive one back at the same time unsigned char readSPI2(unsigned char t) { SPI2STATbits.SPIROV = 0; SPI2BUF = t; // write to buffer for TX while( !SPI2STATbits.SPIRBF); // wait for receive complete return SPI2BUF; // read the received value }
обращение к функции: tnp = readSPI(0x22); tnp возвращает то что принял, 0x22 не передает