コード例 #1
0
ファイル: lsm303d.c プロジェクト: r2p/IMU_module
/**
 * 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;
}
コード例 #2
0
ファイル: lis302dl.c プロジェクト: mabl/ChibiOS
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;
}
コード例 #3
0
ファイル: wavePlayer.c プロジェクト: ADTL/ARMWork
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;
}
コード例 #4
0
ファイル: main.c プロジェクト: bass0324/Bass-GFX-Examples
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
}
コード例 #5
0
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;
}
コード例 #6
0
ファイル: lis302dl.c プロジェクト: mabl/ChibiOS
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;
}
コード例 #7
0
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;
}
コード例 #8
0
ファイル: mtd25.cpp プロジェクト: char32/24aa
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;
}
コード例 #9
0
ファイル: n25q128.c プロジェクト: awygle/ChibiOS
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;
}
コード例 #10
0
ファイル: 25xx_driver.c プロジェクト: serdzz/ChibiOS-Drivers
/**
 * @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
}
コード例 #11
0
ファイル: l3gd20.c プロジェクト: rusefi/ChibiOS
/**
 * @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;
}
コード例 #12
0
ファイル: adis16405.c プロジェクト: cuspaceflight/spalax
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);
}
コード例 #13
0
ファイル: xflash.c プロジェクト: jaumann/model-t
static void
xflash_txn_end()
{
  spiUnselect(SPI_FLASH);
#if SPI_USE_MUTUAL_EXCLUSION
  spiReleaseBus(SPI_FLASH);
#endif
}
コード例 #14
0
ファイル: main.c プロジェクト: ka-ross/Digital-Systems-Labs
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.               */
}
コード例 #15
0
ファイル: 3310-backend.c プロジェクト: z80/clock
/** * @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.
}
コード例 #16
0
ファイル: A4960.cpp プロジェクト: GHF/gyroking
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;
}
コード例 #17
0
ファイル: 3310-backend.c プロジェクト: z80/clock
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.
}
コード例 #18
0
ファイル: fm25l16.c プロジェクト: scarecrowli/ChibiOS
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;
}
コード例 #19
0
ファイル: A4960.cpp プロジェクト: GHF/gyroking
uint16_t A4960::readReg(const uint8_t addr) {
    const uint16_t txData = (uint16_t(addr & 0x7) << 13);
    uint16_t rxData;
    spiAcquireBus(spip);
    spiSelect(spip);
    spiExchange(spip, 1, &txData, &rxData);
    spiUnselect(spip);
    spiReleaseBus(spip);

    return rxData;
}
コード例 #20
0
ファイル: fm25l16.c プロジェクト: scarecrowli/ChibiOS
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;
}
コード例 #21
0
ファイル: main.c プロジェクト: ka-ross/Digital-Systems-Labs
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);
}
コード例 #22
0
ファイル: microspi.c プロジェクト: Ankhbayar/mlab-chibios
uint8_t writeByteSPI(uint8_t txbyte)
{
	uint8_t rxbyte = 0;
	spiAcquireBus(&SPID1);              /* Acquire ownership of the bus.    */
    spiStart(&SPID1, spicfg);       /* Setup transfer parameters.       */
    spiSelect(&SPID1);                  /* Slave Select assertion.          */
    spiExchange(&SPID1, 1,
                &txbyte, &rxbyte);          /* Atomic transfer operations.      */
    spiUnselect(&SPID1);                /* Slave Select de-assertion.       */
    spiReleaseBus(&SPID1);
	chThdSleepMilliseconds(1);
	return rxbyte;
}
コード例 #23
0
ファイル: ADIS16405.c プロジェクト: pfhnr/stm32
/*! \brief Process information from a adis_spi_cb event
 *
 */
void adis_spi_cb_txdone_handler(eventid_t id) {
	(void) id;
	switch(adis_driver.reg) {
		case ADIS_PRODUCT_ID:
			spiUnselect(adis_driver.spi_instance);
			spiReleaseBus(adis_driver.spi_instance);
			adis_tstall_delay();
			spiAcquireBus(adis_driver.spi_instance);
			spiSelect(adis_driver.spi_instance);
			spiStartReceive(adis_driver.spi_instance, adis_driver.rx_numbytes, adis_driver.adis_rxbuf);
			adis_driver.state             = ADIS_RX_PEND;
			break;
		case ADIS_GLOB_CMD:
			spiStartReceive(adis_driver.spi_instance, adis_driver.rx_numbytes, adis_driver.adis_rxbuf);
			adis_driver.state             = ADIS_RX_PEND;
			break;
		default:
			spiUnselect(adis_driver.spi_instance);
			spiReleaseBus(adis_driver.spi_instance);
			adis_driver.state             = ADIS_IDLE;
			break;
	}
}
コード例 #24
0
ファイル: max6675.c プロジェクト: atalax/reflow-controller
int max6675_get_temp(const struct max6675 *max)
{
	uint16_t read;

	spiAcquireBus(max->driver);
	spiStart(max->driver, &max->config);
	spiSelect(max->driver);
	spiReceive(max->driver, 1, &read);
	spiUnselect(max->driver);
	spiStop(max->driver);
	spiReleaseBus(max->driver);

	return (read >> 3) * 250;
}
コード例 #25
0
ファイル: adis16405.c プロジェクト: cuspaceflight/spalax
static void adis16405_write_u8(uint8_t addr, uint8_t val) {
    uint16_t txbuf[1] = {
        ((((uint16_t)addr | 0x80) << 8) | val)
    };

    spiAcquireBus(&ADIS16405_SPID);
    spiStart(&ADIS16405_SPID, &spi_cfg);

    spiSelect(&ADIS16405_SPID);
    spiSend(&ADIS16405_SPID, 1, (void*)txbuf);
    spiUnselect(&ADIS16405_SPID);

    spiReleaseBus(&ADIS16405_SPID);
}
コード例 #26
0
ファイル: main.c プロジェクト: oh3eqn/ChibiOS
static THD_FUNCTION(spi_thread_2, p) {

  (void)p;
  chRegSetThreadName("SPI thread 2");
  while (true) {
    spiAcquireBus(&PORTAB_SPI1);        /* Acquire ownership of the bus.    */
    palWriteLine(PORTAB_LINE_LED1, PORTAB_LED_OFF);
    spiStart(&PORTAB_SPI1, &ls_spicfg); /* Setup transfer parameters.       */
    spiSelect(&PORTAB_SPI1);            /* Slave Select assertion.          */
    spiExchange(&PORTAB_SPI1, 512,
                txbuf, rxbuf);          /* Atomic transfer operations.      */
    spiUnselect(&PORTAB_SPI1);          /* Slave Select de-assertion.       */
    spiReleaseBus(&PORTAB_SPI1);        /* Ownership release.               */
  }
}
コード例 #27
0
ファイル: main.c プロジェクト: KTannenberg/ChibiOS
static THD_FUNCTION(spi_thread_2, p) {

  (void)p;
  chRegSetThreadName("SPI thread 2");
  while (true) {
    spiAcquireBus(&SPID2);              /* Acquire ownership of the bus.    */
    palClearPad(GPIOA, GPIOA_LED_GREEN);/* LED OFF.                         */
    spiStart(&SPID2, &ls_spicfg);       /* Setup transfer parameters.       */
    spiSelect(&SPID2);                  /* Slave Select assertion.          */
    spiExchange(&SPID2, 512,
                txbuf, rxbuf);          /* Atomic transfer operations.      */
    spiUnselect(&SPID2);                /* Slave Select de-assertion.       */
    spiReleaseBus(&SPID2);              /* Ownership release.               */
  }
}
コード例 #28
0
ファイル: main.c プロジェクト: ChibiOS/ChibiOS-Contrib
static THD_FUNCTION(spi_thread_1, p)
{
  (void)p;
  chRegSetThreadName("SPI thread 1");
  while (TRUE) {
    spiAcquireBus(&SPID1);              /* Acquire ownership of the bus.    */
    palSetPad(GPIOF, GPIOF_LED_GREEN);  /* LED ON.                          */
    spiStart(&SPID1, &hs_spicfg);       /* Setup transfer parameters.       */
    spiSelect(&SPID1);                  /* Slave Select assertion.          */
    spiExchange(&SPID1, 512,
                txbuf, rxbuf);          /* Atomic transfer operations.      */
    spiUnselect(&SPID1);                /* Slave Select de-assertion.       */
    spiReleaseBus(&SPID1);              /* Ownership release.               */
  }
}
コード例 #29
0
ファイル: main.c プロジェクト: CNCBASHER/ChibiOS
static msg_t spi_thread_2(void *p) {

  (void)p;
  chRegSetThreadName("SPI thread 2");
  while (TRUE) {
    spiAcquireBus(&SPID1);              /* Acquire ownership of the bus.    */
    palSetPad(IOPORT3, GPIOC_LED);      /* LED OFF.                         */
    spiStart(&SPID1, &ls_spicfg);       /* Setup transfer parameters.       */
    spiSelect(&SPID1);                  /* Slave Select assertion.          */
    spiExchange(&SPID1, 512,
                txbuf, rxbuf);          /* Atomic transfer operations.      */
    spiUnselect(&SPID1);                /* Slave Select de-assertion.       */
    spiReleaseBus(&SPID1);              /* Ownership release.               */
  }
  return 0;
}
コード例 #30
0
ファイル: main.c プロジェクト: hmchen1/ChibiOS-RT
static msg_t spi_thread_1(void *p) {

    (void)p;
    chRegSetThreadName("SPI thread 1");
    while (TRUE) {
        spiAcquireBus(&SPID2);              /* Acquire ownership of the bus.    */
        palClearPad(PORT11, P11_LED1);      /* LED ON.                          */
        spiStart(&SPID2, &hs_spicfg);       /* Setup transfer parameters.       */
        spiSelect(&SPID2);                  /* Slave Select assertion.          */
        spiExchange(&SPID2, 512,
                    txbuf, rxbuf);          /* Atomic transfer operations.      */
        spiUnselect(&SPID2);                /* Slave Select de-assertion.       */
        spiReleaseBus(&SPID2);              /* Ownership release.               */
    }
    return 0;
}