本文整理汇总了C++中spiTransferByte函数的典型用法代码示例。如果您正苦于以下问题:C++ spiTransferByte函数的具体用法?C++ spiTransferByte怎么用?C++ spiTransferByte使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spiTransferByte函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mpu6000WriteRegister
bool mpu6000WriteRegister(uint8_t reg, uint8_t data)
{
ENABLE_MPU6000;
spiTransferByte(MPU6000_SPI_INSTANCE, reg);
spiTransferByte(MPU6000_SPI_INSTANCE, data);
DISABLE_MPU6000;
return true;
}
示例2: mmcCommandNoWait
void mmcCommandNoWait(u08 cmd, u32 arg) {
// send command
spiTransferByte(cmd | 0x40);
spiTransferByte(arg>>24);
spiTransferByte(arg>>16);
spiTransferByte(arg>>8);
spiTransferByte(arg);
spiTransferByte(0x95); // crc valid only for MMC_GO_IDLE_STATE
// end command
}
示例3: set_avr_bank
void set_avr_bank(uint8_t val) {
SPI_SS_HIGH();
FPGA_SS_LOW();
spiTransferByte(0x00); // SET ADDRESS
spiTransferByte(val * 0x20); // select chip
spiTransferByte(0x00); // select chip
spiTransferByte(0x00); // select chip
FPGA_SS_HIGH();
SPI_SS_LOW();
}
示例4: cc2420WriteFifo
void cc2420WriteFifo(u08* data, u16 nBytes)
{
// assert chip select
cbi(PORTB, CC2420_PIN_CS);
// send command
spiTransferByte(CC2420_TXFIFO);
while(nBytes--)
spiTransferByte(*data++);
// release chip select
sbi(PORTB, CC2420_PIN_CS);
}
示例5: cc2420DumpFifo
void cc2420DumpFifo(u16 nBytes)
{
// assert chip select
cbi(PORTB, CC2420_PIN_CS);
// send command
spiTransferByte(CC2420_RXFIFO | 0x40);
while(nBytes--)
spiTransferByte(0x00);
// release chip select
sbi(PORTB, CC2420_PIN_CS);
}
示例6: spieepromReadStatus
u08 spieepromReadStatus(void)
{
u08 status;
// cbi(PORTB,0);
// send command
spiTransferByte(SPIEEPROM_CMD_RDSR);
// get status register value
status = spiTransferByte(0xFF);
// sbi(PORTB,0);
return status;
}
示例7: mpu9250WriteRegister
bool mpu9250WriteRegister(uint8_t reg, uint8_t data)
{
ENABLE_MPU9250;
delayMicroseconds(1);
spiTransferByte(MPU9250_SPI_INSTANCE, reg);
spiTransferByte(MPU9250_SPI_INSTANCE, data);
DISABLE_MPU9250;
delayMicroseconds(1);
return true;
}
示例8: ads7870WriteReg
void ads7870WriteReg(u08 reg, u08 value)
{
// assert chip select
cbi(ADS7870_CS_PORT, ADS7870_CS_PIN);
// issue reg write command
spiTransferByte(ADS7870_REG_WRITE | reg);
// write data
spiTransferByte(value);
// release chip select
sbi(ADS7870_CS_PORT, ADS7870_CS_PIN);
}
示例9: cc2420WriteRam
void cc2420WriteRam(u16 addr, u08* data, u16 nBytes)
{
// assert chip select
cbi(PORTB, CC2420_PIN_CS);
// send command
spiTransferByte(0x80|addr);
spiTransferByte((addr>>1) & 0xC0);
while(nBytes--)
spiTransferByte(*data++);
// release chip select
sbi(PORTB, CC2420_PIN_CS);
}
示例10: crc7update
/**
* sendCommand - send a command to the SD card
* @command : command to be sent
* @parameter: parameter to be sent
* @deselect : Flags if the card should be deselected afterwards
*
* This function calculates the correct CRC7 for the command and
* parameter and transmits all of it to the SD card. If requested
* the card will be deselected afterwards.
*/
int mmc::sendCommand(const byte command,
const uint32_t parameter,
const byte deselect) {
union {
unsigned long l;
unsigned char c[4];
}
long2char;
byte i,crc,errorcount;
uint16_t counter;
long2char.l = parameter;
crc = crc7update(0 , 0x40+command);
crc = crc7update(crc, long2char.c[3]);
crc = crc7update(crc, long2char.c[2]);
crc = crc7update(crc, long2char.c[1]);
crc = crc7update(crc, long2char.c[0]);
crc = (crc << 1) | 1;
errorcount = 0;
while (errorcount < CONFIG_SD_AUTO_RETRIES) {
// Select card
SPI_SS_LOW();
// Transfer command
spiTransferByte(0x40+command);
spiTransferLong(parameter);
spiTransferByte(crc);
// Wait for a valid response
counter = 0;
do {
i = spiTransferByte(0xff);
counter++;
}
while (i & 0x80 && counter < 0x1000);
// Check for CRC error
// can't reliably retry unless deselect is allowed
if (deselect && (i & STATUS_CRC_ERROR)) {
// uart_putc('x');
deselectCard();
errorcount++;
continue;
}
if (deselect) deselectCard();
break;
}
return i;
}
示例11: cc2420WriteReg
void cc2420WriteReg(u08 addr, u16 data)
{
// assert chip select
cbi(PORTB, CC2420_PIN_CS);
// send command
spiTransferByte(addr);
// write data
spiTransferByte(data>>8);
spiTransferByte(data);
// release chip select
sbi(PORTB, CC2420_PIN_CS);
}
示例12: spiflashGetID
unsigned short spiflashGetID(void)
{
unsigned short id;
SPIFLASH_ASSERT_CS;
spiTransferByte(SPIFLASH_CMD_RDID);
id = spiTransferByte(0x00)<<8;
id |= spiTransferByte(0x00);
SPIFLASH_RELEASE_CS;
return id;
}
示例13: ads7870ReadReg
u08 ads7870ReadReg(u08 reg)
{
u08 data;
// assert chip select
cbi(ADS7870_CS_PORT, ADS7870_CS_PIN);
// issue reg read command
spiTransferByte(ADS7870_REG_READ | reg);
// read data
data = spiTransferByte(0x00);
// release chip select
sbi(ADS7870_CS_PORT, ADS7870_CS_PIN);
// return data
return data;
}
示例14: spieepromWriteByte
void spieepromWriteByte(u32 memAddr, u08 data)
{
// wait for any previous write to complete
while(spieepromReadStatus() & SPIEEPROM_STATUS_WIP);
// cbi(PORTB,0);
// send command
spiTransferByte(SPIEEPROM_CMD_WRITE);
// send address
spiTransferByte(memAddr>>8);
spiTransferByte(memAddr&0x00FF);
// send data to be written
spiTransferByte(data);
// sbi(PORTB,0);
}
示例15: spieepromReadByte
u08 spieepromReadByte(u32 memAddr)
{
u08 data;
// cbi(PORTB,0);
// send command
spiTransferByte(SPIEEPROM_CMD_READ);
// send address
spiTransferByte(memAddr>>8);
spiTransferByte(memAddr&0x00FF);
// read contents of memory address
data = spiTransferByte(0xFF);
// return data
return data;
// sbi(PORTB,0);
}