本文整理汇总了C++中spiTransfer函数的典型用法代码示例。如果您正苦于以下问题:C++ spiTransfer函数的具体用法?C++ spiTransfer怎么用?C++ spiTransfer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spiTransfer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spiTransactionBegin
unsigned char CC2500xcvr::sendBurstCommand(unsigned char command, unsigned char* data, unsigned char length)
{
spiTransactionBegin(); // enable device
// send command byte
spiTransfer(command); // this is a burst command
unsigned char result = 0;
// send/recv data bytes
for (int i=0; i<length; ++i)
{
result = spiTransfer(data[i]); // send
data[i] = result; // receive into the same buffer
}
spiTransactionEnd(); // disable device
return result; // return result
}
示例2: mpu6000ReadRegister
bool mpu6000ReadRegister(uint8_t reg, uint8_t length, uint8_t *data)
{
ENABLE_MPU6000;
spiTransferByte(MPU6000_SPI_INSTANCE, reg | 0x80); // read transaction
spiTransfer(MPU6000_SPI_INSTANCE, data, NULL, length);
DISABLE_MPU6000;
return true;
}
示例3: readEepromPage
void readEepromPage(uint16_t address, uint16_t length)
{
// here again we have a word address
for (uint16_t addr = address * 2, i = 0; i < length; i++)
{
uint8_t ee = spiTransfer(0xA0, addr++, 0xFF);
Serial.write(ee);
}
Serial.write(STK_OK);
}
示例4: spiTransfer
void LedControl::setRow(int addr, int row, byte value) {
int offset;
if(addr<0 || addr>=maxDevices)
return;
if(row<0 || row>7)
return;
offset=addr*8;
status[offset+row]=value;
spiTransfer(addr, row+1,status[offset+row]);
}
示例5: writeEnable
void writeEnable(void)
{
ENABLE_EEPROM;
spiTransfer(EEPROM_SPI, WRITE_ENABLE);
DISABLE_EEPROM;
delayMicroseconds(2);
}
示例6: spiTransfer
void MAX7219::clearDisplay(int addr) {
if (addr < 0 || addr >= maxDevices) return;
int offset;
offset = addr * 8;
for (uint8_t i = 0; i < 8; i++) {
status[offset + i] = 0;
spiTransfer(addr, i + 1, status[offset + i]);
}
}
示例7: mpu9250SlowReadRegister
bool mpu9250SlowReadRegister(uint8_t reg, uint8_t length, uint8_t *data)
{
ENABLE_MPU9250;
delayMicroseconds(1);
spiTransferByte(MPU9250_SPI_INSTANCE, reg | 0x80); // read transaction
spiTransfer(MPU9250_SPI_INSTANCE, data, NULL, length);
DISABLE_MPU9250;
delayMicroseconds(1);
return true;
}
示例8: transposeData
void LedControl::clearDisplay(int addr) {
int offset;
if(addr<0 || addr>=maxDevices)
return;
offset=addr*8;
for(int i=0;i<8;i++) {
status[offset+i]=0;
}
if (anodeMode) {
transposeData(addr);
for(int i=0;i<8;i++) {
spiTransfer(addr, i+1, statusTransposed[offset+i]);
}
} else {
for(int i=0;i<8;i++) {
spiTransfer(addr, i+1, status[offset+i]);
}
}
}
示例9: spiTransfer
void LedControl::clearDisplay(int addr) {
int offset;
if(addr<0 || addr>=maxDevices)
return;
offset=addr*8;
for(int i=0;i<8;i++) {
status[offset+i]=0;
spiTransfer(addr, i+1,status[offset+i]);
}
}
示例10: m25p16_pageProgramBegin
void m25p16_pageProgramBegin(uint32_t address)
{
uint8_t command[] = { M25P16_INSTRUCTION_PAGE_PROGRAM, (address >> 16) & 0xFF, (address >> 8) & 0xFF, address & 0xFF};
m25p16_waitForReady(DEFAULT_TIMEOUT_MILLIS);
m25p16_writeEnable();
ENABLE_M25P16;
spiTransfer(M25P16_SPI_INSTANCE, NULL, command, sizeof(command));
}
示例11: spiTest
static bool spiTest(void)
{
uint8_t out[] = { 0x9F, 0, 0, 0 };
uint8_t in[4];
spiSelect(true);
spiTransfer(in, out, sizeof(out));
spiSelect(false);
if (in[1] == 0xEF)
return true;
return false;
}
示例12: assert
MAX7219::MAX7219(SPI* spi, int numDevices) {
assert(spi != nullptr);
this->spi = spi;
if (numDevices <= 0 || numDevices > 8) {
numDevices = 8;
}
maxDevices = numDevices;
for (uint8_t i = 0; i < 64; i++) {
status[i] = 0x00;
}
for (int i = 0; i < maxDevices; i++) {
spiTransfer(i, OP_DISPLAYTEST, 0);
//scanlimit is set to max on startup
setScanLimit(7, i);
//decode is done in source
spiTransfer(i, OP_DECODEMODE, 0);
clearDisplay(i);
//we go into shutdown-mode on startup
shutdown(true, i);
}
}
示例13: m25p16_readStatus
static uint8_t m25p16_readStatus()
{
uint8_t command[2] = { M25P16_INSTRUCTION_READ_STATUS_REG, 0 };
uint8_t in[2];
ENABLE_M25P16;
spiTransfer(M25P16_SPI_INSTANCE, in, command, sizeof(command));
DISABLE_M25P16;
return in[1];
}
示例14: m25p16_eraseSector
/**
* Erase a sector full of bytes to all 1's at the given byte offset in the flash chip.
*/
void m25p16_eraseSector(uint32_t address)
{
uint8_t out[] = { M25P16_INSTRUCTION_SECTOR_ERASE, (address >> 16) & 0xFF, (address >> 8) & 0xFF, address & 0xFF};
m25p16_waitForReady(SECTOR_ERASE_TIMEOUT_MILLIS);
m25p16_writeEnable();
ENABLE_M25P16;
spiTransfer(M25P16_SPI_INSTANCE, NULL, out, sizeof(out));
DISABLE_M25P16;
}
示例15: digitalWrite
/** \brief SPI command.
Setup DC and SS pins, then send command via SPI to SSD1306 controller.
*/
void MicroOLED::command(uint8_t c) {
if (interface == MODE_SPI)
{
digitalWrite(dcPin, LOW);
digitalWrite(csPin, LOW);
spiTransfer(c);
digitalWrite(csPin, HIGH);
}
else if (interface == MODE_I2C)
{
digitalWrite(dcPin, LOW); // DC pin LOW
i2cWrite(I2C_ADDRESS_SA0_1, I2C_COMMAND, c);
}
}