當前位置: 首頁>>代碼示例>>C++>>正文


C++ GPIOSetDir函數代碼示例

本文整理匯總了C++中GPIOSetDir函數的典型用法代碼示例。如果您正苦於以下問題:C++ GPIOSetDir函數的具體用法?C++ GPIOSetDir怎麽用?C++ GPIOSetDir使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GPIOSetDir函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: trigInputInit

/**
 * *brief	init trig pin as input, install interrupt handler on event 1
 * IO pins on lpc11xx can be configured for hysteresis ~0.4V, we enable this to avoid
 * multiple interrupts when optocoupler input is fired from a potential noisy and slow input
 * */
void trigInputInit(void)
{
    /* init timers */
    /* avoid triggerning after reset, and allow inputs to settle */
    timeLast1 = 0;
    timeLast2 = 0;
    timeEdge1 = 0;
    timeEdge2 = 0;

    /* allow interrupts on GPIO 1 & 2 */
    NVIC_EnableIRQ(EINT1_IRQn);
    NVIC_EnableIRQ(EINT2_IRQn);

    /* hard coded pins set pullups and hysteresis TODO*/
    LPC_IOCON->PIO2_2  = 0x00000030;
    LPC_IOCON->PIO1_10 = 0x000000B0;


    GPIOSetDir( TRIG_IN_PORT_1, TRIG_IN_PIN_1, 0);
    GPIOSetDir( TRIG_IN_PORT_2, TRIG_IN_PIN_2, 0);

    /* attach pin to falling edge Interrupt */
    GPIOSetInterrupt(TRIG_IN_PORT_1, TRIG_IN_PIN_1, 0, 0, 0);
    GPIOSetInterrupt(TRIG_IN_PORT_2, TRIG_IN_PIN_2, 0, 0, 0);
    /*enable interrupts*/
    GPIOIntEnable( TRIG_IN_PORT_1, TRIG_IN_PIN_1);
    GPIOIntEnable( TRIG_IN_PORT_2, TRIG_IN_PIN_2);
}
開發者ID:opprud,項目名稱:remote_2_0,代碼行數:33,代碼來源:trigInput.c

示例2: rfid_init

void rfid_init(void)
{
	/* reset SSP peripheral */
	LPC_SYSCON->PRESETCTRL = 0x01;

	/* Enable SSP clock */
	LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 11);

	// Enable SSP peripheral
	LPC_IOCON->PIO0_8 = 0x01 | (0x01 << 3); /* MISO, Pulldown */
	LPC_IOCON->PIO0_9 = 0x01; /* MOSI */

	LPC_IOCON->SCKLOC = 0x00; /* route to PIO0_10 */
	LPC_IOCON->JTAG_TCK_PIO0_10 = 0x02; /* SCK */

	/* Set SSP clock to 4.5MHz */
	LPC_SYSCON->SSPCLKDIV = 0x01;
	LPC_SSP->CR0 = 0x0707;
	LPC_SSP->CR1 = 0x0002;
	LPC_SSP->CPSR = 0x02;

	/* Initialize chip select line */
	GPIOSetDir(PN532_CS_PORT, PN532_CS_PIN, 1);
	rfid_cs(1);

	/* Initialize RESET line */
	GPIOSetDir(PN532_RESET_PORT, PN532_RESET_PIN, 1);
	rfid_reset(0);

}
開發者ID:KhMassri,項目名稱:DTNWorkspace,代碼行數:30,代碼來源:rfid.c

示例3: main

int main (void)
{
  uint8_t ledState;

  //Set LED1 pin as an output
  GPIOSetDir( LED1_PORT, LED1_PIN, GPIO_OUTPUT);
  GPIOSetValue( LED1_PORT, LED1_PIN, LED_OFF);

  //Set SW2 pin as an input
  GPIOSetDir( SW2_PORT, SW2_PIN, GPIO_INPUT);

  //enter forever loop
  while (1)
  {
    //delay a specified period of time (the sample period)
    delayMS(75);

    //check if push-button is pressed
    if (GPIOGetValue(SW2_PORT, SW2_PIN) == SW_PRESSED)
    {
      //toggle LED
	    if (ledState == LED_ON)
	      ledState = LED_OFF;
	    else
        ledState = LED_ON;
      GPIOSetValue( LED1_PORT, LED1_PIN, ledState);

      //wait until push-button is released
	    while(GPIOGetValue(SW2_PORT, SW2_PIN) == SW_PRESSED)
		    ;
	  }
  }
  return 0;
}
開發者ID:finklabs,項目名稱:epicsamples,代碼行數:34,代碼來源:main.c

示例4: pn532_bus_HWInit

error_t pn532_bus_HWInit(void)
{
  #ifdef PN532_DEBUGMODE
  PN532_DEBUG("Initialising I2C%s", CFG_PRINTF_NEWLINE);
  #endif
  i2cInit(I2CMASTER);

  // Set reset pin as output and reset device
  GPIOSetDir(CFG_PN532_RSTPD_PORT, CFG_PN532_RSTPD_PIN, 1);
  #ifdef PN532_DEBUGMODE
  PN532_DEBUG("Resetting the PN532%s", CFG_PRINTF_NEWLINE);
  #endif
  LPC_GPIO->CLR[CFG_PN532_RSTPD_PORT] = (1 << CFG_PN532_RSTPD_PIN);
  systickDelay(400);
  LPC_GPIO->SET[CFG_PN532_RSTPD_PORT] = (1 << CFG_PN532_RSTPD_PIN);

  // Wait for the PN532 to finish booting
  systickDelay(100);

  // Ping the I2C device first to see if it exists!
  if (i2cCheckAddress(PN532_I2C_ADDRESS) == false)
  {
    #ifdef PN532_DEBUGMODE
    PN532_DEBUG("Can't find PN532 on the I2C bus%s", CFG_PRINTF_NEWLINE);
    #endif
    return ERROR_I2C_DEVICENOTFOUND;
  }

  // Set IRQ pin to input
  GPIOSetDir(CFG_PN532_I2C_IRQPORT, CFG_PN532_I2C_IRQPIN, 0);

  return ERROR_NONE;
}
開發者ID:kevinxusz,項目名稱:LPC11U_LPC13U_CodeBase,代碼行數:33,代碼來源:pn532_bus_i2c.c

示例5: rfid_init

void rfid_init(void)
{
	/* reset SSP peripheral */
	LPC_SYSCON->PRESETCTRL = 0x01;

	/* Enable SSP clock */
	LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 11);

	// Enable SSP peripheral
	LPC_IOCON->PIO0_8 = 0x01 | (0x01 << 3); /* MISO, Pulldown */
	LPC_IOCON->PIO0_9 = 0x01; /* MOSI */

	LPC_IOCON->SCKLOC = 0x00; /* route to PIO0_10 */
	LPC_IOCON->JTAG_TCK_PIO0_10 = 0x02; /* SCK */

	/* Set SSP clock to 4.5MHz */
	LPC_SYSCON->SSPCLKDIV = 0x01;
	LPC_SSP->CR0 = 0x0707;
	LPC_SSP->CR1 = 0x0002;
	LPC_SSP->CPSR = 0x02;

	/* Initialize chip select line */
	rfid_cs(1);
	GPIOSetDir(PN532_CS_PORT, PN532_CS_PIN, 1);

	/* Initialize RESET line */
	rfid_reset(0);
	GPIOSetDir(PN532_RESET_PORT, PN532_RESET_PIN, 1);

	/* Create PN532 task */
	xTaskCreate(rfid_task, (const signed char*) "RFID", TASK_RFID_STACK_SIZE,
			NULL, TASK_RFID_PRIORITY, NULL);
}
開發者ID:code-constructor,項目名稱:openbeacon,代碼行數:33,代碼來源:rfid.c

示例6: GPIOInit

/*****************************************************************************
** Function name:		GPIOInit
**
** Descriptions:		Initialize GPIO, install the
**						GPIO interrupt handler
**
** parameters:			None
** Returned value:		true or false, return false if the VIC table
**						is full and GPIO interrupt handler can be
**						installed.
** 
*****************************************************************************/
void GPIOInit( void )
{
	//int i;
  /* Enable AHB clock to the GPIO domain. */
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);

	LPC_IOCON->R_PIO0_11  &= ~0x07;
  LPC_IOCON->R_PIO0_11  |= 0x01;

	LPC_IOCON->R_PIO1_0  &= ~0x07;
  LPC_IOCON->R_PIO1_0  |= 0x01;
	
  LPC_IOCON->R_PIO1_1  &= ~0x07;
  LPC_IOCON->R_PIO1_1  |= 0x01;

	LPC_IOCON->R_PIO1_2  &= ~0x07;
  LPC_IOCON->R_PIO1_2  |= 0x01;
	
	LPC_IOCON->PIO0_4 = 0x100;
	LPC_IOCON->PIO0_5 = 0x100;
	
	//NodeId_Adress
	LPC_GPIO[PORT2]->DIR &= ~(0xDC0); //ADDR0-4
	GPIOSetDir(PORT1,10,E_IO_INPUT);		//ADDR5
	GPIOSetDir(PORT1,11,E_IO_INPUT);	//ADDR6
	
	GPIOSetDir(PORT1, 2, E_IO_INPUT);	//EINT

  /* Set up NVIC when I/O pins are configured as external interrupts. */
  //NVIC_EnableIRQ(EINT0_IRQn);
  //NVIC_EnableIRQ(EINT1_IRQn);
  //NVIC_EnableIRQ(EINT2_IRQn);
  //NVIC_EnableIRQ(EINT3_IRQn);
  return;
}
開發者ID:dihic,項目名稱:iShelfTCM,代碼行數:47,代碼來源:gpio.c

示例7: main

int main(void) {
	//GPIOInit();
	SysTick_Config( SystemCoreClock/1000 );
	SysTick->CTRL &= (0 << 1);
	//initDrive();
	ADCInit( ADC_CLK );
	//initReflex();
	//GPIOSetDir( 3, 2, 1 );
	//GPIOSetValue( 3, 2, 0);
	GPIOSetDir( LED_PORT, LED_BIT, 1 );
	GPIOSetValue( LED_PORT, LED_BIT, LED_OFF );
	GPIOSetDir( 3, 2, 1 );
	// Enter an infinite loop, just incrementing a counter
	volatile static int i = 0 ;
	while(1)
	{
		//uint16_t adcValue = ADCRead( 5 );
		if(reflexRead())//adcValue > 100)
		{
			GPIOSetValue( LED_PORT, LED_BIT, LED_ON );
		}
		else
		{
			GPIOSetValue( LED_PORT, LED_BIT, LED_OFF );
		}
		//i++;
	}
	return 0 ;
}
開發者ID:staffy,項目名稱:EDwin,代碼行數:29,代碼來源:main.c

示例8: main

/*****************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{
  SystemInit();

  GPIOInit();

  /* use port0_1 as input event, interrupt test. */
  GPIOSetDir( PORT0, 1, 0 );
  /* port0_1, single trigger, active high. */
  GPIOSetInterrupt( PORT0, 1, 0, 0, 0 );
  GPIOIntEnable( PORT0, 1 );

  /* use port1_1 as input event, interrupt test. */
  GPIOSetDir( PORT1, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT1, 1, 0, 0, 0 );
  GPIOIntEnable( PORT1, 1 );

  /* use port2_1 as input event, interrupt test. */
  GPIOSetDir( PORT2, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT2, 1, 0, 0, 0 );
  GPIOIntEnable( PORT2, 1 );

  /* use port3_1 as input event, interrupt test. */
  GPIOSetDir( PORT3, 1, 0 );
  /* port0_1, single edge trigger, active high. */
  GPIOSetInterrupt( PORT3, 1, 0, 0, 0 );
  GPIOIntEnable( PORT3, 1 );

  while( 1 );
}
開發者ID:m3y54m,項目名稱:32bitmicro,代碼行數:35,代碼來源:gpiotest.c

示例9: flashLight

void flashLight(int timeMS, int OnOrOff)
{
	GPIOSetDir( LED_PORT, LED_BIT, OnOrOff );
	//delay for time
	delaySysTick(timeMS/10);
	GPIOSetDir( LED_PORT, LED_BIT, 0 );
}
開發者ID:jacobhaynes,項目名稱:Digital-Design-Lab,代碼行數:7,代碼來源:main.c

示例10: prvSetupHardware

static void prvSetupHardware( void )
{
extern unsigned long _vStackTop[], _pvHeapStart[];
unsigned long ulInterruptStackSize;

	/* Initialize GPIO (sets up clock) */
	GPIOInit();
	/* Set LED port pin to output */
	GPIOSetDir(LED_PORT, LED_GREEN_BIT, 1);
	GPIOSetDir(LED_PORT, LED_RED_BIT, 1);
	GPIOSetValue(LED_PORT, LED_GREEN_BIT, 0);
	GPIOSetValue(LED_PORT, LED_RED_BIT, 0);

	PumpsInit();
	FlowrateInit();
	PacketInit(230400);

	/* The size of the stack used by main and interrupts is not defined in
	the linker, but just uses whatever RAM is left.  Calculate the amount of
	RAM available for the main/interrupt/system stack, and check it against
	a reasonable number.  If this assert is hit then it is likely you don't
	have enough stack to start the kernel, or to allow interrupts to nest.
	Note - this is separate to the stacks that are used by tasks.  The stacks
	that are used by tasks are automatically checked if
	configCHECK_FOR_STACK_OVERFLOW is not 0 in FreeRTOSConfig.h - but the stack
	used by interrupts is not.  Reducing the conifgTOTAL_HEAP_SIZE setting will
	increase the stack available to main() and interrupts. */
	ulInterruptStackSize = ( ( unsigned long ) _vStackTop ) - ( ( unsigned long ) _pvHeapStart );
	configASSERT( ulInterruptStackSize > 350UL );

	/* Fill the stack used by main() and interrupts to a known value, so its
	use can be manually checked. */
	memcpy( ( void * ) _pvHeapStart, ucExpectedInterruptStackValues, sizeof( ucExpectedInterruptStackValues ) );
}
開發者ID:Cheng-SG,項目名稱:BubbleCode,代碼行數:34,代碼來源:main.c

示例11: main

int main (void)
{
  draw_lcd_t lcd;

  // outputs
  GPIOSetDir(OLED_SSEL_PORT, OLED_SSEL_PIN, GPIO_OUTPUT);
  GPIOSetDir(OLED_DC_PORT, OLED_DC_PIN, GPIO_OUTPUT);
  GPIOSetDir(OLED_RESET_PORT, OLED_RESET_PIN, GPIO_OUTPUT);

  GPIOSetValue(OLED_SSEL_PORT, OLED_SSEL_PIN, 1);
  GPIOSetValue(OLED_DC_PORT, OLED_DC_PIN, 1);
  GPIOSetValue(OLED_RESET_PORT, OLED_RESET_PIN, 1);

  SSP0Init(6000000);

  printf("\nInitializing oled driver...");
  oled_init(&lcd);

  rainbow(&lcd);

  //enter forever loop -
  while (1) {
  }

  return 0;
}
開發者ID:finklabs,項目名稱:epicsamples,代碼行數:26,代碼來源:main.c

示例12: power_mgr_init

void power_mgr_init() {
   GPIOSetDir( POWER_MGR_PORT, POWER_MGR_PIN_PLAYER, 1);
   GPIOSetDir( POWER_MGR_PORT, POWER_MGR_PIN_AMP, 1);

   // set default value (0 means active due relay module)
   GPIOSetValue( POWER_MGR_PORT, POWER_MGR_PIN_PLAYER, 0);
   GPIOSetValue( POWER_MGR_PORT, POWER_MGR_PIN_AMP, 0);
}
開發者ID:hdo,項目名稱:lpcx1343_cmsis2_jukebox4kids_ui,代碼行數:8,代碼來源:power_mgr.c

示例13: temp_init

/******************************************************************************
 *
 * Description:
 *    Initialize Temp Sensor driver
 *
 * Params:
 *   [in] getMsTicks - callback function for retrieving number of elapsed ticks
 *                     in milliseconds
 *
 *****************************************************************************/
void temp_init (uint32_t (*getMsTicks)(void))
{
#ifdef TEMP_USE_P0_2
    GPIOSetDir( PORT0, 2, 0 );
#else
    GPIOSetDir( PORT1, 5, 0 );
#endif
    getTicks = getMsTicks;
}
開發者ID:ecomptiago,項目名稱:EmbarcadosLab2,代碼行數:19,代碼來源:temp.c

示例14: rgb_init

/******************************************************************************
 *
 * Description:
 *    Initialize RGB driver
 *
 *****************************************************************************/
void rgb_init (void)
{
    GPIOSetDir( PORT1, 9, 1 );
    GPIOSetDir( PORT1, 2, 1 );
    GPIOSetDir( PORT1, 10, 1 );

    LPC_IOCON->PIO1_10 = LPC_IOCON->PIO1_10 & ~0x7;
    LPC_IOCON->PIO1_9 = LPC_IOCON->PIO1_9 & ~0x7;
    //DR:
    LPC_IOCON->R_PIO1_2 = (LPC_IOCON->R_PIO1_2 & ~0x7) | 0x1;
}
開發者ID:ecomptiago,項目名稱:EmbarcadosLab2,代碼行數:17,代碼來源:rgb.c

示例15: touchInit

void touchInit(){
  SSP0_IOConfig(); 
  GPIOSetDir(ADS7843_CS_GPIO,ADS7843_CS_GPIOBIT,1);  //out
  GPIOSetDir(ADS7843_INT_GPIO,ADS7843_INT_GPIOBIT,0); //in put
  GPIOSetInterrupt(ADS7843_INT_GPIO,ADS7843_INT_GPIOBIT, 0, 0, 0); //signal fall edge 
  //GPIOIntEnable(ADS7843_INT_GPIO, ADS7843_INT_GPIOBIT);
  GPIOSetValue(ADS7843_CS_GPIO,ADS7843_CS_GPIOBIT,1); //output hight
  SSP0_Init();   //spi_clk is 1mhz
  touchTimerInit();
  
}
開發者ID:httpftpli,項目名稱:keyboard,代碼行數:11,代碼來源:touch.c


注:本文中的GPIOSetDir函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。