uint8 SPI_ReadBit(void) { SCACLK_H; SPI_Delay(10); SCACLK_L; SPI_Delay(10); return SCAOUT_D; }
void SPI_WriteByte(uint8 wdata ) { uint8 i; for( i = 0 ; i < 8 ; ++i ){ SCACLK_L; SPI_Delay(10); if(wdata & 0x80)SCAIN_H;else SCAIN_L; wdata = wdata << 1; SPI_Delay(10); SCACLK_H; SPI_Delay(10); } SCACLK_L; }
uint16 SPI_ReadBits(uint8 n ) { uint16 rtemp=0,i; for( i = 0 ; i < n ; i++ ){ ; SPI_Delay(10); rtemp<<=1; if( SCAOUT_D == 1 ){ rtemp++; }else{ } SCACLK_H; SPI_Delay(10); SCACLK_L; SPI_Delay(10); } return rtemp; }
void SPI_Start(void){ SCACLK_L; SCACS_L; SPI_Delay(10); }
void SPI_Stop() { SCACLK_L; SCACS_H; SPI_Delay(10); }
/** * @brief Deactivate SPI slave module by driving CS line high * * @return void */ void SPI_CS_Deactivate(){ SPI_Delay(); GPIO_SpiSetCS(); }
/** * @brief Activate SPI slave module by driving CS line low * * @return void */ void SPI_CS_Activate(){ GPIO_SpiClrCS(); SPI_Delay(); }