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

C++ delayMicroseconds函数代码示例

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

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



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


示例16: st7032_clear

/********** high level commands, for the user! */
void st7032_clear()
{
  st7032_command(LCD_CLEARDISPLAY);  // clear display, set cursor position to zero
  delayMicroseconds(2000);  // this command takes a long time!
}
开发者ID:LAPIS-Lazurite,项目名称:LazuriteIDE_0.10.x,代码行数:6,代码来源:ST7032.c


示例17: st7032_home

void st7032_home()
{
  st7032_command(LCD_RETURNHOME);  // set cursor position to zero
  delayMicroseconds(2000);  // this command takes a long time!
}
开发者ID:LAPIS-Lazurite,项目名称:LazuriteIDE_0.10.x,代码行数:5,代码来源:ST7032.c


示例18: switch

// * Receiving the lenght of bytes from Serial port
void HerkulexClass::readData(int size)
{
	int i = 0;
    int beginsave=0;
    int Time_Counter=0;
    switch (port)
	{
	case SSerial:

        while((SwSerial.available() < size) & (Time_Counter < TIME_OUT)){
        		Time_Counter++;
        		delayMicroseconds(1000);  //wait 1 millisecond for 10 times
		}
        	
		while (SwSerial.available() > 0){
			byte inchar = (byte)SwSerial.read();
			if ( (inchar == 0xFF) & ((byte)SwSerial.peek() == 0xFF) ){
					beginsave=1; 
					i=0; 				 // if found new header, begin again
			}
			if (beginsave==1 && i<size) {
				   dataEx[i] = inchar;
				   i++;
			}
		}
		SwSerial.flush();
		break;
	
	#if defined (__AVR_ATmega1280__) || defined (__AVR_ATmega128__) || defined (__AVR_ATmega2560__)
	case HSerial1:
		while((Serial1.available() < size) & (Time_Counter < TIME_OUT)){
        		Time_Counter++;
        		delayMicroseconds(1000);
		}      	
		while (Serial1.available() > 0){
      		byte inchar = (byte)Serial1.read();
			//printHexByte(inchar);
        	if ( (inchar == 0xFF) & ((byte)Serial1.peek() == 0xFF) ){
						beginsave=1;
						i=0; 						
             }
            if (beginsave==1 && i<size) {
                       dataEx[i] = inchar;
                       i++;
			}
		}
		break;
	
	case HSerial2:
	    while((Serial2.available() < size) & (Time_Counter < TIME_OUT)){
        		Time_Counter++;
        		delayMicroseconds(1000);
		}
        	
		while (Serial2.available() > 0){
			byte inchar = (byte)Serial2.read();
			if ( (inchar == 0xFF) & ((byte)Serial2.peek() == 0xFF) ){
					beginsave=1;
					i=0; 					
			}
			if (beginsave==1 && i<size) {
				   dataEx[i] = inchar;
				   i++;
			}
		}
		break;

	case HSerial3:
		while((Serial3.available() < size) & (Time_Counter < TIME_OUT)){
			Time_Counter++;
			delayMicroseconds(1000);
		}
		
		while (Serial3.available() > 0){
			byte inchar = (byte)Serial3.read();
			if ( (inchar == 0xFF) & ((byte)Serial3.peek() == 0xFF) ){
					beginsave=1;
					i=0; 
			}
			if (beginsave==1 && i<size) {
				   dataEx[i] = inchar;
				   i++;
			}
		}
		break;
	#endif
	}
}
开发者ID:NickAlbers,项目名称:RoboCup,代码行数:89,代码来源:Herkulex.cpp


示例19: delayMicroseconds

void MyTM1637::bitDelay(void)
{
	delayMicroseconds(50);
}
开发者ID:lanselambor,项目名称:ToolKit1.0,代码行数:4,代码来源:MyTM1637.cpp


示例20: digitalWrite

boolean DHT::read(void) {
  uint8_t laststate = HIGH;
  uint8_t counter = 0;
  uint8_t j = 0, i;
  unsigned long currenttime;

  // pull the pin high and wait 250 milliseconds
  digitalWrite(_pin, HIGH);
  delay(250);

  currenttime = millis();
  if (currenttime < _lastreadtime) {
    // ie there was a rollover
    _lastreadtime = 0;
  }
  if (!firstreading && ((currenttime - _lastreadtime) < 2000)) {
    return true; // return last correct measurement
    //delay(2000 - (currenttime - _lastreadtime));
  }
  firstreading = false;
  /*
Serial.print("Currtime: "); Serial.print(currenttime);
Serial.print(" Lasttime: "); Serial.print(_lastreadtime);
*/
  _lastreadtime = millis();

  data[0] = data[1] = data[2] = data[3] = data[4] = 0;
  
  // now pull it low for ~20 milliseconds
  pinMode(_pin, OUTPUT);
  digitalWrite(_pin, LOW);
  delay(20);
  cli();
  digitalWrite(_pin, HIGH);
  delayMicroseconds(40);
  pinMode(_pin, INPUT);

  // read in timings
  for ( i=0; i< MAXTIMINGS; i++) {
    counter = 0;
    while (digitalRead(_pin) == laststate) {
      counter++;
      delayMicroseconds(1);
      if (counter == 255) {
        break;
      }
    }
    laststate = digitalRead(_pin);

    if (counter == 255) break;

    // ignore first 3 transitions
    if ((i >= 4) && (i%2 == 0)) {
      // shove each bit into the storage bytes
      data[j/8] <<= 1;
      if (counter > _count)
        data[j/8] |= 1;
      j++;
    }

  }

  sei();
  
  /*
Serial.println(j, DEC);
Serial.print(data[0], HEX); Serial.print(", ");
Serial.print(data[1], HEX); Serial.print(", ");
Serial.print(data[2], HEX); Serial.print(", ");
Serial.print(data[3], HEX); Serial.print(", ");
Serial.print(data[4], HEX); Serial.print(" =? ");
Serial.println(data[0] + data[1] + data[2] + data[3], HEX);
*/

  // check we read 40 bits and that the checksum matches
  if ((j >= 40) &&
      (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) ) {
    return true;
  }
  

  return false;

}
开发者ID:te-bachi,项目名称:humidity,代码行数:84,代码来源:DHT.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ delayMs函数代码示例发布时间:2022-05-30
下一篇:
C++ delay100函数代码示例发布时间: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