/**
* [url=home.php?mod=space&uid=247401]@brief[/url] SPI write 1 byte
* @param dat,8bit
* @retval None
*/
void SPI_WriteByte(uchar8_t dat)
{
uchar8_t i = 0;
for (i = 0; i < 8; i++) {
ADC_SPI_MOSI = dat >> 7;
dat <<= 1;
ADC_SPI_CLK = 1;
ADC_SPI_CLK = 0;
}
}
/**
* @brief SPI Read 1 byte
* @param None
* @retval data
*/
uchar8_t SPI_ReadByte(void)
{
uchar8_t i = 0;
uchar8_t val = 0;
for (i = 0; i < 8; i++) {
ADC_SPI_CLK = 1;
ADC_SPI_CLK = 0;
val <<= 1;
val |= ADC_SPI_MISO;
}
return val;
}
|