mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-04 04:27:53 +00:00
Spi cosmetics
This commit is contained in:
parent
cdcaa70235
commit
12b3f3900f
@ -17,16 +17,11 @@ void initSPI2() {
|
||||
|
||||
SPI_2.setBitOrder(MSBFIRST); // Set the SPI_2 bit order
|
||||
SPI_2.setDataMode(SPI_MODE0); //Set the SPI_2 data mode 0
|
||||
SPI_2.setClockDivider(SPI_CLOCK_DIV8); //// Slow speed (36 / 8 = 4.5 MHz SPI_2 speed)
|
||||
SPI_2.setClockDivider(SPI_CLOCK_DIV8); //// speed (36 / 8 = 4.5 MHz SPI_2 speed)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef XMEGA
|
||||
#define XNOP() NOP()
|
||||
#else
|
||||
#define XNOP()
|
||||
#endif
|
||||
|
||||
#if defined STM32_board
|
||||
|
||||
@ -87,10 +82,9 @@ void spi_write(uint8_t command)
|
||||
{
|
||||
uint8_t n=8;
|
||||
SCK_off;//SCK start low
|
||||
XNOP() ;
|
||||
SDI_off;
|
||||
XNOP() ;
|
||||
while(n--) {
|
||||
do
|
||||
{
|
||||
if(command&0x80)
|
||||
SDI_on;
|
||||
else
|
||||
@ -102,8 +96,8 @@ void spi_write(uint8_t command)
|
||||
XNOP() ;
|
||||
SCK_off;
|
||||
command = command << 1;
|
||||
XNOP() ;
|
||||
}
|
||||
while(n--);
|
||||
SDI_on;
|
||||
}
|
||||
|
||||
@ -128,23 +122,16 @@ uint8_t spi_Read(void) {
|
||||
|
||||
uint8_t spi_read()
|
||||
{
|
||||
uint8_t result;
|
||||
uint8_t i;
|
||||
result=0;
|
||||
uint8_t result=0,i;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
result<<=1;
|
||||
if(SDO_1) ///
|
||||
result|=0x01;
|
||||
SCK_on;
|
||||
XNOP() ;
|
||||
XNOP() ;
|
||||
NOP();
|
||||
SCK_off;
|
||||
XNOP() ;
|
||||
XNOP() ;
|
||||
NOP();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user