当前位置: 首页>>代码示例>>C++>>正文


C++ delayMicroseconds函数代码示例

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


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

示例1: digitalWrite

/* Leave pin off for time (given in microseconds) */
void IRsend::space(int time) {
  // Sends an IR space for the specified number of microseconds.
  // A space is no output, so the PWM output is disabled.
  digitalWrite(IRpin, LOW);
  if (time > 0) delayMicroseconds(time);
}
开发者ID:hishamk,项目名称:IRremoteESP8266,代码行数:7,代码来源:IRremoteESP8266.cpp

示例2: pwmSetRangeWPi

void pwmSetRangeWPi (unsigned int range)
{
  *(pwm + PWM0_RANGE) = range ; delayMicroseconds (10) ;
  *(pwm + PWM1_RANGE) = range ; delayMicroseconds (10) ;
}
开发者ID:damiencorpataux,项目名称:raspi-breakout-sandbox,代码行数:5,代码来源:wiringPi.c

示例3: command

void LiquidCrystal::home()
{
  command(LCD_RETURNHOME);  // set cursor position to zero
  delayMicroseconds(2000);  // this command takes a long time!
}
开发者ID:tanelili,项目名称:Lab4_1_Bar,代码行数:5,代码来源:LiquidCrystal.cpp

示例4: command

void LCD::home()
{
   command(LCD_RETURNHOME);             // set cursor position to zero
   delayMicroseconds(HOME_CLEAR_EXEC);  // This command is time consuming
}
开发者ID:pesilajo,项目名称:mybcschas,代码行数:5,代码来源:LCD.cpp

示例5: initMPU6000

void initMPU6000(void)
{
    ///////////////////////////////////

    GPIO_ResetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);
    spiTransfer(MPU6000_SPI, MPU6000_PWR_MGMT_1);          // Device Reset
    spiTransfer(MPU6000_SPI, BIT_H_RESET);
    GPIO_SetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);

    delay(150);

    GPIO_ResetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);
    spiTransfer(MPU6000_SPI, MPU6000_PWR_MGMT_1);          // Clock Source PPL with Z axis gyro reference
    spiTransfer(MPU6000_SPI, MPU_CLK_SEL_PLLGYROZ);
    GPIO_SetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);

    delayMicroseconds(1);

    GPIO_ResetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);
    spiTransfer(MPU6000_SPI, MPU6000_USER_CTRL);           // Disable Primary I2C Interface
    spiTransfer(MPU6000_SPI, BIT_I2C_IF_DIS);
    GPIO_SetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);

    delayMicroseconds(1);

    GPIO_ResetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);
    spiTransfer(MPU6000_SPI, MPU6000_PWR_MGMT_2);
    spiTransfer(MPU6000_SPI, 0x00);
    GPIO_SetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);

    delayMicroseconds(1);

    GPIO_ResetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);
    spiTransfer(MPU6000_SPI, MPU6000_SMPLRT_DIV);          // Accel Sample Rate 1000 Hz, Gyro Sample Rate 8000 Hz
    spiTransfer(MPU6000_SPI, 0x00);
    GPIO_SetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);

    delayMicroseconds(1);

    GPIO_ResetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);
    spiTransfer(MPU6000_SPI, MPU6000_CONFIG);              // Accel and Gyro DLPF Setting
    spiTransfer(MPU6000_SPI, eepromConfig.dlpfSetting);
    GPIO_SetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);

    delayMicroseconds(1);

    GPIO_ResetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);
    spiTransfer(MPU6000_SPI, MPU6000_ACCEL_CONFIG);        // Accel +/- 4 G Full Scale
    spiTransfer(MPU6000_SPI, BITS_FS_4G);
    GPIO_SetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);

    delayMicroseconds(1);

    GPIO_ResetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);
    spiTransfer(MPU6000_SPI, MPU6000_GYRO_CONFIG);         // Gyro +/- 1000 DPS Full Scale
    spiTransfer(MPU6000_SPI, BITS_FS_1000DPS);
    GPIO_SetBits(MPU6000_CS_GPIO, MPU6000_CS_PIN);

    ///////////////////////////////////

    setSPIdivisor(MPU6000_SPI, 2);                         // 21 MHz SPI clock (within 20 +/- 10%)

    ///////////////////////////////////

    delay(100);

    computeMPU6000RTData();
}
开发者ID:Tarsisnat,项目名称:aq32plus,代码行数:68,代码来源:mpu6000.c

示例6: digitalWrite

void NewRemoteTransmitter::_sendStopPulse() {
	digitalWrite(_pin, HIGH);
	delayMicroseconds(_periodusec);
	digitalWrite(_pin, LOW);
	delayMicroseconds(_periodusec * 40);
}
开发者ID:PrinceBalabis,项目名称:Arduino_Repo,代码行数:6,代码来源:NewRemoteTransmitter.cpp

示例7: Modbus_WaitForReply

void Modbus_WaitForReply(void)
{
#define MODBUS_TIMEOUT	1000	// millis
	mb_state = RECEIVING_DATA;
	buffer = 0;
	timeout = millis();	// wait up to one second for reply
//	if ( (*ModbusPort).available() ) // is there something to check?
	while ( (millis()-timeout)<MODBUS_TIMEOUT && mb_state==RECEIVING_DATA )
	{
		while ( ec_client.available() )
		{
			WDG_RST;  // avoid reset
			// The maximum number of bytes is limited to the serial buffer size of BUFFER_SIZE.
			// If more bytes is received than BUFFER_SIZE, the overflow flag will be set and
			// the serial buffer will be flushed as long as the slave is still responding.
			uint8_t mb_data = ec_client.read();
			//Serial.println(mb_data,HEX);	// debug
			if ( mb_state==RECEIVING_DATA )	{
				if ( buffer==0 && mb_data==0 )	continue;	// workaround for leading '0'
				// read and check data byte
				if ( buffer>=BUFFER_SIZE )
					ProcessError(BUFFER_OVERFLOW);	// buffer size overflow
				else if ( buffer==0 && mb_data!=frame[0] )
					ProcessError(WRONG_ID);	// wrong slave ID
				else if ( buffer==1 && (mb_data!=frame[1] || (0x80&frame[1])) )
					ProcessError(WRONG_FUNCTION);	// wrong function code
				else if ( buffer==2 && mb_data!=2*frame[5] )
					ProcessError(WRONG_DATA_LEN);	// wrong data lenght
			}
			if ( mb_state==RECEIVING_DATA )	// store data byte only if no error detected so far
			{
				frame[buffer++] = mb_data;  // store data and increment index
				 // check frame length and CRC
				if ( buffer>2 && (frame[2]+5)==buffer )	// last byte of frame received
				{
					*(uint16_t *)&frame[buffer] = *(uint16_t *)&frame[buffer-2];	// save received CRC
					CalculateCRC(buffer-2);	// overwrite received CRC with calculated value in the frame buffer
					if ( *(uint16_t *)&frame[buffer] != *(uint16_t *)&frame[buffer-2] )
						ProcessError(WRONG_CRC);	// wrong CRCs
					else
						ProcessSuccess();	// complete and correct reply frame received
				}
			}
			// insert inter character time out if no new data received yet
			if ( !ec_client.available() )
				delayMicroseconds(T1_5);
		}

		////////// END OF FRAME RECPTION //////////
		WDG_RST;  // avoid reset

		// The minimum buffer size from a slave can be an exception response of 5 bytes.
		// If the buffer was partially filled set a frame_error.
		if ( buffer>0 )
			ProcessError(WRONG_FRAME_LEN);	// too few bytes received
	}
	WDG_RST;  // avoid reset
	if ( buffer==0 )
		ProcessError(REPLY_TIMEOUT);	// timeout error, no data received
	startDelay = millis(); // starting delay
}
开发者ID:stevstrong,项目名称:HomeServer,代码行数:61,代码来源:energy_cam.cpp

示例8: ucg_com_arduino_illi9325_SW_SPI

static int16_t ucg_com_arduino_illi9325_SW_SPI(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data)
{

  switch(msg)
  {
    case UCG_COM_MSG_POWER_UP:
      /* "data" is a pointer to ucg_com_info_t structure with the following information: */
      /*	((ucg_com_info_t *)data)->serial_clk_speed value in nanoseconds */
      /*	((ucg_com_info_t *)data)->parallel_clk_speed value in nanoseconds */

#ifdef __AVR__
      ucg_com_arduino_init_shift_out(ucg->pin_list[UCG_PIN_SDA], ucg->pin_list[UCG_PIN_SCL]);
#endif
    
      /* setup pins */
      pinMode(ucg->pin_list[UCG_PIN_CD], OUTPUT);
      pinMode(ucg->pin_list[UCG_PIN_SDA], OUTPUT);
      pinMode(ucg->pin_list[UCG_PIN_SCL], OUTPUT);
      if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
	pinMode(ucg->pin_list[UCG_PIN_CS], OUTPUT);
      if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE )
	pinMode(ucg->pin_list[UCG_PIN_RST], OUTPUT);

      digitalWriteFast(ucg->pin_list[UCG_PIN_CD], 1);
      digitalWriteFast(ucg->pin_list[UCG_PIN_SDA], 1);
      digitalWriteFast(ucg->pin_list[UCG_PIN_SCL], 0);
      if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
	digitalWriteFast(ucg->pin_list[UCG_PIN_CS], 1);
      if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE )
	digitalWriteFast(ucg->pin_list[UCG_PIN_RST], 1);

      break;
    case UCG_COM_MSG_POWER_DOWN:
      break;
    case UCG_COM_MSG_DELAY:
      delayMicroseconds(arg);
      break;
    case UCG_COM_MSG_CHANGE_RESET_LINE:
      if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE )
	digitalWriteFast(ucg->pin_list[UCG_PIN_RST], arg);
      break;
      
    case UCG_COM_MSG_CHANGE_CS_LINE:
#ifdef __AVR__
      ucg_com_arduino_init_shift_out(ucg->pin_list[UCG_PIN_SDA], ucg->pin_list[UCG_PIN_SCL]);
#endif    
      if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
	digitalWriteFast(ucg->pin_list[UCG_PIN_CS], arg);      
      break;
      
    case UCG_COM_MSG_CHANGE_CD_LINE:
      if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
      {
	digitalWriteFast(ucg->pin_list[UCG_PIN_CS], 1);      
	digitalWriteFast(ucg->pin_list[UCG_PIN_CS], 0);      
      }

      if ( ucg->com_status & UCG_COM_STATUS_MASK_CD )
	ucg_com_arduino_send_generic_SW_SPI(ucg, 0x072);
      else
	ucg_com_arduino_send_generic_SW_SPI(ucg, 0x070);      
	
      break;
      
    case UCG_COM_MSG_SEND_BYTE:
      ucg_com_arduino_send_generic_SW_SPI(ucg, arg);
      break;
    case UCG_COM_MSG_REPEAT_1_BYTE:
      while( arg > 0 ) {
	ucg_com_arduino_send_generic_SW_SPI(ucg, data[0]);
	arg--;
      }
      break;
    case UCG_COM_MSG_REPEAT_2_BYTES:
      while( arg > 0 ) {
	ucg_com_arduino_send_generic_SW_SPI(ucg, data[0]);
	ucg_com_arduino_send_generic_SW_SPI(ucg, data[1]);
	arg--;
      }
      break;
    case UCG_COM_MSG_REPEAT_3_BYTES:
      while( arg > 0 ) {
	ucg_com_arduino_send_generic_SW_SPI(ucg, data[0]);
	ucg_com_arduino_send_generic_SW_SPI(ucg, data[1]);
	ucg_com_arduino_send_generic_SW_SPI(ucg, data[2]);
	arg--;
      }
      break;
    case UCG_COM_MSG_SEND_STR:
      while( arg > 0 ) {
	ucg_com_arduino_send_generic_SW_SPI(ucg, *data++);
	arg--;
      }
      break;
    case UCG_COM_MSG_SEND_CD_DATA_SEQUENCE:
      while(arg > 0)
      {
	if ( *data != 0 )
	{
	  if ( *data == 1 )
//.........这里部分代码省略.........
开发者ID:ramonschepers,项目名称:arduino_framebuffer,代码行数:101,代码来源:Ucglib.cpp

示例9: ucg_com_arduino_3wire_9bit_SW_SPI

static int16_t ucg_com_arduino_3wire_9bit_SW_SPI(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data)
{

  switch(msg)
  {
    case UCG_COM_MSG_POWER_UP:
      /* "data" is a pointer to ucg_com_info_t structure with the following information: */
      /*	((ucg_com_info_t *)data)->serial_clk_speed value in nanoseconds */
      /*	((ucg_com_info_t *)data)->parallel_clk_speed value in nanoseconds */
      
      /* setup pins */
      pinMode(ucg->pin_list[UCG_PIN_SDA], OUTPUT);
      pinMode(ucg->pin_list[UCG_PIN_SCL], OUTPUT);
      if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
	pinMode(ucg->pin_list[UCG_PIN_CS], OUTPUT);
      if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE )
	pinMode(ucg->pin_list[UCG_PIN_RST], OUTPUT);

      digitalWriteFast(ucg->pin_list[UCG_PIN_SDA], 1);
      digitalWriteFast(ucg->pin_list[UCG_PIN_SCL], 0);
      if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
	digitalWriteFast(ucg->pin_list[UCG_PIN_CS], 1);
      if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE )
	digitalWriteFast(ucg->pin_list[UCG_PIN_RST], 1);

      break;
    case UCG_COM_MSG_POWER_DOWN:
      break;
    case UCG_COM_MSG_DELAY:
      delayMicroseconds(arg);
      break;
    case UCG_COM_MSG_CHANGE_RESET_LINE:
      if ( ucg->pin_list[UCG_PIN_RST] != UCG_PIN_VAL_NONE )
	digitalWriteFast(ucg->pin_list[UCG_PIN_RST], arg);
      break;
    case UCG_COM_MSG_CHANGE_CS_LINE:
      if ( ucg->pin_list[UCG_PIN_CS] != UCG_PIN_VAL_NONE )
	digitalWriteFast(ucg->pin_list[UCG_PIN_CS], arg);
      break;
    case UCG_COM_MSG_CHANGE_CD_LINE:
      /* ignored, there is not CD line */
      break;
    case UCG_COM_MSG_SEND_BYTE:
      ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, ucg->com_status &UCG_COM_STATUS_MASK_CD, arg);
      break;
    case UCG_COM_MSG_REPEAT_1_BYTE:
      while( arg > 0 ) {
	ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, ucg->com_status &UCG_COM_STATUS_MASK_CD, data[0]);
	arg--;
      }
      break;
    case UCG_COM_MSG_REPEAT_2_BYTES:
      while( arg > 0 ) {
	ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, ucg->com_status &UCG_COM_STATUS_MASK_CD, data[0]);
	ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, ucg->com_status &UCG_COM_STATUS_MASK_CD, data[1]);
	arg--;
      }
      break;
    case UCG_COM_MSG_REPEAT_3_BYTES:
      while( arg > 0 ) {
	ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, ucg->com_status &UCG_COM_STATUS_MASK_CD, data[0]);
	ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, ucg->com_status &UCG_COM_STATUS_MASK_CD, data[1]);
	ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, ucg->com_status &UCG_COM_STATUS_MASK_CD, data[2]);
	arg--;
      }
      break;
    case UCG_COM_MSG_SEND_STR:
      while( arg > 0 ) {
	ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, ucg->com_status &UCG_COM_STATUS_MASK_CD, *data++);
	arg--;
      }
      break;
    case UCG_COM_MSG_SEND_CD_DATA_SEQUENCE:
      {
	uint8_t last_cd = ucg->com_status &UCG_COM_STATUS_MASK_CD;
	while(arg > 0)
	{
	  if ( *data != 0 )
	  {
	    if ( *data == 1 )
	    {
	      last_cd = 0;
	    }
	    else
	    {
	      last_cd = 1;
	    }
	  }
	  data++;
	  ucg_com_arduino_send_3wire_9bit_SW_SPI(ucg, last_cd, *data); 
	  data++;
	  arg--;
	}
      }
      break;
  }
  return 1;
}
开发者ID:ramonschepers,项目名称:arduino_framebuffer,代码行数:98,代码来源:Ucglib.cpp

示例10: delayMicroseconds

void HD7279A::sendCmdAndData(unsigned char cmd, unsigned char data) {
	delayMicroseconds(50);
	sendRawData(cmd);
	delayMicroseconds(20);
	sendRawData(data);
}
开发者ID:derekhe,项目名称:arduino-mega-2560-eclipse-workspace,代码行数:6,代码来源:HD7279A.cpp

示例11: delay

void delay(uint32_t ms)
{
    while (ms--)
        delayMicroseconds(1000);
}
开发者ID:AXH2O,项目名称:raceflight,代码行数:5,代码来源:system.c

示例12: digitalWrite

void HD7279A::sendCmd(unsigned char cmd) {
	digitalWrite(clkPin, 0);
	delayMicroseconds(50);
	sendRawData(cmd);
}
开发者ID:derekhe,项目名称:arduino-mega-2560-eclipse-workspace,代码行数:5,代码来源:HD7279A.cpp

示例13: delayMicroseconds

uint8_t OS_SoftSPIClass::transfer(uint8_t _data) {
  uint8_t index;
  uint8_t shiftIn;
  uint8_t shiftOut;
  int reg;

  //
  // SPI implements a virtual ring that exchanges a byte
  // (or other sized word) from the master to the slave a
  // single bit at a time.
  //
  // Note: some chips may exchange a word of different
  // bit size. For example some A/D chips will transfer
  // 12 bits for their samples. See the chip programming
  // data sheet. This class may need to be updated to exchange
  // larger bit sizes as it currently uses the default 8.
  //
  // If you do this, create a transfer12() or other function
  // since its likely the chip will require a mixture of
  // byte commands and 12 bit readings depending on the
  // chip.
  //
  // A Chip Select (CS) line is set to LOW to enable a chip
  // before communication is started. By default HIGH deselects
  // the chip. Only one chip may be selected at a time
  // to allow for multi-drop support.
  //
  // The Chip Select (CS) is the responsibility of the caller/user
  // of this class, including waiting any chip specific wait
  // times. For example a humidity sensor requires some number
  // of milliseconds once its CS is asserted before data
  // may be transfered using this function.
  //
  // The SCK line clocks the data in and out. Its IDLE value
  // depends on the Clock Polarity (CPOL) value.
  // CPOL=0 clock is IDLE low
  // CPOL=1 clock is IDLE high
  //
  // A bit is sampled at either the assertion, or de-assertion
  // of the SCK signal depending on the configured Clock Phase
  //(CPHA). In either case, the data must be stable at the time
  // it is sampled.
  //
  // Both devices expect a whole, word to be exchanged per transfer,
  // so 8 SCLK transitions are expected for a byte transfer sequence.
  //
  // Since this is a data exchange between the master and the slave,
  // the send/write data is shifted out of the MOSI (Master Out Slave In)
  // port at the same time the receive/read data is shifted in from the
  // MISO (Master In Slave Out) port.
  //
  // Whether the Most Significant Bit (MSB) or the Least Significant Bit
  // (LSB) is transferred first depends on the configured bit order
  // in setBitOrder().
  //
  // There is always a received word from the slave device when a word is
  // sent as the serial ring protocol demands it. This function will always
  // return that value, but the caller may not use it depending on the device
  // and its protocol. In many device sequences there a series of commands
  // which act in one direction, and responses, reads which return meanful
  // data.
  //
  // For example, many devices internally implement a "virtual register file"
  // similar to a set of I/O ports. Commands typically look like:
  //
  // Register Read:
  //
  // transfer(READ_REGISTER_COMMAND);
  // regValue = transfer(REGISTER_NUMBER);
  //
  // Register Write:
  //
  // transfer(WRITE_REGISTER_COMMAND);
  // transfer(REGISTER_NUMBER);
  // transfer(data_value);
  //

  // The caller controls CSN select, so issue its delay here if set
  delayMicroseconds(m_csnDelay);

  shiftIn = 0;
  shiftOut = _data;

  if (m_lsbFirst) {

    for(index = 0; index < 8; index++) {

      shiftIn >>= 1;

      // Send the bit
      if (shiftOut & 0x01) {
	reg = HIGH;
      }
      else {
        reg = LOW;
      }

      //
      // Write the output bit to the slave
      //
//.........这里部分代码省略.........
开发者ID:menloparkinnovation,项目名称:openpux,代码行数:101,代码来源:OS_SoftSPI.cpp

示例14: jshDelayMicroseconds

void jshDelayMicroseconds(int microsec) {
  delayMicroseconds(microsec);
}
开发者ID:HTH-CODE,项目名称:Espruino,代码行数:3,代码来源:jshardware.cpp

示例15: main

int main(int argc, const char* argv[])
{
	int result = 1;
	// run this program in background when not in Debug mode
#ifndef DEBUG
	{
		pid_t pid, sid;
		pid = fork();
		if (pid < 0)
		{
			exit(EXIT_FAILURE);
		}
		if (pid > 0)
		{
			exit(EXIT_SUCCESS);
		}
		
		// change file mode mask
		umask(0);
		// open logs,,, but I did not record any logs
		
		// create SID for child process
		sid = setsid();
		if (sid < 0)
		{
			exit(EXIT_FAILURE);
		}
		
		close(STDIN_FILENO);
		close(STDOUT_FILENO);
		//close(STDERR_FILENO);
	}
#endif	
	signal(SIGINT, break_program);
	
	// First to setup wiringPi
	if (wiringPiSetup() < 0)
	{
		fprintf(stderr, "Unable to setup wiringPi: %s \n", strerror(errno));
		return 1;	//exit(1);
	}
	pinMode(TRIG_GPIO_PIN, OUTPUT);
	pinMode(ECHO_GPIO_PIN, INPUT);
	pullUpDnControl(ECHO_GPIO_PIN, PUD_DOWN);

	if (wiringPiISR (ECHO_GPIO_PIN, INT_EDGE_BOTH, &myInterrupt) < 0)
	{
		fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno)) ;
		return 1 ;
	}


	
	loopingStatus = 1;
#ifdef DEBUG
	printf("All initialized...\n");
#endif
	while(loopingStatus)
	{
#ifdef DEBUG
	printf("waiting for signal...\n");
#endif
		digitalWrite(TRIG_GPIO_PIN, LOW);
		delayMicroseconds(10);
		digitalWrite(TRIG_GPIO_PIN, HIGH);
		usleep(10);
		digitalWrite(TRIG_GPIO_PIN, LOW);
		sleep(5);
	}
	
	return 0;
}
开发者ID:micromath,项目名称:rpi-car,代码行数:72,代码来源:ultrasonic.c


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