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


C++ __WFI函数代码示例

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


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

示例1: HAL_PWR_EnterSLEEPMode

/**
  * @brief Enters Sleep mode.
  *   
  * @note In Sleep mode, all I/O pins keep the same state as in Run mode.
  * 
  * @note In Sleep mode, the systick is stopped to avoid exit from this mode with
  *       systick interrupt when used as time base for Timeout 
  *                
  * @param Regulator: Specifies the regulator state in SLEEP mode.
  *            This parameter can be one of the following values:
  *            @arg PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON
  *            @arg PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON
  * @note This parameter is not used for the STM32F4 family and is kept as parameter
  *       just to maintain compatibility with the lower power families.
  * @param SLEEPEntry: Specifies if SLEEP mode in entered with WFI or WFE instruction.
  *          This parameter can be one of the following values:
  *            @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
  *            @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
  * @retval None
  */
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
{
  /* Check the parameters */
  assert_param(IS_PWR_REGULATOR(Regulator));
  assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
  
  /* Disable SysTick Timer */
  SysTick->CTRL  &= 0xFE;
  
  /* Select SLEEP mode entry -------------------------------------------------*/
  if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
  {   
    /* Request Wait For Interrupt */
    __WFI();
  }
  else
  {
    /* Request Wait For Event */
    __WFE();
  }

  /* Enable SysTick Timer */
  SysTick->CTRL  |= 0x01;
}
开发者ID:GDXN,项目名称:PSDR,代码行数:44,代码来源:stm32f4xx_hal_pwr.c

示例2: HAL_PWR_EnterSLEEPMode

/**
  * @brief Enters Sleep mode.
  *   
  * @note In Sleep mode, all I/O pins keep the same state as in Run mode.
  * 
  * @note In Sleep mode, the systick is stopped to avoid exit from this mode with
  *       systick interrupt when used as time base for Timeout 
  *                
  * @param Regulator: Specifies the regulator state in SLEEP mode.
  *            This parameter can be one of the following values:
  *            @arg PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON
  *            @arg PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON
  * @note This parameter is not used for the STM32F4 family and is kept as parameter
  *       just to maintain compatibility with the lower power families.
  * @param SLEEPEntry: Specifies if SLEEP mode in entered with WFI or WFE instruction.
  *          This parameter can be one of the following values:
  *            @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
  *            @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
  * @retval None
  */
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
{
  (void)Regulator;
  /* Check the parameters */
  assert_param(IS_PWR_REGULATOR(Regulator));
  assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));

  /* Clear SLEEPDEEP bit of Cortex System Control Register */
  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));

  /* Select SLEEP mode entry -------------------------------------------------*/
  if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
  {   
    /* Request Wait For Interrupt */
    __WFI();
  }
  else
  {
    /* Request Wait For Event */
    __SEV();
    __WFE();
    __WFE();
  }
}
开发者ID:KurlesHS,项目名称:stm32f429i-disco-speccy-emul,代码行数:44,代码来源:stm32f4xx_hal_pwr.c

示例3: main

/**@brief Function for application main entry. Does not return.
 */
int main(void)
{
    utils_setup();
    softdevice_setup();
    ant_channel_rx_broadcast_setup();

    // Main loop.
    for (;;)
    {
#ifdef CPU_LOAD_TRACE
        // Disabling interrupts in this way is highly not recommended. It has an impact on the work
        // of the SoftDevice and is used only to show CPU load.
        __disable_irq();
        LEDS_OFF(BSP_LED_0_MASK);
        __WFI();
        LEDS_ON(BSP_LED_0_MASK);
        __enable_irq();
#else
        // Put CPU in sleep if possible. 
        uint32_t err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
#endif // CPU_LOAD_TRACE
    }
}
开发者ID:kevin-ledinh,项目名称:banana-tree,代码行数:26,代码来源:main.c

示例4: main

int main(void) {
	uint32_t nextBlink;
	uint32_t blinkState = 0;

	init();

	nextBlink = tickMs + BLINK_DELAY_MS;
	for(;;) {

		if(tickMs > nextBlink) {
			nextBlink = tickMs + BLINK_DELAY_MS;
			if(blinkState) {
				GPIO_SetBits(GPIOA, GPIO_Pin_15);
			} else {
				GPIO_ResetBits(GPIOA, GPIO_Pin_15);
			}
			blinkState ^= 1;
		}

		__WFI();
	}

	return 0;
}
开发者ID:alvarop,项目名称:stm32f0xx-gcc-barebones,代码行数:24,代码来源:main.c

示例5: main

/**
 * @brief	Funcion principal.
 * Se encarga de las inicializaciones y queda esperando a la interrupcion.
 * @return	0
 */
int main(void)
{
	//Cuando incializa tenemos que tomar el valor incial de Reload_Ticks

	/* Generic Initialization */
	SystemCoreClockUpdate();

	/* Board_Init calls Chip_GPIO_Init and enables GPIO clock if needed,
	   Chip_GPIO_Init is not called again */
	Board_Init();
	Board_LED_Set(0, false);

	GPIO_Config();
	Setup_SysTick();

	Incializacion_Reload_Ticks();

	/* Wait for interrupts - LED will toggle on each wakeup event */
	while (1) {
		__WFI();
	}

	return 0;
}
开发者ID:frand08,项目名称:TP4-TDII,代码行数:29,代码来源:main.c

示例6: PWRCU_DeepSleep2

/*********************************************************************************************************//**
 * @brief Enters DEEP-SLEEP Mode 2.
 * @param SleepEntry : Enters sleep mode instruction that is used to WFI or WFE.
 *   This parameter can be one of the following values:
 *   @arg PWRCU_SLEEP_ENTRY_WFE: Enters SLEEP mode via WFE instruction.
 *   @arg PWRCU_SLEEP_ENTRY_WFI: Enters SLEEP mode via WFI instruction.
 * @retval None
 ************************************************************************************************************/
void PWRCU_DeepSleep2(PWRCU_SLEEP_ENTRY_Enum SleepEntry)
{
  u32 uRTCStatus = 0;
  u32 uADCStatus = 0;
  Assert_Param(IS_PWRCU_SLEEP_ENTRY(SleepEntry));

  uRTCStatus = BB_RTCEN;
  uADCStatus = BB_ADCEN;

  BB_RTCEN = 1;
  BB_ADCEN = 0;

  if (BB_DMOSSTS == 0)
  {
    BB_DMOSON = 0x0;
    BB_DMOSON = 0x1;
  }
  BB_LDOOFF = 0x0;

  BB_RTCEN = uRTCStatus;

  /* Sets SLEEPDEEP bit of Cortex System Control Register                                                   */
  SCB->SCR |= SLEEPDEEP_SET;

  if (SleepEntry == PWRCU_SLEEP_ENTRY_WFE)
  {
    /* Wait for event                                                                                       */
    __WFE();
  }
  else
  {
    /* Wait for interrupt                                                                                   */
    __WFI();
  }
  BB_ADCEN = uADCStatus;
}
开发者ID:SubaiDeng,项目名称:EmbeddedDevelopment,代码行数:44,代码来源:ht32f1655_56_pwrcu.c

示例7: HAL_PWR_EnterSLEEPMode

/**
  * @brief Enters Sleep mode.
  * @note In Sleep mode, all I/O pins keep the same state as in Run mode.
  * @param Regulator: Specifies the regulator state in SLEEP mode.
  *          This parameter can be one of the following values:
  *            @arg PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON
  *            @arg PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON
  * @param SLEEPEntry: Specifies if SLEEP mode is entered with WFI or WFE instruction.
  *           When WFI entry is used, tick interrupt have to be disabled if not desired as 
  *           the interrupt wake up source.
  *           This parameter can be one of the following values:
  *            @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
  *            @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
  * @retval None
  */
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
{
   uint32_t tmpreg = 0U;
  /* Check the parameters */
  assert_param(IS_PWR_REGULATOR(Regulator));
  assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));

  /* Select the regulator state in Sleep mode ---------------------------------*/
  tmpreg = PWR->CR;

  /* Clear PDDS and LPDS bits */
  CLEAR_BIT(tmpreg, (PWR_CR_PDDS | PWR_CR_LPSDSR));

 /* Set LPSDSR bit according to PWR_Regulator value */
  SET_BIT(tmpreg, Regulator);

  /* Store the new value */
  PWR->CR = tmpreg;
  
  /* Clear SLEEPDEEP bit of Cortex System Control Register */
  CLEAR_BIT(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk);

  /* Select SLEEP mode entry -------------------------------------------------*/
  if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
  {
    /* Request Wait For Interrupt */
    __WFI();
  }
  else
  {
    /* Request Wait For Event */
    __SEV();
    __WFE();
    __WFE();
  }
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:51,代码来源:stm32l0xx_hal_pwr.c

示例8: PWR_EnterSTOPMode

/**
  * @brief  Enters STOP mode.
  * @note   In Stop mode, all I/O pins keep the same state as in Run mode.
  * @note   When exiting Stop mode by issuing an interrupt or a wakeup event, 
  *         the HSI RC oscillator is selected as system clock.
  * @note   When the voltage regulator operates in low power mode, an additional 
  *         startup delay is incurred when waking up from Stop mode. 
  *         By keeping the internal regulator ON during Stop mode, the consumption 
  *         is higher although the startup time is reduced.
  * @param  PWR_Regulator: specifies the regulator state in STOP mode.
  *         This parameter can be one of the following values:
  *             @arg PWR_Regulator_ON: STOP mode with regulator ON
  *             @arg PWR_Regulator_LowPower: STOP mode with regulator in low power mode
  * @param  PWR_STOPEntry: specifies if STOP mode in entered with WFI or WFE instruction.
  *         This parameter can be one of the following values:
  *             @arg PWR_STOPEntry_WFI: enter STOP mode with WFI instruction
  *             @arg PWR_STOPEntry_WFE: enter STOP mode with WFE instruction
  * @retval None
  */
void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry)
{
  uint32_t tmpreg = 0;
  
  /* Check the parameters */
  assert_param(IS_PWR_REGULATOR(PWR_Regulator));
  assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry));
  
  /* Select the regulator state in STOP mode ---------------------------------*/
  tmpreg = PWR->CR;
  /* Clear PDDS and LPDSR bits */
  tmpreg &= CR_DS_MASK;
  
  /* Set LPDSR bit according to PWR_Regulator value */
  tmpreg |= PWR_Regulator;
  
  /* Store the new value */
  PWR->CR = tmpreg;
  
  /* Set SLEEPDEEP bit of Cortex System Control Register */
  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
  
  /* Select STOP mode entry --------------------------------------------------*/
  if(PWR_STOPEntry == PWR_STOPEntry_WFI)
  {   
    /* Request Wait For Interrupt */
    __WFI();
  }
  else
  {
    /* Request Wait For Event */
    __WFE();
  }
  /* Reset SLEEPDEEP bit of Cortex System Control Register */
  SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);  
}
开发者ID:8bitgeek,项目名称:caribou-rtos,代码行数:55,代码来源:stm32f30x_pwr.c

示例9: HAL_Delay

void HAL_Delay(uint32_t Delay) {
	/* Delay for amount of milliseconds */
	/* Check if we are called from ISR */
	if (__get_IPSR() == 0) {
		/* Called from thread mode */
		uint32_t tickstart = HAL_GetTick();
		
		/* Count interrupts */
		while ((HAL_GetTick() - tickstart) < Delay) {
#ifdef DELAY_SLEEP
			/* Go sleep, wait systick interrupt */
			__WFI();
#endif
		}
	} else {
		/* Called from interrupt mode */
		while (Delay) {
			/* Check if timer reached zero after we last checked COUNTFLAG bit */
			if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) {
				Delay--;
			}
		}
	}
}
开发者ID:AidanHockey5,项目名称:STM32_Nucleo_VGM_Test_SN76489,代码行数:24,代码来源:tm_stm32_delay.c

示例10: blocking_resolve

socket_error_t blocking_resolve(const socket_stack_t stack, const socket_address_family_t af, const char* server, struct socket_addr * addr) {
    struct socket s;
    const struct socket_api *api = socket_get_api(stack);
    (void) af;
    blocking_resolve_socket = &s;
    s.stack = stack;
    s.handler = blocking_resolve_cb;
    s.api = api;
    blocking_resolve_done = false;
    socket_error_t err = api->resolve(&s, server);
    if(!TEST_EQ(err, SOCKET_ERROR_NONE)) {
        return err;
    }
    while (!blocking_resolve_done) {
        __WFI();
    }
    if(!TEST_EQ(blocking_resolve_err, SOCKET_ERROR_NONE)) {
        return blocking_resolve_err;
    }
    int rc = strcmp(server, (char *)blocking_resolve_domain);
    TEST_EQ(rc,0);
    memcpy(addr, (const void*)&blocking_resolve_addr, sizeof(struct socket_addr));
    return SOCKET_ERROR_NONE;
}
开发者ID:carmelomigliore,项目名称:sal,代码行数:24,代码来源:socket_abstract_test.cpp

示例11: ProcessPowerState

/* Handle interrupt from GPIO pin or GPIO pin mapped to PININT */
static void ProcessPowerState(CHIP_PMU_MCUPOWER_T crntPowerSetting)
{
	volatile uint32_t tempTimeout;

	/* Output power status message, add separating space */
	DEBUGSTR("\r\n");

	/* Switch on current selected power setting */
	switch (crntPowerSetting) {
	case PMU_MCU_SLEEP:
	default:
		DEBUGSTR("-----------------------------------------------------------------\r\n");
		DEBUGSTR("     Entering SLEEP power setting\r\n");
		DEBUGOUT("       (System will exit SLEEP in %d seconds)\r\n", POWER_CYCLE_SEC_DELAY);
		DEBUGSTR("-----------------------------------------------------------------\r\n\r\n");

		/* Wait for all serial characters to be output */
		DelayForSerialOutput();

		/* Enter MCU Sleep mode */
		LPC_PWRD_API->power_mode_configure(PMU_SLEEP, (PMU_PD_WDOSC | PMU_PD_BOD | PMU_PD_ACMP0 | PMU_PD_ACMP1 | PMU_PD_ACMP2 |PMU_PD_ACMP3 | PMU_PD_IREF | PMU_PD_TS));
		__WFI();

		break;

	case PMU_MCU_DEEP_SLEEP:
		DEBUGSTR("-----------------------------------------------------------------\r\n");
		DEBUGSTR("     Entering DEEP SLEEP power setting\r\n");
		DEBUGOUT("       (System will exit DEEP SLEEP in %d seconds)\r\n", POWER_CYCLE_SEC_DELAY);
		DEBUGSTR("-----------------------------------------------------------------\r\n\r\n");

		/* Wait for all serial characters to be output */
		DelayForSerialOutput();

		/* We should call Chip_SYSCTL_SetWakeup() to setup any peripherals we want
		   to power back up on wakeup. For this example, we'll power back up the IRC,
		   FLASH, the system oscillator, and the PLL */
		Chip_SYSCTL_SetWakeup(~(SYSCTL_SLPWAKE_IRCOUT_PD | SYSCTL_SLPWAKE_IRC_PD |
								SYSCTL_SLPWAKE_FLASH_PD | SYSCTL_SLPWAKE_SYSOSC_PD | SYSCTL_SLPWAKE_SYSPLL_PD));
		Chip_SYSCTL_EnableERP1PeriphWakeup(SYSCTL_ERP1_WAKEUP_RTCALARMINT);

		/* Enter MCU Deep Sleep mode */
		LPC_PWRD_API->power_mode_configure(PMU_DEEP_SLEEP, (PMU_PD_WDOSC | PMU_PD_BOD | PMU_PD_ACMP0 | PMU_PD_ACMP1 | PMU_PD_ACMP2 |PMU_PD_ACMP3 | PMU_PD_IREF | PMU_PD_TS));
		__WFI();

		break;

	case PMU_MCU_POWER_DOWN:
		DEBUGSTR("-----------------------------------------------------------------\r\n");
		DEBUGSTR("     Entering POWER DOWN power setting\r\n");
		DEBUGOUT("       (System will exit POWER DOWN in %d seconds)\r\n", POWER_CYCLE_SEC_DELAY);
		DEBUGSTR("-----------------------------------------------------------------\r\n\r\n");

		/* Wait for all serial characters to be output */
		DelayForSerialOutput();

		/* We should call Chip_SYSCTL_SetWakeup() to setup any peripherals we want
		   to power back up on wakeup. For this example, we'll power back up the IRC,
		   FLASH, the system oscillator, and the PLL */
		Chip_SYSCTL_SetWakeup(~(SYSCTL_SLPWAKE_IRCOUT_PD | SYSCTL_SLPWAKE_IRC_PD |
								SYSCTL_SLPWAKE_FLASH_PD | SYSCTL_SLPWAKE_SYSOSC_PD | SYSCTL_SLPWAKE_SYSPLL_PD));
		Chip_SYSCTL_EnableERP1PeriphWakeup(SYSCTL_ERP1_WAKEUP_RTCALARMINT);

		/* Enter MCU Power down mode */
		LPC_PWRD_API->power_mode_configure(PMU_POWERDOWN, (PMU_PD_WDOSC | PMU_PD_BOD | PMU_PD_ACMP0 | PMU_PD_ACMP1 | PMU_PD_ACMP2 |PMU_PD_ACMP3 | PMU_PD_IREF | PMU_PD_TS));
		__WFI();

		break;

	case PMU_MCU_DEEP_PWRDOWN:
		DEBUGSTR("-----------------------------------------------------------------\r\n");
		DEBUGSTR("     Entering DEEP POWER DOWN power setting\r\n");
		DEBUGOUT("       (System will exit DEEP POWER DOWN in %d seconds)\r\n", POWER_CYCLE_SEC_DELAY);
		DEBUGSTR("-----------------------------------------------------------------\r\n\r\n");

		/* Wait for all serial characters to be output */
		DelayForSerialOutput();
		/* Enable wakeup from deep power down mode due to RTC Alarm Match */
		Chip_RTC_EnableWakeup(LPC_RTC, RTC_CTRL_ALARMDPD_EN);
		/* Enter MCU Deep Power down mode */
		LPC_PWRD_API->power_mode_configure(PMU_DEEP_POWERDOWN, (PMU_PD_WDOSC | PMU_PD_BOD | PMU_PD_ACMP0 | PMU_PD_ACMP1 | PMU_PD_ACMP2 |PMU_PD_ACMP3 | PMU_PD_IREF | PMU_PD_TS));
		__WFI();

		break;
	}
}
开发者ID:0xBADCA7,项目名称:lk,代码行数:87,代码来源:pmu_rom.c

示例12: main

/**
 * @brief	main routine for blinky example
 * @return	Function should not exit.
 */
int main(void)
{
	int i;

	/* Generic Initialization */
	SystemCoreClockUpdate();
	Board_Init();
	Board_LED_Set(0, false);

	/* Enable SysTick Timer */
	SysTick_Config(SystemCoreClock / TICKRATE_HZ);
	
	/* Initialize the array data to be written to FLASH */
	for (i = 0; i < WRITECOUNT; i++) {
		array_data[i] = 0x11223340 + i;
	}
	
	/* Read Part Identification Number*/
	command[0] = IAP_REPID_CMD;								/* Read ID command code */
	iap_entry(command, result);

	/* Reinvoke ISP mode so that reprogamming of Flash possible */
	__disable_irq();

	command[0] = IAP_REPID_CMD;
	iap_entry(command, result);

	/* Prepare to write/erase the last sector */
	command[0] = IAP_PREWRRITE_CMD;						/* Prepare to write/erase command code */
	command[1] = IAP_LAST_SECTOR;							/* Start Sector Number */
	command[2] = IAP_LAST_SECTOR;							/* End Sector Number */
	iap_entry(command, result);

	/* Erase the last sector */
	command[0] = IAP_ERSSECTOR_CMD;						/* Erase command code*/
	command[1] = IAP_LAST_SECTOR;							/* Start Sector Number */
	command[2] = IAP_LAST_SECTOR;							/* Start Sector Number */
	iap_entry(command, result);

	/* Prepare to write/erase the last sector */
	command[0] = IAP_PREWRRITE_CMD;						/* Prepare to write/erase command code */
	command[1] = IAP_LAST_SECTOR;							/* Start Sector Number */
	command[2] = IAP_LAST_SECTOR;							/* Start Sector Number */
	iap_entry(command, result);

	/* Write to the last sector */
	command[0] = IAP_WRISECTOR_CMD;								/* Write command code */
	command[1] = (uint32_t) last_sector_flash;		/* Destination Flash Address */
	command[2] = (uint32_t) &array_data;					/* Source RAM Address */
	command[3] = IAP_NUM_BYTES_TO_WRITE;					/* Number of Bytes to be written */
	command[4] = SystemCoreClock / 1000;					/* System clock frequency */
	iap_entry(command, result);

	/* Re-enable interrupt mode */
	__enable_irq();

	while (1) {
		__WFI();
	}

	return 0;
}
开发者ID:0xBADCA7,项目名称:lk,代码行数:66,代码来源:iap.c

示例13: main

/**
 * @brief	Main routine for SPI example
 * @return	Does not return
 */
int main(void)
{
	uint16_t seed = 0;

	SystemCoreClockUpdate();
	Board_Init();

	/* SPI initialization */
	Init_SPI_PinMux();

	/* Initialize stopwatch driver so some event times can be measured */
	StopWatch_Init();

	/* Setup SPI controllers */
	setupMaster();
	setupSlave();

	/* Enable SPI controller interrupts */
	NVIC_EnableIRQ(LPC_SPIMASTERIRQNUM);
	NVIC_EnableIRQ(LPC_SPISLAVEIRQNUM);

	DEBUGSTR("SPI master/slave combined example\r\n");

	/* If you enable loopback mode and connect the master and slave controller's clock
	   and SSEL lines together, the master and slave will wrap data to each other */
	// Chip_SPIM_EnableLoopBack(LPC_SPIMASTERPORT);

	/* Loop forever */
	while (1) {
		/* Setup some data for transmit from master to slave and slave to master */
		seed = bufferInit(seed);

		/* Set slave transfer, this is only the initial transfer,
		   the callbacks can change this later */
		spiSlaveXfer.pTXData16 = slaveTXBuffer16;
		spiSlaveXfer.txCount = sizeof(slaveTXBuffer16) / sizeof(uint16_t);	/* Count is in transfer size */
		spiSlaveXfer.pRXData16 = slaveRXBuffer16;
		spiSlaveXfer.rxCount = sizeof(slaveRXBuffer16) / sizeof(uint16_t);	/* Count is in transfer size */

		/* Set master transfer, this is only the initial transfer,
		   the callbacks can change this later */
		spiMasterXfer.pTXData16 = masterTXBuffer16;	/* Use NULL to send 0x0 */
		spiMasterXfer.txCount = sizeof(masterTXBuffer16) / sizeof(uint16_t);/* Count is in transfer size */
		spiMasterXfer.pRXData16 = masterRXBuffer16;
		spiMasterXfer.rxCount = sizeof(masterRXBuffer16) / sizeof(uint16_t);/* Count is in transfer size */

		/* Setup master transfer options - 16 data bits per transfer, EOT, EOF */
		spiMasterXfer.options =
			SPI_TXCTL_FLEN(16) |		/* This must be enabled as a minimum, use 16 data bits */
			// SPI_TXCTL_EOT |			/* Enable this to assert and deassert SSEL for each individual byte/word, current slave functions for this example do not support this */
			// SPI_TXCTL_EOF |			/* Insert a delay between bytes/words as defined by frame delay time */
			// SPI_TXCTL_RXIGNORE |		/* Enable this to ignore incoming data, or set spiMasterXfer.pRXData16 to NULL to ignore RX data  */
			0;

		/* Transfer will terminate after current buffer is sent. If terminate is not set, the buffers
		   must be setup by the callbacks		*/
		spiMasterXfer.terminate = true;

		/* Use SPI select 0 */
		spiMasterXfer.sselNum = 0;

		/* Time master and slave transfers */
		masterTime = StopWatch_Start();

		/* Limitation: The call below 'pre-buffers' the initial slave transmit datum.
		   If this isn't pre-buffered, a slave transmit underflow will always occur
		   at slave assertion time for the initial transmit datum. The datum sent to the
		   master will be 0. This is ok as we are only using a single slave, but with multiple
		   slaves pre-buffering is not always an option and the master might need to toss the
		   first byte. */
		Chip_SPI_FlushFifos(LPC_SPIMASTERPORT);
		Chip_SPI_FlushFifos(LPC_SPISLAVEPORT);
		Chip_SPIS_PreBuffSlave(LPC_SPISLAVEPORT, &spiSlaveXfer);

		/* Start master transfer */
		Chip_SPIM_Xfer(LPC_SPIMASTERPORT, &spiMasterXfer);

		/* Sleep until transfers are complete */
		mEnd = sEnd = false;
		while ((mEnd == false) || (sEnd == false)) {
			__WFI();
		}

		/* Toggle LED */
		Board_LED_Toggle(0);

		/* Display some information about the transfer */
		Print_Val("\r\nTRANSFER COMPLETE: errors = 0x", errors);
		errors = 0;
		Print_Val("Master total transfer time in uS: 0x", StopWatch_TicksToUs(StopWatch_Elapsed(masterTime)));

		/* Show data */
		showData("Master TX data", masterTXBuffer16);
		showData("Master RX data", masterRXBuffer16);
		showData("Slave  TX data", slaveTXBuffer16);
		showData("Slave  RX data", slaveRXBuffer16);
//.........这里部分代码省略.........
开发者ID:Magicoe,项目名称:LPC820,代码行数:101,代码来源:main_spi_sm_int.c

示例14: main

/**
  * @brief   Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Configure the system clocks */
  RCC_Configuration();

  /* Initialize Leds and Key Button mounted on STM3210X-EVAL board */       
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  STM_EVAL_PBInit(Button_KEY, Mode_EXTI); 
 
  /* Configures the DMA Channel */
  DMA_Configuration();
  
/* EVAL_COM1 configuration ---------------------------------------------------*/
  /* EVAL_COM1 configured as follow:
        - BaudRate = 115200 baud  
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Hardware flow control disabled (RTS and CTS signals)
        - Receive and transmit enabled
  */
  USART_InitStructure.USART_BaudRate = 115200;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  STM_EVAL_COMInit(COM1, &USART_InitStructure);
  USART_DMACmd(EVAL_COM1, USART_DMAReq_Rx, ENABLE);
  
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
  
  /* Enable the USARTy_DMA1_IRQn Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = USARTy_DMA1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* Enable the EXTI9_5  Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_Init(&NVIC_InitStructure);
    
  while (1)
  {
    if(LowPowerMode == 1)
    {

      STM_EVAL_LEDOff(LED2);
      STM_EVAL_LEDOff(LED3);

      /* Request to enter WFI mode */
      __WFI();
      LowPowerMode = 0;
    }

    Delay(0xFFFFF);
    STM_EVAL_LEDToggle(LED1);
  }
}
开发者ID:jwithee,项目名称:bearboard,代码行数:70,代码来源:main.c

示例15: setMcuToSleep

void setMcuToSleep(SLEEPMODE mode)
{
    if(SLEEP_DEFAULT==mode)
    {
        // Sleep mode:
        // PCON.DPDEN bit 1 = 0
        // SCR.SLEEDEEP bit 2 = 0
        // WFI
        // Sleep mode exit: any IRQ enabled
        
        CLRBIT(LPC_PMU->PCON,1); //PCON.DPDEN bit 1 = 0
        SETBIT(LPC_PMU->PCON,11); //Clear the Deep power-down flag
        CLRBIT(SCB->SCR,2);
        __WFI();
    }
    else if(SLEEP_DEEP==mode)
    {
        // Deep-sleep mode:
        // PCON.DPDEN bit 1 = 0
        // set MAINCLKSEL to IRC
        // set PDAWAKECFG for wakeup

        // external pins used: see start logic register and enable start logic IRQ
        // pin: PIO0_0 to PIO0_11, PIO1_0 to PIO1_11 and PIO2_0 to PIO2_7
        // Enable register pin : STARTERP0
        // 

        // disable all peripherals SYSAHBCLKCTRL
        // SCR.SLEEPDEEP bit 2 = 1
        // WFI

        // Deep-sleep mode exit: GPIO IRQ, RTC alarm, Watchdog timeout, USB
        
        // Use internal clock for the main clock
        LPC_SYSCON->MAINCLKSEL    = 0;

        // Update main clock selection
        LPC_SYSCON->MAINCLKUEN    = 1;
        LPC_SYSCON->MAINCLKUEN    = 0;
        LPC_SYSCON->MAINCLKUEN    = 1;

        // Wait main clock
        while ( !(LPC_SYSCON->MAINCLKUEN & BIT(0)) );

        
        // Clear deep sleep flag
//        SETBIT(LPC_PMU->PCON,8);
        
        // Clear the deep power down flag
        SETBIT(LPC_PMU->PCON,11);
        CLRBIT(LPC_PMU->PCON,1);
        
        // Turn off Watchdog and brown out detector (decrease consumption)
        LPC_SYSCON->PDSLEEPCFG |= 0x00000FFF;
        
        // Select the peripheral to be powered when wakeup
        LPC_SYSCON->PDAWAKECFG = LPC_SYSCON->PDRUNCFG;
        
        // Initialize the wakeup source
        initWakeUp();
        
        // Set Deep Sleep mode
        SETBIT(SCB->SCR,2);
        
        __WFI();
    }
    else if(SLEEP_DEEP_POWERDOWN==mode)
    {
        // We can wakeup only on the Wakeup pin AD5 
        
        // bref j'ai pas vu de difference de consommation 
        // entre le slee deep et le sleep deep powerdown
        
        // todo trouver le machin qui consomme ?
        
        SETBIT(LPC_PMU->PCON,1);
      
        //setIOInLowPowerMode();
        
       // set IRCOUT_PD & IRC_PD bits to 0 (PDRUNCFG Register)  
       // Set bits in PDRUNCFG to power down all perihphics except Flash and BOD powered  
       LPC_SYSCON->PDRUNCFG=0xEDFC; 
       LPC_SYSCON->SYSAHBCLKCTRL = 0;
       
       CLRBIT(LPC_SYSCON->SYSAHBCLKCTRL,5);
       CLRBIT(LPC_SYSCON->SYSAHBCLKCTRL,6);
       CLRBIT(LPC_SYSCON->SYSAHBCLKCTRL,7);
       CLRBIT(LPC_SYSCON->SYSAHBCLKCTRL,11);
       CLRBIT(LPC_SYSCON->SYSAHBCLKCTRL,13);
       CLRBIT(LPC_SYSCON->SYSAHBCLKCTRL,14);
    
       //Write 1 to SLEEPDEEP bit SCR Register
        SETBIT(SCB->SCR,2);
        
        __WFI();
    }
    
    
}
开发者ID:batitous,项目名称:dvos,代码行数:99,代码来源:sleep-lpc13xx.c


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