本文整理汇总了C++中SPI_RW函数的典型用法代码示例。如果您正苦于以下问题:C++ SPI_RW函数的具体用法?C++ SPI_RW怎么用?C++ SPI_RW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SPI_RW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NRF_WriteBuf
/*=====================================================================================================*/
static void NRF_WriteBuf( u8 WriteAddr, u8 *WriteBuf, u8 Bytes )
{
u8 i;
NRF_CSN = 0;
SPI_RW(NRF_SPIx, WriteAddr);
for(i=0; i<Bytes; i++)
SPI_RW(NRF_SPIx, WriteBuf[i]);
NRF_CSN = 1;
}
示例2: SPI_Read_Reg
/**************************************************
Function: SPI_Read_Reg();
Description:
Read one UINT8 from BK2421 register, 'reg'
// **************************************************/
UINT8 SPI_Read_Reg(UINT8 reg)
{
UINT8 value;
CSN(0); // CSN low, initialize SPI communication...
op_status = SPI_RW(reg); // Select register to read from..
value = SPI_RW(0); // ..then read register value
CSN(1); // CSN high, terminate SPI communication
return(value); // return register value
}
示例3: SPI_Write_Buf
uchar SPI_Write_Buf(uchar reg, uchar * pBuf, uchar bytes)
{
uchar status, i;
CSN = 0; // CSN置低,开始传输数据
status = SPI_RW(reg); // 选择寄存器,同时返回状态字
for(i=0; i<bytes; i++)
SPI_RW(pBuf[i]); // 逐个字节写入nRF24L01
CSN = 1; // CSN拉高,结束数据传输
return(status); // 返回状态寄存器
}
示例4: NRF_ReadBuf
/*=====================================================================================================*/
static void NRF_ReadBuf( u8 ReadAddr, u8 *ReadBuf, u8 Bytes )
{
u8 i = 0;
NRF_CSN = 0;
SPI_RW(NRF_SPIx, ReadAddr);
for(i=0; i<Bytes; i++)
ReadBuf[i] = SPI_RW(NRF_SPIx, 0xFF);
NRF_CSN = 1;
}
示例5: SPI_Write_Buf
unsigned char SPI_Write_Buf(unsigned char reg, unsigned char *pBuf, unsigned uchars)
{
unsigned char status,uchar_ctr;
cbi(PORTC,CSN);//CSN = 0; //SPI
status = SPI_RW(reg);
for(uchar_ctr=0; uchar_ctr<uchars; uchar_ctr++) //
SPI_RW(*pBuf++);
sbi(PORTC,CSN);//CSN = 1; //SPI
return(status); //
}
示例6: SPI_Read_Buf
uchar SPI_Read_Buf(uchar reg, uchar * pBuf, uchar bytes)
{
uchar status, i;
CSN = 0; // CSN置低,开始传输数据
status = SPI_RW(reg); // 选择寄存器,同时返回状态字
for(i=0; i<bytes; i++)
pBuf[i] = SPI_RW(0); // 逐个字节从nRF24L01读出
CSN = 1; // CSN拉高,结束数据传输
return(status); // 返回状态寄存器
}
示例7: NRF_Read_Reg
//读寄存器
uint8_t NRF_Read_Reg(uint8_t reg)
{
uint8_t reg_val;
SPI_CSN_L();
SPI_RW(reg);
reg_val = SPI_RW(0); /* 读取该寄存器返回数据 */
SPI_CSN_H();
return reg_val;
}
示例8: SPI_Write_Reg
/////////////////////写寄存器/////////////////////////////////////////////
uchar SPI_Write_Reg(uchar reg, uchar value)
{
uchar status;
NRF_CSN0; // CSN low, init SPI transaction
status = SPI_RW(reg); // select register
SPI_RW(value); // ..and write value to it..
NRF_CSN1; // CSN high again
return(status); // return nRF24L01 status byte
}
示例9: SPI_Command
BYTE SPI_Command(BYTE reg, BYTE value)
{
BYTE status;
CSN_Pin_LowSelect();
status = SPI_RW( reg);
SPI_RW(value);
CSN_Pin_HighDisable();
return(status);
}
示例10: SPI_Write_Register
BYTE SPI_Write_Register(BYTE reg, BYTE value)
{
BYTE status;
CSN_Pin_LowSelect();
status = SPI_RW(WRITE_REG | reg);
SPI_RW(value);
CSN_Pin_HighDisable();
return(status);
}
示例11: SPI_Read_Register
BYTE SPI_Read_Register(BYTE reg)
{
BYTE reg_val;
CSN_Pin_LowSelect();
SPI_RW(reg);
reg_val = SPI_RW(0);
CSN_Pin_HighDisable();
return(reg_val);
}
示例12: SPI_Write_Buf
/**************************************************
Function: SPI_Write_Buf();
Description:
Writes contents of buffer '*pBuf' to RFM73
// **************************************************/
void SPI_Write_Buf(UINT8 reg, UINT8 *pBuf, UINT8 length)
{
UINT8 byte_ctr;
CSN(0); // Set CSN low, init SPI tranaction
op_status = SPI_RW(reg); // Select register to write to and read status UINT8
for(byte_ctr=0; byte_ctr<length; byte_ctr++) // then write all UINT8 in buffer(*pBuf)
SPI_RW(*pBuf++);
CSN(1); // Set CSN high again
}
示例13: SPI_RW_Reg
unsigned char SPI_RW_Reg(unsigned char reg, unsigned char value)
{
unsigned char status;
cbi(PORTC,CSN);//CSN = 0; // CSN low, init SPI transaction
status = SPI_RW(reg); // select register
SPI_RW(value); // ..and write value to it..
sbi(PORTC,CSN);//CSN = 1; // CSN high again
return(status); // return nRF24L01 status uchar
}
示例14: SPI_Read
/**************************************************
功能:读RF寄存器
**************************************************/
uint8_t SPI_Read(uint8_t reg)
{
uint8_t reg_val;
RFCSN = 0;
SPI_RW(reg); // 选择RF寄存器
reg_val = SPI_RW(0); // 读出数据
RFCSN = 1;
return(reg_val); // 返回RF状态值
}
示例15: SPI_RW_Reg
/**************************************************
功能:写RF寄存器,读RF状态值
**************************************************/
uint8_t SPI_RW_Reg(uint8_t reg, uint8_t value)
{
uint8_t status;
RFCSN = 0;
status = SPI_RW(reg); // 选择RF寄存器
SPI_RW(value); // 写入数据
RFCSN = 1;
return(status); // 返回RF状态值
}