• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ spiReleaseBus函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: lsm303_init

/**
 * Init function.
 */
int lsm303_init(SPIDriver *spip) {
	uint8_t who_am_i;

	// FIXME: interrupt lines will be rearranged!
	spiAcquireBus(spip);
	who_am_i = lsm303dReadRegister(spip, LSM303D_WHO_AM_I);

	if (who_am_i != 0x49) {
		spiReleaseBus(spip);
		return -1;
	}

	lsm303dWriteRegister(spip, LSM303D_CTRL0, 0x00);
	lsm303dWriteRegister(spip, LSM303D_CTRL2, 0x40); // 194Hz anti-alias filter BW
	lsm303dWriteRegister(spip, LSM303D_CTRL3, 0x04); // Acc data-ready on INT1
	lsm303dWriteRegister(spip, LSM303D_CTRL4, 0x04); // Mag data-ready on INT2
	lsm303dWriteRegister(spip, LSM303D_CTRL5, 0xF4); // Temp sensor enabled, magnetometer high-res, Mag 100Hz
	lsm303dWriteRegister(spip, LSM303D_CTRL6, 0x00); // Mag FS ±2 gauss
	lsm303dWriteRegister(spip, LSM303D_CTRL7, 0x00);
	lsm303dWriteRegister(spip, LSM303D_CTRL1, 0x67); // Acc 100Hz, axes enabled, no data update until MSB and LSB read
	spiReleaseBus(spip);

	chThdSleepMilliseconds(250);
	return 0;
}
开发者ID:r2p,项目名称:IMU_module,代码行数:28,代码来源:lsm303d.c


示例2: set_full_scale

static msg_t set_full_scale(void *ip, lis302dl_fs_t fs) {
  float newfs, scale;
  uint8_t i, cr;

  if(fs == LIS302DL_FS_2G) {
    newfs = LIS302DL_2G;
  }
  else if(fs == LIS302DL_FS_8G) {
    newfs = LIS302DL_8G;
  }
  else {
    return MSG_RESET;
  }

  if(newfs != ((LIS302DLDriver *)ip)->fullscale) {
    scale = newfs / ((LIS302DLDriver *)ip)->fullscale;
    ((LIS302DLDriver *)ip)->fullscale = newfs;

#if LIS302DL_USE_SPI
#if LIS302DL_SHARED_SPI
  spiAcquireBus(((LIS302DLDriver *)ip)->config->spip);
  spiStart(((LIS302DLDriver *)ip)->config->spip,
          ((LIS302DLDriver *)ip)->config->spicfg);
#endif /* LIS302DL_SHARED_SPI */
    lis302dlSPIReadRegister(((LIS302DLDriver *)ip)->config->spip,
                            LIS302DL_AD_CTRL_REG1, 1, &cr);
#if LIS302DL_SHARED_SPI
  spiReleaseBus(((LIS302DLDriver *)ip)->config->spip);
#endif /* LIS302DL_SHARED_SPI */
#endif /* LIS302DL_USE_SPI */

    cr &= ~(LIS302DL_CTRL_REG1_FS_MASK);
    cr |= fs;

#if LIS302DL_USE_SPI
#if LIS302DL_SHARED_SPI
  spiAcquireBus(((LIS302DLDriver *)ip)->config->spip);
  spiStart(((LIS302DLDriver *)ip)->config->spip,
          ((LIS302DLDriver *)ip)->config->spicfg);
#endif /* LIS302DL_SHARED_SPI */
    lis302dlSPIWriteRegister(((LIS302DLDriver *)ip)->config->spip,
                             LIS302DL_AD_CTRL_REG1, 1, &cr);
#if LIS302DL_SHARED_SPI
  spiReleaseBus(((LIS302DLDriver *)ip)->config->spip);
#endif /* LIS302DL_SHARED_SPI */
#endif /* LIS302DL_USE_SPI */

    /* Scaling sensitivity and bias. Re-calibration is suggested anyway. */
    for(i = 0; i < LIS302DL_NUMBER_OF_AXES; i++) {
      ((LIS302DLDriver *)ip)->sensitivity[i] *= scale;
      ((LIS302DLDriver *)ip)->bias[i] *= scale;
    }
  }
  return MSG_OK;
}
开发者ID:mabl,项目名称:ChibiOS,代码行数:55,代码来源:lis302dl.c


示例3: wavePlayerThread

static msg_t wavePlayerThread(void *arg) {
	(void)arg;
	chRegSetThreadName("blinker");

	UINT temp, bufSwitch=1;

	codec_pwrCtl(1);
	codec_muteCtl(0);

	f_read(&f1, buf, PLAYBACK_BUFFER_SIZE, &temp);
	bytesToPlay-=temp;

	chEvtAddFlags(1);

	while(bytesToPlay)
	{
		chEvtWaitOne(1);

		if (bufSwitch)
		{
			codec_audio_send(buf, temp/2);
			spiAcquireBus(&SPID1);
			f_read(&f1, buf2, PLAYBACK_BUFFER_SIZE, &temp);
			spiReleaseBus(&SPID1);
			bufSwitch=0;
		}
		else
		{
			codec_audio_send(buf2, temp/2);
			spiAcquireBus(&SPID1);
			f_read(&f1, buf, PLAYBACK_BUFFER_SIZE, &temp);
			spiReleaseBus(&SPID1);
			bufSwitch=1;
		}

		bytesToPlay-=temp;

		if (chThdShouldTerminate()) break;
	}

	codec_muteCtl(1);
	codec_pwrCtl(0);

	playerThread=NULL;

	f_close(&f1);

	return 0;
}
开发者ID:ADTL,项目名称:ARMWork,代码行数:49,代码来源:wavePlayer.c


示例4: 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,代码来源:main.c


示例5: getTemperatureStr

static uint32_t getTemperatureStr(char * temperatureStr)
{

    float temperature = 0;
    float pressure = 0;

    spiAcquireBus(&CC3000_SPI_DRIVER);
    i2cAcquireBus(&I2C_DRIVER);
    i2cStart(&I2C_DRIVER, &i2cConfig);

    if (RDY_OK != mplOneShotReadBarometer(&I2C_DRIVER,
                                          MPL3115A2_DEFAULT_ADDR,
                                          &pressure, 
                                          &temperature))
    {
        return 1;
    }


    i2cStop(&I2C_DRIVER);
    i2cReleaseBus(&I2C_DRIVER);
    spiReleaseBus(&CC3000_SPI_DRIVER);
 
    temperature += CELSIUS_TO_KELVIN;

    snprintf(temperatureStr, TEMPERATURE_STRING_SIZE, "%.2f K", temperature); 
    temperatureStr[TEMPERATURE_STRING_SIZE-1] = 0;


    return 0;
}
开发者ID:alanbarr,项目名称:FinalYearProject,代码行数:31,代码来源:http_sensors.c


示例6: read_raw

static msg_t read_raw(void *ip, int32_t axes[LIS302DL_NUMBER_OF_AXES]) {
  uint8_t i, tmp;

  osalDbgCheck((ip != NULL) && (axes != NULL));

  osalDbgAssert((((LIS302DLDriver *)ip)->state == LIS302DL_READY),
              "read_raw(), invalid state");

#if LIS302DL_USE_SPI
  osalDbgAssert((((LIS302DLDriver *)ip)->config->spip->state == SPI_READY),
                "read_raw(), channel not ready");

#if	LIS302DL_SHARED_SPI
  spiAcquireBus(((LIS302DLDriver *)ip)->config->spip);
  spiStart(((LIS302DLDriver *)ip)->config->spip,
          ((LIS302DLDriver *)ip)->config->spicfg);
#endif /* LIS302DL_SHARED_SPI */

    for(i = 0; i < LIS302DL_NUMBER_OF_AXES; i++) {
      lis302dlSPIReadRegister(((LIS302DLDriver *)ip)->config->spip,
                              LIS302DL_AD_OUT_X + (i * 2), 1, &tmp);
      axes[i] = (int32_t)((int8_t)tmp);
    }

#if	LIS302DL_SHARED_SPI
  spiReleaseBus(((LIS302DLDriver *)ip)->config->spip);
#endif /* LIS302DL_SHARED_SPI */

#endif /* LIS302DL_USE_SPI */ 
  return MSG_OK;
}
开发者ID:mabl,项目名称:ChibiOS,代码行数:31,代码来源:lis302dl.c


示例7: getPressureStr

static uint32_t getPressureStr(char * pressureStr)
{

    float pressure;
    float temperature;

    spiAcquireBus(&CC3000_SPI_DRIVER);
    i2cAcquireBus(&I2C_DRIVER);
    i2cStart(&I2C_DRIVER, &i2cConfig);

    if (RDY_OK != mplOneShotReadBarometer(&I2C_DRIVER,
                                          MPL3115A2_DEFAULT_ADDR,
                                          &pressure, 
                                          &temperature))
    {
        return 1;
    }

    i2cStop(&I2C_DRIVER);
    i2cReleaseBus(&I2C_DRIVER);
    spiReleaseBus(&CC3000_SPI_DRIVER);
 
    pressure /= 1000; /* kPa */

    snprintf(pressureStr, PRESSURE_STRING_SIZE, "%.2f kPa", pressure); 
    pressureStr[PRESSURE_STRING_SIZE-1] = 0;

    return 0;
}
开发者ID:alanbarr,项目名称:FinalYearProject,代码行数:29,代码来源:http_sensors.c


示例8: spiAcquireBus

msg_t Mtd25::spi_write_enable(void) {
  msg_t ret = MSG_RESET;
  uint8_t tmp;

#if SPI_USE_MUTUAL_EXCLUSION
  spiAcquireBus(this->spip);
#endif

  /* try to enable write access */
  spiSelect(spip);
  spiPolledExchange(spip, S25_CMD_WREN);
  spiUnselect(spip);
  chSysPolledDelayX(10);

  /* check result */
  spiSelect(spip);
  spiPolledExchange(spip, S25_CMD_RDSR1);
  tmp = spiPolledExchange(spip, 0);
  spiUnselect(spip);
  if (tmp & S25_SR1_WEL)
    ret = MSG_OK;
  else
    ret = MSG_RESET;

#if SPI_USE_MUTUAL_EXCLUSION
  spiReleaseBus(this->spip);
#endif

  return ret;
}
开发者ID:char32,项目名称:24aa,代码行数:30,代码来源:mtd25.cpp


示例9: read

static flash_error_t read(void *instance, flash_address_t addr,
                          uint8_t *rp, size_t n) {
  N25Q128Driver *devp = (N25Q128Driver *)instance;
  SPIDriver *spip = devp->config->spip;

  osalDbgAssert(devp->state == FLASH_READY, "invalid state");

#if N25Q128_SHARED_SPI == TRUE
  spiAcquireBus(spip);
  spiStart(spip, devp->config->spicfg);
#endif
  devp->state = FLASH_ACTIVE;

  /* Read command.*/
  spiSelect(spip);
  spi_send_cmd_addr(devp, N25Q128_CMD_READ, addr);
  spiReceive(spip, n, rp);
  spiUnselect(spip);

  devp->state = FLASH_READY;
#if N25Q128_SHARED_SPI == TRUE
  spiReleaseBus(spip);
#endif
  return FLASH_NO_ERROR;
}
开发者ID:awygle,项目名称:ChibiOS,代码行数:25,代码来源:n25q128.c


示例10: ll_25xx_transmit_receive

/**
 * @brief 25XX low level write then read rountine.
 *
 * @param[in]  eepcfg pointer to configuration structure of eeprom file.
 * @param[in]  txbuf  pointer to buffer to be transfered.
 * @param[in]  txlen  number of bytes to be transfered.
 * @param[out] rxbuf  pointer to buffer to be received.
 * @param[in]  rxlen  number of bytes to be received.
 */
static void ll_25xx_transmit_receive(const SPIEepromFileConfig *eepcfg,
                                     const uint8_t *txbuf, size_t txlen,
                                     uint8_t *rxbuf, size_t rxlen) {

#if SPI_USE_MUTUAL_EXCLUSION
  spiAcquireBus(eepcfg->spip);
#endif

  spiStart(eepcfg->spip, eepcfg->spicfg);
  spiSelect(eepcfg->spip);
#ifdef POLLED_SPI
  size_t count = 0;
  for( count = 0; count < txlen; ++count )
      spiPolledExchange( eepcfg->spip, txbuf[count] );
  for( count = 0; count < rxlen; ++count )
      rxbuf[count] = spiPolledExchange( eepcfg->spip, 0 );
#else
  spiSend(eepcfg->spip, txlen, txbuf);
  if (rxlen) /* Check if receive is needed. */
    spiReceive(eepcfg->spip, rxlen, rxbuf);
#endif
  spiUnselect(eepcfg->spip);

#if SPI_USE_MUTUAL_EXCLUSION
  spiReleaseBus(eepcfg->spip);
#endif
}
开发者ID:serdzz,项目名称:ChibiOS-Drivers,代码行数:36,代码来源:25xx_driver.c


示例11: l3gd20Stop

/**
 * @brief   Deactivates the L3GD20 Complex Driver peripheral.
 *
 * @param[in] devp       pointer to the @p L3GD20Driver object
 *
 * @api
 */
void l3gd20Stop(L3GD20Driver *devp) {
  uint8_t cr1;
  osalDbgCheck(devp != NULL);

  osalDbgAssert((devp->state == L3GD20_STOP) || (devp->state == L3GD20_READY),
                "l3gd20Stop(), invalid state");

  if (devp->state == L3GD20_READY) {
    /* Disabling all axes and enabling power down mode.*/
    cr1 = 0;
    
#if L3GD20_USE_SPI
#if	L3GD20_SHARED_SPI
    spiAcquireBus(devp->config->spip);
    spiStart(devp->config->spip,
             devp->config->spicfg);
#endif /* L3GD20_SHARED_SPI */

    l3gd20SPIWriteRegister(devp->config->spip, L3GD20_AD_CTRL_REG1, 
                           1, &cr1);
    spiStop(devp->config->spip);
    
#if	L3GD20_SHARED_SPI
    spiReleaseBus(devp->config->spip);
#endif /* L3GD20_SHARED_SPI */ 
#endif /* L3GD20_USE_SPI */
  }			 
  devp->state = L3GD20_STOP;
}
开发者ID:rusefi,项目名称:ChibiOS,代码行数:36,代码来源:l3gd20.c


示例12: adis16405_read_multiple

static void adis16405_read_multiple(int base_addr, int num, uint16_t* rx_buff) {
    spiAcquireBus(&ADIS16405_SPID);
    spiStart(&ADIS16405_SPID, &spi_cfg);
    for (int i = 0; i < num; i++)
        rx_buff[i] = internal_adis16405_read_u16(base_addr + i * 2);

    spiReleaseBus(&ADIS16405_SPID);
}
开发者ID:cuspaceflight,项目名称:spalax,代码行数:8,代码来源:adis16405.c


示例13: xflash_txn_end

static void
xflash_txn_end()
{
  spiUnselect(SPI_FLASH);
#if SPI_USE_MUTUAL_EXCLUSION
  spiReleaseBus(SPI_FLASH);
#endif
}
开发者ID:jaumann,项目名称:model-t,代码行数:8,代码来源:xflash.c


示例14: 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,代码来源:main.c


示例15: sendByte3310

/** * @brief Sends a byte through the SPI interface and return the byte
    * received from the SPI bus. 
    * @param byte : byte to send. 
    * @retval : The value of the received byte. 
    */ 
void sendByte3310( uint8_t byte )
{
    spiAcquireBus( &SPI_3310 );     // Acquire ownership of the bus.
    spiStart( &SPI_3310, &spicfg ); // Setup transfer parameters.
    spiSelect( &SPI_3310 );         // Slave Select assertion.
    spiStartSend( &SPI_3310, 1, &byte );
    //spiExchange( &SPI_3310, 512,
    //             txbuf, rxbuf );  // Atomic transfer operations.
    spiUnselect( &SPI_3310 );       // Slave Select de-assertion.
    spiReleaseBus( &SPI_3310 );     // Ownership release.
}
开发者ID:z80,项目名称:clock,代码行数:16,代码来源:3310-backend.c


示例16: spiAcquireBus

uint16_t A4960::writeReg(const uint8_t addr, const uint16_t data) {
    const uint16_t txData = (uint16_t(addr & 0x7) << 13) | 0x1000 | (data & 0xfff);
    uint16_t rxData;
    spiAcquireBus(spip);
    spiSelect(spip);
    spiExchange(spip, 1, &txData, &rxData);
    spiUnselect(spip);
    spiReleaseBus(spip);

    return rxData;
}
开发者ID:GHF,项目名称:gyroking,代码行数:11,代码来源:A4960.cpp


示例17: sendArray3310

void sendArray3310( uint8_t * data, int cnt )
{
    spiAcquireBus( &SPID1 );     // Acquire ownership of the bus.
    spiStart( &SPID1, &spicfg ); // Setup transfer parameters.
    spiSelect( &SPID1 );         // Slave Select assertion.
    //spiExchange( &SPID1, 512,
    //            txbuf, rxbuf );  // Atomic transfer operations.
    spiStartSend( &SPI_3310, cnt, data );
    spiUnselect( &SPID1 );       // Slave Select de-assertion.
    spiReleaseBus( &SPID1 );     // Ownership release.
}
开发者ID:z80,项目名称:clock,代码行数:11,代码来源:3310-backend.c


示例18: fm25l16_exchange

uint8_t fm25l16_exchange(int len)
{
	spiAcquireBus(&SPID1);              /* Acquire ownership of the bus.    */
	spiStart(&SPID1, &hs_spicfg);       /* Setup transfer parameters.       */
	spiSelect(&SPID1);                  /* Slave Select assertion.          */
	spiExchange(&SPID1, len,
			txbuf, rxbuf);          /* Atomic transfer operations.      */
	spiUnselect(&SPID1);                /* Slave Select de-assertion.       */
    spiReleaseBus(&SPID1);              /* Ownership release.               */
	return len;
}
开发者ID:scarecrowli,项目名称:ChibiOS,代码行数:11,代码来源:fm25l16.c


示例19: fm25l16_write_read

uint8_t fm25l16_write_read(uint8_t cmd)
{
	spiAcquireBus(&SPID1);              /* Acquire ownership of the bus.    */
	spiStart(&SPID1, &hs_spicfg);       /* Setup transfer parameters.       */
	spiSelect(&SPID1);                  /* Slave Select assertion.          */
	tx_ch = cmd;
	spiExchange(&SPID1, 1,
			&tx_ch, &rx_ch);          /* Atomic transfer operations.      */
	spiUnselect(&SPID1);                /* Slave Select de-assertion.       */
    spiReleaseBus(&SPID1);              /* Ownership release.               */
	return rx_ch;
}
开发者ID:scarecrowli,项目名称:ChibiOS,代码行数:12,代码来源:fm25l16.c


示例20: gyro_read_register

uint8_t gyro_read_register (uint8_t address) {
  uint8_t receive_data;
  address = address | 0x80;            /* Set the read 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 */
  spiReceive(&SPID1, 1,&receive_data); 
  spiUnselect(&SPID1);                 /* Slave Select de-assertion.       */
  spiReleaseBus(&SPID1);               /* Ownership release.               */
  return (receive_data);
}
开发者ID:ka-ross,项目名称:Digital-Systems-Labs,代码行数:12,代码来源:main.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ spiSelect函数代码示例发布时间:2022-05-30
下一篇:
C++ spiRec函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap