void HAL_Core_Enter_Stop_Mode(uint16_t wakeUpPin, uint16_t edgeTriggerMode)
{
    if ((wakeUpPin < TOTAL_PINS) && (edgeTriggerMode <= FALLING))
    {
        PinMode wakeUpPinMode = INPUT;

        /* Set required pinMode based on edgeTriggerMode */
        switch(edgeTriggerMode)
        {
        case CHANGE:
            wakeUpPinMode = INPUT;
            break;

        case RISING:
            wakeUpPinMode = INPUT_PULLDOWN;
            break;

        case FALLING:
            wakeUpPinMode = INPUT_PULLUP;
            break;
        }
        HAL_Pin_Mode(wakeUpPin, wakeUpPinMode);

        /* Configure EXTI Interrupt : wake-up from stop mode using pin interrupt */
        HAL_Interrupts_Attach(wakeUpPin, NULL, NULL, edgeTriggerMode, NULL);

        HAL_Core_Execute_Stop_Mode();

        /* Detach the Interrupt pin */
        HAL_Interrupts_Detach(wakeUpPin);
    }
}
示例#2
0
文件: core_hal.c 项目: spark/firmware
/*******************************************************************************
 * Function Name  : HAL_Core_Config.
 * Description    : Called in startup routine, before calling C++ constructors.
 * Input          : None.
 * Output         : None.
 * Return         : None.
 *******************************************************************************/
void HAL_Core_Config(void)
{
	// this ensures the stm32_it.c functions aren't dropped by the linker, thinking
	// they are unused. Without this none of the interrupts handlers are linked.
	linkme();
	DECLARE_SYS_HEALTH(ENTERED_SparkCoreConfig);
#ifdef DFU_BUILD_ENABLE
	/* Set the Vector Table(VT) base location at 0x5000 */
	NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x5000);

	USE_SYSTEM_FLAGS = 1;
#endif

#ifdef SWD_JTAG_DISABLE
	/* Disable the Serial Wire JTAG Debug Port SWJ-DP */
	GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
#else
#ifdef SWD_ENABLE_JTAG_DISABLE
  /* Disable JTAG, but enable SWJ-DP */
  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
#endif
#endif

	Set_System();

	SysTick_Configuration();

	/* Enable CRC clock */
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);

	HAL_RTC_Configuration();

	/* Execute Stop mode if STOP mode flag is set via System.sleep(pin, mode) */
	HAL_Core_Execute_Stop_Mode();

	LED_SetRGBColor(RGB_COLOR_WHITE);
	LED_On(LED_RGB);

#ifdef IWDG_RESET_ENABLE
	// ToDo this needs rework for new bootloader
	/* Check if the system has resumed from IWDG reset */
	if (RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET)
	{
		/* IWDGRST flag set */
		IWDG_SYSTEM_RESET = 1;

		/* Clear reset flags */
		RCC_ClearFlag();
	}

	/* We are duplicating the IWDG call here for compatibility with old bootloader */
	/* Set IWDG Timeout to 3 secs */
	IWDG_Reset_Enable(3 * TIMING_IWDG_RELOAD);
#endif

#ifdef DFU_BUILD_ENABLE
	Load_SystemFlags();
#endif

	sFLASH_Init();

        module_user_init_hook();
}