您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ spiSend函数代码示例

51自学网 2021-06-03 08:09:22
  C++
这篇教程C++ spiSend函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中spiSend函数的典型用法代码示例。如果您正苦于以下问题:C++ spiSend函数的具体用法?C++ spiSend怎么用?C++ spiSend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了spiSend函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: chipSelectLow

//------------------------------------------------------------------------------// send command and return error code.  Return zero for OKuint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) {  // select card  chipSelectLow();  // wait up to 300 ms if busy  waitNotBusy(300);  // send command  spiSend(cmd | 0x40);  // send argument  for (int8_t s = 24; s >= 0; s -= 8) spiSend(arg >> s);  // send CRC  uint8_t crc = 0XFF;  if (cmd == CMD0) crc = 0X95;  // correct crc for CMD0 with arg 0  if (cmd == CMD8) crc = 0X87;  // correct crc for CMD8 with arg 0X1AA  spiSend(crc);  // skip stuff byte for stop read  if (cmd == CMD12) spiRec();  // wait for response  for (uint8_t i = 0; ((status_ = spiRec()) & 0X80) && i != 0XFF; i++) { /* Intentionally left empty */ }  return status_;}
开发者ID:Kazuyoko,项目名称:MarlinKimbra4due,代码行数:28,


示例2: mmcSequentialWrite

/** * @brief   Writes a block within a sequential write operation. * * @param[in] mmcp      pointer to the @p MMCDriver object * @param[out] buffer   pointer to the write buffer * * @return              The operation status. * @retval HAL_SUCCESS   the operation succeeded. * @retval HAL_FAILED    the operation failed. * * @api */bool mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer) {  static const uint8_t start[] = {0xFF, 0xFC};  uint8_t b[1];  osalDbgCheck((mmcp != NULL) && (buffer != NULL));  if (mmcp->state != BLK_WRITING) {    return HAL_FAILED;  }  spiSend(mmcp->config->spip, sizeof(start), start);    /* Data prologue.   */  spiSend(mmcp->config->spip, MMCSD_BLOCK_SIZE, buffer);/* Data.            */  spiIgnore(mmcp->config->spip, 2);                     /* CRC ignored.     */  spiReceive(mmcp->config->spip, 1, b);  if ((b[0] & 0x1FU) == 0x05U) {    wait(mmcp);    return HAL_SUCCESS;  }  /* Error.*/  spiUnselect(mmcp->config->spip);  spiStop(mmcp->config->spip);  mmcp->state = BLK_READY;  return HAL_FAILED;}
开发者ID:mabl,项目名称:ChibiOS,代码行数:37,


示例3: dma_setup_transfer

//------------------------------------------------------------------------------// send one block of data for write block or write multiple blocksuint8_t Sd2Card::writeData(uint8_t token, const uint8_t* src) {#ifdef SPI_DMA        dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS, (uint8_t *)src, DMA_SIZE_8BITS, (DMA_MINC_MODE |  DMA_FROM_MEM | DMA_TRNS_CMPLT | DMA_TRNS_ERR));        dma_attach_interrupt(DMA1, DMA_CH3, DMAEvent);        dma_set_priority(DMA1, DMA_CH3, DMA_PRIORITY_VERY_HIGH);        dma_set_num_transfers(DMA1, DMA_CH3, 512);        dmaActive = true;        dma_enable(DMA1, DMA_CH3);        while(dmaActive) delayMicroseconds(1);        dma_disable(DMA1, DMA_CH3);#else  // SPI_DMA  spiSend(token);  for (uint16_t i = 0; i < 512; i++) {    spiSend(src[i]);  }#endif  // OPTIMIZE_HARDWARE_SPI  spiSend(0xff);  // dummy crc  spiSend(0xff);  // dummy crc  status_ = spiRec();  if ((status_ & DATA_RES_MASK) != DATA_RES_ACCEPTED) {    error(SD_CARD_ERROR_WRITE);    chipSelectHigh();	Serial.println("Error: Write");    Serial.println("Error: Sd2Card::writeData()");    return false;  }  return true;}
开发者ID:floriancargoet,项目名称:choosatron-core-firmware,代码行数:34,


示例4: readEnd

//------------------------------------------------------------------------------// send command to carduint8_t SdReader::cardCommand(uint8_t cmd, uint32_t arg){  uint8_t r1;    // end read if in partialBlockRead mode  readEnd();    // select card  spiSSLow();    // wait up to 300 ms if busy  waitNotBusy(300);    // send command  spiSend(cmd | 0x40);    // send argument  for (int8_t s = 24; s >= 0; s -= 8) spiSend(arg >> s);    // send CRC  uint8_t crc = 0XFF;  if (cmd == CMD0) crc = 0X95; // correct crc for CMD0 with arg 0  if (cmd == CMD8) crc = 0X87; // correct crc for CMD8 with arg 0X1AA  spiSend(crc);    // wait for response  for (uint8_t retry = 0; ((r1 = spiRec()) & 0X80) && retry != 0XFF; retry++);  return r1;}
开发者ID:zoomx,项目名称:moanbot,代码行数:32,


示例5: while

//------------------------------------------------------------------------------// send one block of data for write block or write multiple blocksuint8_t Sd2Card::writeData(uint8_t token, const uint8_t* src) {#ifdef OPTIMIZE_HARDWARE_SPI  // send data - optimized loop  SPDR = token;  // send two byte per iteration  for (uint16_t i = 0; i < 512; i += 2) {    while (!(SPSR & (1 << SPIF)));    SPDR = src[i];    while (!(SPSR & (1 << SPIF)));    SPDR = src[i+1];  }  // wait for last data byte  while (!(SPSR & (1 << SPIF)));#else  // OPTIMIZE_HARDWARE_SPI  spiSend(token);  for (uint16_t i = 0; i < 512; i++) {    spiSend(src[i]);  }#endif  // OPTIMIZE_HARDWARE_SPI  spiSend(0xff);  // dummy crc  spiSend(0xff);  // dummy crc  status_ = spiRec();  if ((status_ & DATA_RES_MASK) != DATA_RES_ACCEPTED) {    error(SD_CARD_ERROR_WRITE);    chipSelectHigh();    return false;  }  return true;}
开发者ID:757Nauman,项目名称:chipKIT32-MAX,代码行数:36,


示例6: mmcSequentialWrite

/** * @brief   Writes a block within a sequential write operation. * * @param[in] mmcp      pointer to the @p MMCDriver object * @param[out] buffer   pointer to the write buffer * @return              The operation status. * @retval FALSE        the operation succeeded. * @retval TRUE         the operation failed. * * @api */bool_t mmcSequentialWrite(MMCDriver *mmcp, const uint8_t *buffer) {  static const uint8_t start[] = {0xFF, 0xFC};  uint8_t b[1];  chDbgCheck((mmcp != NULL) && (buffer != NULL), "mmcSequentialWrite");  chSysLock();  if (mmcp->state != MMC_WRITING) {    chSysUnlock();    return TRUE;  }  chSysUnlock();  spiSend(mmcp->spip, sizeof(start), start);        /* Data prologue.       */  spiSend(mmcp->spip, MMC_SECTOR_SIZE, buffer);     /* Data.                */  spiIgnore(mmcp->spip, 2);                         /* CRC ignored.         */  spiReceive(mmcp->spip, 1, b);  if ((b[0] & 0x1F) == 0x05) {    wait(mmcp);    return FALSE;  }  /* Error.*/  spiUnselect(mmcp->spip);  chSysLock();  if (mmcp->state == MMC_WRITING)    mmcp->state = MMC_READY;  chSysUnlock();  return TRUE;}
开发者ID:glockwork,项目名称:dfu,代码行数:41,


示例7: readEnd

//------------------------------------------------------------------------------// send command and return error code.  Return zero for OKuint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) {  // end read if in partialBlockRead mode  readEnd();  // select card  chipSelectLow();  // wait up to 300 ms if busy  waitNotBusy(300);  // send command  spiSend(cmd | 0x40);  // send argument  for (int8_t s = 24; s >= 0; s -= 8) spiSend(arg >> s);  // send CRC  uint8_t crc = 0XFF;  if (cmd == CMD0) crc = 0X95;  // correct crc for CMD0 with arg 0  if (cmd == CMD8) crc = 0X87;  // correct crc for CMD8 with arg 0X1AA  spiSend(crc);  // wait for response  for (unsigned int i = 0; ((status_ = spiRec()) & 0X80) && i != 0xFFF; i++);  return status_;}
开发者ID:elkintomen,项目名称:chipKIT32-MAX,代码行数:28,


示例8: cmd_write

static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {    (void)argc;    (void)argv;    acquire_bus();    write_index(0x00);    chprintf(chp,"Device ID %x/r/n",read_data());    release_bus();    //chprintf(chp,"GRAM %x/r/n",gdispReadReg(0x22));     /*gdispClear(White);    chThdSleepMilliseconds(3000);    gdispClear(Red);    chThdSleepMilliseconds(3000);    gdispClear(Blue);    chThdSleepMilliseconds(3000);    gdispClear(Green);*/    #if 0    uint8_t c = 0xAA;    uint8_t d = 0x55;    spiAcquireBus(&SPID1);              /* Acquire ownership of the bus.    */    spiStart(&SPID1, &spicfg);       /* Setup transfer parameters.       */    spiSelect(&SPID1);                  /* Slave Select assertion.          */    spiSend(&SPID1, 1, &c);    spiSend(&SPID1, 1, &d);    spiUnselect(&SPID1);                /* Slave Select de-assertion.       */    spiReleaseBus(&SPID1);              /* Ownership release.               */    #endif}
开发者ID:bass0324,项目名称:Bass-GFX-Examples,代码行数:33,


示例9: u8g_com_HAL_DUE_shared_hw_spi_fn

uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {  switch(msg) {    case U8G_COM_MSG_STOP:      break;    case U8G_COM_MSG_INIT:      u8g_SetPILevel_DUE_hw_spi(u8g, U8G_PI_CS, 1);      u8g_SetPILevel_DUE_hw_spi(u8g, U8G_PI_A0, 1);      u8g_SetPIOutput_DUE_hw_spi(u8g, U8G_PI_CS);      u8g_SetPIOutput_DUE_hw_spi(u8g, U8G_PI_A0);      u8g_Delay(5);      spiBegin();      #ifndef SPI_SPEED        #define SPI_SPEED SPI_FULL_SPEED  // use same SPI speed as SD card      #endif      spiInit(2);      break;    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */      u8g_SetPILevel_DUE_hw_spi(u8g, U8G_PI_A0, arg_val);      break;    case U8G_COM_MSG_CHIP_SELECT:      u8g_SetPILevel_DUE_hw_spi(u8g, U8G_PI_CS, (arg_val ? 0 : 1));      break;    case U8G_COM_MSG_RESET:      break;    case U8G_COM_MSG_WRITE_BYTE:      spiSend((uint8_t)arg_val);      break;    case U8G_COM_MSG_WRITE_SEQ: {        uint8_t *ptr = (uint8_t*) arg_ptr;        while (arg_val > 0) {          spiSend(*ptr++);          arg_val--;        }      }      break;    case U8G_COM_MSG_WRITE_SEQ_P: {        uint8_t *ptr = (uint8_t*) arg_ptr;        while (arg_val > 0) {          spiSend(*ptr++);          arg_val--;        }      }      break;  }  return 1;}
开发者ID:teemuatlut,项目名称:Marlin,代码行数:59,


示例10: spiSendBlock

  void spiSendBlock(uint8_t token, const uint8_t* buf) {  spiSend (token);  for (uint16_t i = 0; i < 512; i += 2) {	spiSend (buf[i]);	spiSend (buf[i+1]);  }}
开发者ID:Kazuyoko,项目名称:MarlinKimbra4due,代码行数:9,


示例11: SPI_Write

void SPI_Write(unsigned int addr,unsigned char data){  enablewiz();   			// Activate the CS pin  spiSend(WIZNET_WRITE_OPCODE);   // Send Wiznet W5100 Write OpCode  spiSend(addr >>8); 		// Send Wiznet W5100 Address High Byte  spiSend(addr & 0x00FF);	// Send Wiznet W5100 Address Low Byte  spiSend(data);			// Send the data byte  disablewiz();				// make CS pin not active}
开发者ID:bill2009,项目名称:lcc1802,代码行数:9,


示例12: _writeBuffer

void _writeBuffer(uint16_t len, uint8_t *data){  uint8_t tx[] = { WRITE_BUF_MEM };  spiSelect(_spip);  spiSend(_spip, 1, tx);  spiSend(_spip, len, data);  spiUnselect(_spip);}
开发者ID:utzig,项目名称:chibios-avr-enc28j60-demo,代码行数:9,


示例13: l3gd20SPIWriteRegister

/** * @brief   Writes a value into a generic register using SPI. * @pre     The SPI interface must be initialized and the driver started. * * @param[in] spip      pointer to the SPI interface * @param[in] reg       starting register address * @param[in] n         number of adjacent registers to write * @param[in] b         pointer to a buffer of values. */static void l3gd20SPIWriteRegister(SPIDriver *spip, uint8_t reg, size_t n,                                   uint8_t* b) {  uint8_t cmd;  (n == 1) ? (cmd = reg) : (cmd = reg | L3GD20_MS);  spiSelect(spip);  spiSend(spip, 1, &cmd);  spiSend(spip, n, b);  spiUnselect(spip);}
开发者ID:rusefi,项目名称:ChibiOS,代码行数:18,


示例14: adxl362_write_register

void adxl362_write_register (uint16_t address, uint8_t data) {    uint8_t command = 0x0A;    spiStart(&SPID1, &adxl362_cfg);      /* Setup transfer parameters. */    spiSelect(&SPID1);                   /* Slave Select assertion.    */    spiSend(&SPID1, 1, &command);        /* Write Command              */    spiSend(&SPID1, 1, &address);        /* Address                    */    spiSend(&SPID1, 1, &data);           /* Data                       */    spiUnselect(&SPID1);                 /* Slave Select de-assertion. */}
开发者ID:ka-ross,项目名称:nucleo_f303re,代码行数:10,


示例15: gyro_write_register

void gyro_write_register (uint8_t address, uint8_t data) {  address = address & (~0x80);         /* Clear the write bit (bit 7)      */  spiAcquireBus(&SPID1);               /* Acquire ownership of the bus.    */  spiStart(&SPID1, &gyro_cfg);         /* Setup transfer parameters.       */  spiSelect(&SPID1);                   /* Slave Select assertion.          */  spiSend(&SPID1, 1, &address);        /* Send the address byte            */  spiSend(&SPID1, 1, &data);   spiUnselect(&SPID1);                 /* Slave Select de-assertion.       */  spiReleaseBus(&SPID1);               /* Ownership release.               */}
开发者ID:ka-ross,项目名称:Digital-Systems-Labs,代码行数:10,


示例16: SPI_Read

unsigned char SPI_Read(unsigned int addr){  unsigned char value; 	//data returned from spi transmission  enablewiz();   		// Activate the CS pin  spiSend(WIZNET_READ_OPCODE);   //Send Wiznet W5100 Write OpCode  spiSend(addr >>8);	// Send Wiznet W5100 Address High Byte  spiSend(addr & 0x00FF);  // Send Wiznet W5100 Address Low Byte  value=spixfer(0xff);	// Send Dummy transmission to read the data  disablewiz();			// make CS pin inactive  return(value);}
开发者ID:bill2009,项目名称:lcc1802,代码行数:11,


示例17: adxl362_read_register

uint8_t adxl362_read_register (uint8_t address) {    uint8_t command = 0x0B;    uint8_t dummy = 0x00;    uint8_t receive_data;    spiStart(&SPID1, &adxl362_cfg);       /* Setup transfer parameters. */    spiSelect(&SPID1);                    /* Slave Select assertion. */    spiSend(&SPID1, 1, &command);         /* Transmit Read Command */    spiSend(&SPID1, 1, &address);         /* Read Command */    spiReceive(&SPID1, 1, &receive_data); /* Read the data that is returned */    spiUnselect(&SPID1);                  /* Slave Select de-assertion. */    return (receive_data);}
开发者ID:ka-ross,项目名称:nucleo_f303re,代码行数:13,


示例18: readRegVal

void RFM70::selectBank(uint8_t bank) {	uint8_t tmp = readRegVal(0x07) & 0x80;	if (bank) {		if (!tmp) {			spiSend(0, (uint8_t *) RFM70_cmd_switch_cfg,					NELEMS(RFM70_cmd_switch_cfg));		}	} else {		if (tmp) {			spiSend(0, (uint8_t *) RFM70_cmd_switch_cfg,					NELEMS(RFM70_cmd_switch_cfg));		}	}}
开发者ID:chendong2012,项目名称:cells,代码行数:14,


示例19: send_cmd

static voidsend_cmd(uint8_t cmd, uint32_t addr, const uint8_t* cmd_tx_buf, uint32_t cmd_tx_len, uint8_t* cmd_rx_buf, uint32_t cmd_rx_len){  xflash_txn_begin();  spiSend(SPI_FLASH, 1, &cmd);  if (addr != NO_ADDR) {    uint8_t addr_buf[3];    addr_buf[0] = addr >> 16;    addr_buf[1] = addr >> 8;    addr_buf[2] = addr;    spiSend(SPI_FLASH, 3, addr_buf);  }
开发者ID:jaumann,项目名称:model-t,代码行数:14,


示例20: cardCommand

//------------------------------------------------------------------------------static uint8_t cardCommand(uint8_t cmd, uint32_t arg){  uint8_t r1;  // some cards need extra clocks after transaction to go to ready state  // easiest to put extra clocks before next transaction  spiSSLow();  spiRec();  spiSend(cmd | 0x40);  for (int8_t s = 24; s >= 0; s -= 8) spiSend(arg >> s);  spiSend(cmd == CMD0 ? 0x95 : 0XFF);//must send valid CRC for CMD0  //wait for not busy  for (uint8_t retry = 0; (r1 = spiRec()) == 0xFF && retry != 0XFF; retry++);  return r1;}
开发者ID:enderdsus7,项目名称:arduino-fermentation-controller,代码行数:15,


示例21: spiRec32

static uint32_t spiRec32(uint8_t wishboneSlot) {	 spiSend(0XFF);	 spiSend(0XFF);	 spiSend(0XFF);	 spiSend(0XFF);// Serial.print(USPIDATA&0xff);// Serial.print(" ");	//return USPIDATA&0xff;	//return USPIDATA;	//return SPI.transfer32(0xFFFFFFFF);	//REGISTER(IO_SLOT(12),5) = 0xFFFFFFFF;	return REGISTER(IO_SLOT(wishboneSlot),1);	//return SPI.transfer32(0xFFFFFFFF);}
开发者ID:GadgetFactory,项目名称:DesignLab_Examples,代码行数:14,


示例22: M25P16WritePage

static void M25P16WritePage(uint32_t Address, uint8_t * Buffer)  {    uint8_t Command[] = { M25P16_PAGE_PROGRAM, (Address >> 16) & 0xFF, (Address >> 8) & 0xFF, Address & 0xFF};    M25P16SetWriteEnable();    spiStart(&FLASH_SPI, &HSSpiConfig); /* Setup transfer parameters.       */    spiSelect(&FLASH_SPI); /* Slave Select assertion.          */    spiSend(&FLASH_SPI, 4, Command); /* Send command                     */    spiSend(&FLASH_SPI, 256, Buffer);    spiUnselect(&FLASH_SPI); /* Slave Select de-assertion.       */    spiStop(&FLASH_SPI);    while(M25P16ReadStatus() & 0x1)      chThdSleepMicroseconds(100);  }
开发者ID:hrrr,项目名称:ChibiFlight,代码行数:14,


示例23: eeprom_read

void eeprom_read(uint8_t address, uint8_t *data, uint32_t length){    eeprom_select();    uint8_t header [2] = {0x03, address};    spiSend(&EEPROM_SPI_BUS, 2, header);    spiReceive(&EEPROM_SPI_BUS, length, data);    eeprom_unselect();}
开发者ID:TotalKrill,项目名称:eeprom,代码行数:7,


示例24: spiSend

//------------------------------------------------------------------------------// send one block of data for write block or write multiple blocksuint8_t Sd2Card::writeData(uint8_t token, const uint8_t* src) {  spiSend(token);  for (uint16_t i = 0; i < 512; i++) {    spiSend(src[i]);  }  spiSend(0xff);  // dummy crc  spiSend(0xff);  // dummy crc  status_ = spiRec();  if ((status_ & DATA_RES_MASK) != DATA_RES_ACCEPTED) {    error(SD_CARD_ERROR_WRITE);    chipSelectHigh();    return false;  }  return true;}
开发者ID:abiaozsh,项目名称:MyCode,代码行数:18,


示例25: spiSSHigh

/** Set Slave Select high */inline void spiSSHigh(void) {   //digitalWrite(SS, HIGH);   sbi(PORTB, SS);   // insure SD data out is high Z   spiSend(0XFF);}
开发者ID:lukebaumann,项目名称:CPE453,代码行数:8,


示例26: mmcStopSequentialRead

/** * @brief   Stops a sequential read gracefully. * * @param[in] mmcp      pointer to the @p MMCDriver object * @return              The operation status. * @retval FALSE        the operation succeeded. * @retval TRUE         the operation failed. * * @api */bool_t mmcStopSequentialRead(MMCDriver *mmcp) {  static const uint8_t stopcmd[] = {0x40 | MMC_CMDSTOP, 0, 0, 0, 0, 1, 0xFF};  bool_t result;  chDbgCheck(mmcp != NULL, "mmcStopSequentialRead");  chSysLock();  if (mmcp->state != MMC_READING) {    chSysUnlock();    return TRUE;  }  chSysUnlock();  spiSend(mmcp->spip, sizeof(stopcmd), stopcmd);/*  result = recvr1(mmcp) != 0x00;*/  /* Note, ignored r1 response, it can be not zero, unknown issue.*/  recvr1(mmcp);  result = FALSE;  spiUnselect(mmcp->spip);  chSysLock();  if (mmcp->state == MMC_READING)    mmcp->state = MMC_READY;  chSysUnlock();  return result;}
开发者ID:glockwork,项目名称:dfu,代码行数:36,


示例27: spiSend

/** SPI send multiple bytes */static void spiSend(const uint8_t* output, size_t len) {  // clear any data in RX FIFO  SPI0_MCR = SPI_MCR_MSTR | SPI_MCR_CLR_RXF | SPI_MCR_PCSIS(0x1F);  // use 16 bit frame to avoid TD delay between frames  // send one byte if len is odd  if (len & 1) {    spiSend(*output++);    len--;  }  // initial number of words to push into TX FIFO  int nf = len/2 < SPI_INITIAL_FIFO_DEPTH ? len/2 : SPI_INITIAL_FIFO_DEPTH;  // limit for pushing data into TX fifo  const uint8_t* limit = output + len;  for (int i = 0; i < nf; i++) {    uint16_t w = (*output++) << 8;    w |= *output++;    SPI0_PUSHR = SPI_PUSHR_CONT | SPI_PUSHR_CTAS(1) | w;  }  // write data to TX FIFO  while (output < limit) {    uint16_t w = *output++ << 8;    w |= *output++;    while (!(SPI0_SR & SPI_SR_RXCTR)) {}    SPI0_PUSHR = SPI_PUSHR_CONT | SPI_PUSHR_CTAS(1) | w;    SPI0_POPR;  }  // wait for data to be sent  while (nf) {    while (!(SPI0_SR & SPI_SR_RXCTR)) {}    SPI0_POPR;    nf--;  }}
开发者ID:brianc118,项目名称:Team-PI-Lib,代码行数:34,


示例28: pinMode

/** * Initialize a SD flash memory card. *  * /param[in] slow Set SPI Frequency F_CPU/4 if true else F_CPU/2.  *   * /return The value one, true, is returned for success and * the value zero, false, is returned for failure.  * */  uint8_t SdCard::init(uint8_t slow){  pinMode(SS, OUTPUT);  spiSSHigh();  pinMode(MOSI, OUTPUT);  pinMode(SCK, OUTPUT);  //Enable SPI, Master, clock rate F_CPU/128  SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1) | (1 << SPR0);  //must supply min of 74 clock cycles with CS high.  for (uint8_t i = 0; i < 10; i++) spiSend(0XFF);  spiSSLow();  // next line prevent re-init hang by some cards (not sure why this works)  for (uint16_t i = 0; i <= 512; i++) spiRec();  uint8_t r = cardCommand(CMD0, 0);  for (uint16_t retry = 0; r != R1_IDLE_STATE; retry++){    if (retry == 10000) {      error(SD_ERROR_CMD0, r);      return false;    }    r = spiRec();  }  for (uint16_t retry = 0; ; retry++) {    cardCommand(CMD55, 0);    if ((r = cardCommand(ACMD41, 0)) == R1_READY_STATE)break;    if (retry == 1000) {      error(SD_ERROR_ACMD41, r);      return false;    }  }  // set SPI frequency  SPCR &= ~((1 << SPR1) | (1 << SPR0)); // F_CPU/4  if (!slow) SPSR |= (1 << SPI2X); // Doubled Clock Frequency to F_CPU/2  spiSSHigh();  return true;}
开发者ID:enderdsus7,项目名称:arduino-fermentation-controller,代码行数:44,


示例29: spiClearBuffer

void MD_MAX72XX::flushBufferAll()// Only one data byte is sent to a device, so if there are many changes, it is more// efficient to send a data byte all devices at the same time, substantially cutting// the number of communication messages required.{  for (uint8_t i=0; i<ROW_SIZE; i++)  // all data rows  {    bool bChange = false; // set to true if we detected a change    spiClearBuffer();    for (uint8_t dev = FIRST_BUFFER; dev <= LAST_BUFFER; dev++)	// all devices    {      if (bitRead(_matrix[dev].changed, i))      {        // put our device data into the buffer        _spiData[SPI_OFFSET(dev, 0)] = OP_DIGIT0+i;        _spiData[SPI_OFFSET(dev, 1)] = _matrix[dev].dig[i];        bChange = true;      }    }  if (bChange) spiSend();  }  // mark everything as cleared  for (uint8_t dev = FIRST_BUFFER; dev <= LAST_BUFFER; dev++)    _matrix[dev].changed = ALL_CLEAR;}
开发者ID:mmcromero,项目名称:Arduino,代码行数:29,


示例30: PRINT

void MD_MAX72XX::flushBuffer(uint8_t buf)// Use this function when the changes are limited to one device only.// Address passed is a buffer address{  PRINT("/nflushBuf: ", buf);  PRINTS(" r");  if (buf > LAST_BUFFER)    return;  for (uint8_t i = 0; i < ROW_SIZE; i++)  {    if (bitRead(_matrix[buf].changed, i))    {      PRINT("", i);      spiClearBuffer();      // put our device data into the buffer      _spiData[SPI_OFFSET(buf, 0)] = OP_DIGIT0+i;      _spiData[SPI_OFFSET(buf, 1)] = _matrix[buf].dig[i];      spiSend();    }  }  _matrix[buf].changed = ALL_CLEAR;}
开发者ID:mmcromero,项目名称:Arduino,代码行数:26,



注:本文中的spiSend函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ spiStart函数代码示例
C++ spiSelect函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。