mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-03 12:07:52 +00:00
Mod for common spi routines for all protocols
This commit is contained in:
parent
4822851993
commit
5f15211e0b
@ -28,9 +28,9 @@ void CC2500_ReadData(uint8_t *dpbuffer, uint8_t len)
|
||||
static void CC2500_ReadRegisterMulti(uint8_t address, uint8_t data[], uint8_t length)
|
||||
{
|
||||
CC25_CSN_off;
|
||||
CC2500_SPI_Write(address);
|
||||
spi_write(address);
|
||||
for(uint8_t i = 0; i < length; i++)
|
||||
data[i] = CC2500_SPI_Read();
|
||||
data[i] = spi_read();
|
||||
CC25_CSN_on;
|
||||
}
|
||||
|
||||
@ -39,9 +39,9 @@ static void CC2500_ReadRegisterMulti(uint8_t address, uint8_t data[], uint8_t le
|
||||
static void CC2500_WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t length)
|
||||
{
|
||||
CC25_CSN_off;
|
||||
CC2500_SPI_Write(CC2500_WRITE_BURST | address);
|
||||
spi_write(CC2500_WRITE_BURST | address);
|
||||
for(uint8_t i = 0; i < length; i++)
|
||||
CC2500_SPI_Write(data[i]);
|
||||
spi_write(data[i]);
|
||||
CC25_CSN_on;
|
||||
}
|
||||
|
||||
@ -52,62 +52,23 @@ void CC2500_WriteData(uint8_t *dpbuffer, uint8_t len)
|
||||
CC2500_Strobe(CC2500_STX);//0x35
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
static void CC2500_SPI_Write(uint8_t command) {
|
||||
uint8_t n=8;
|
||||
|
||||
SCK_off;//SCK start low
|
||||
SDI_off;
|
||||
while(n--)
|
||||
{
|
||||
if(command&0x80)
|
||||
SDI_on;
|
||||
else
|
||||
SDI_off;
|
||||
SCK_on;
|
||||
NOP();
|
||||
SCK_off;
|
||||
command = command << 1;
|
||||
}
|
||||
SDI_on;
|
||||
}
|
||||
|
||||
//----------------------------
|
||||
void CC2500_WriteReg(uint8_t address, uint8_t data) {//same as 7105
|
||||
CC25_CSN_off;
|
||||
CC2500_SPI_Write(address);
|
||||
spi_write(address);
|
||||
NOP();
|
||||
CC2500_SPI_Write(data);
|
||||
spi_write(data);
|
||||
CC25_CSN_on;
|
||||
}
|
||||
|
||||
static uint8_t CC2500_SPI_Read(void)
|
||||
{
|
||||
uint8_t result;
|
||||
uint8_t i;
|
||||
result=0;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
if(SDO_1) ///
|
||||
result=(result<<1)|0x01;
|
||||
else
|
||||
result=result<<1;
|
||||
SCK_on;
|
||||
NOP();
|
||||
SCK_off;
|
||||
NOP();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
static uint8_t CC2500_ReadReg(uint8_t address)
|
||||
{
|
||||
uint8_t result;
|
||||
CC25_CSN_off;
|
||||
address |=0x80; //bit 7 =1 for reading
|
||||
CC2500_SPI_Write(address);
|
||||
result = CC2500_SPI_Read();
|
||||
spi_write(address);
|
||||
result = spi_read();
|
||||
CC25_CSN_on;
|
||||
return(result);
|
||||
}
|
||||
@ -115,7 +76,7 @@ static uint8_t CC2500_ReadReg(uint8_t address)
|
||||
void CC2500_Strobe(uint8_t address)
|
||||
{
|
||||
CC25_CSN_off;
|
||||
CC2500_SPI_Write(address);
|
||||
spi_write(address);
|
||||
CC25_CSN_on;
|
||||
}
|
||||
//------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user