示例#1
0
static void BUTTON_Interrupt_Handler(void *data) {
    Button_TypeDef button = (Button_TypeDef)data;

    HAL_Buttons[button].debounce_time = 0x00;
    HAL_Buttons[button].active = true;

    BUTTON_EXTI_Config(button, DISABLE);

    button_timer_start();
}
示例#2
0
void BUTTON_Check_State(uint16_t button, uint8_t pressed) {
    if (BUTTON_GetState(button) == pressed) {
        if (!HAL_Buttons[button].active) {
            HAL_Buttons[button].active = true;
        }
        HAL_Buttons[button].debounce_time += BUTTON_DEBOUNCE_INTERVAL;
    } else if (HAL_Buttons[button].active) {
        HAL_Buttons[button].active = false;
        /* Enable button Interrupt */
        BUTTON_EXTI_Config(button, ENABLE);
    }
}
/**
 * Force the button in the unpressed state.
 */
void HAL_Core_Mode_Button_Reset(void)
{
    /* Disable TIM2 CC1 Interrupt */
    TIM_ITConfig(TIM2, TIM_IT_CC1, DISABLE);

    BUTTON_DEBOUNCED_TIME[BUTTON1] = 0x00;

    HAL_Notify_Button_State(BUTTON1, false);

    /* Enable BUTTON1 Interrupt */
    BUTTON_EXTI_Config(BUTTON1, ENABLE);

}
示例#4
0
static void button_reset(uint16_t button) {
    HAL_Buttons[button].debounce_time = 0x00;

    if (!HAL_Buttons[BUTTON1].active && !HAL_Buttons[BUTTON1_MIRROR].active) {
        button_timer_stop();
    }

#if MODULE_FUNCTION != MOD_FUNC_BOOTLOADER
    HAL_Notify_Button_State((Button_TypeDef)button, false); 
#endif

    /* Enable Button Interrupt */
    BUTTON_EXTI_Config((Button_TypeDef)button, ENABLE);
}
示例#5
0
文件: core_hal.c 项目: spark/firmware
void HAL_Core_Mode_Button_Reset(uint16_t button)
{

    /* Disable TIM1 CC4 Interrupt */
    TIM_ITConfig(TIM1, TIM_IT_CC4, DISABLE);

    BUTTON_ResetDebouncedState(BUTTON1);

    HAL_Notify_Button_State(BUTTON1, false);

    /* Enable BUTTON1 Interrupt */
    BUTTON_EXTI_Config(BUTTON1, ENABLE);

}
示例#6
0
/*******************************************************************************
 * Function Name  : EXTI2_IRQHandler
 * Description    : This function handles EXTI2 interrupt request.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
void EXTI2_IRQHandler(void)
{
	if (EXTI_GetITStatus(EXTI_Line2) != RESET)//BUTTON1_EXTI_LINE
	{
		/* Clear the EXTI line pending bit */
		EXTI_ClearITPendingBit(EXTI_Line2);//BUTTON1_EXTI_LINE

		BUTTON_DEBOUNCED_TIME[BUTTON1] = 0x00;

		/* Disable BUTTON1 Interrupt */
		BUTTON_EXTI_Config(BUTTON1, DISABLE);

		/* Enable TIM1 CC4 Interrupt */
		TIM_ITConfig(TIM1, TIM_IT_CC4, ENABLE);
	}
}
示例#7
0
/**
 * @brief  This function handles BUTTON EXTI Handler.
 * @param  None
 * @retval None
 */
void BUTTON1_EXTI_IRQ_HANDLER(void)
{
    if (EXTI_GetITStatus(BUTTON1_EXTI_LINE) != RESET)
    {
        /* Clear the EXTI line pending bit */
        EXTI_ClearITPendingBit(BUTTON1_EXTI_LINE);

        BUTTON_DEBOUNCED_TIME[BUTTON1] = 0x00;

        /* Disable BUTTON1 Interrupt */
        BUTTON_EXTI_Config(BUTTON1, DISABLE);

        /* Enable TIM2 CC1 Interrupt */
        TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
    }
}
/**
 * @brief  This function handles EXTI2_IRQ or EXTI_9_5_IRQ Handler.
 * @param  None
 * @retval None
 */
void Handle_Mode_Button_EXTI_irq(void)
{
    if (EXTI_GetITStatus(BUTTON1_EXTI_LINE) != RESET)
    {
        /* Clear the EXTI line pending bit (cleared in WICED GPIO IRQ handler) */
        EXTI_ClearITPendingBit(BUTTON1_EXTI_LINE);

        BUTTON_DEBOUNCED_TIME[BUTTON1] = 0x00;

        /* Disable BUTTON1 Interrupt */
        BUTTON_EXTI_Config(BUTTON1, DISABLE);

        /* Enable TIM2 CC1 Interrupt */
        TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
    }

}
示例#9
0
/*******************************************************************************
 * Function Name  : TIM1_CC_IRQHandler
 * Description    : This function handles TIM1 Capture Compare interrupt request.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
void TIM1_CC_IRQHandler(void)
{
	if (TIM_GetITStatus(TIM1, TIM_IT_CC4) != RESET)
	{
		TIM_ClearITPendingBit(TIM1, TIM_IT_CC4);

		if (BUTTON_GetState(BUTTON1) == BUTTON1_PRESSED)
		{
			BUTTON_DEBOUNCED_TIME[BUTTON1] += BUTTON_DEBOUNCE_INTERVAL;
		}
		else
		{
			/* Disable TIM1 CC4 Interrupt */
			TIM_ITConfig(TIM1, TIM_IT_CC4, DISABLE);

			/* Enable BUTTON1 Interrupt */
			BUTTON_EXTI_Config(BUTTON1, ENABLE);
		}
	}
}
示例#10
0
void BUTTON_Init(Button_TypeDef button, ButtonMode_TypeDef Button_Mode) {

    if (!systick_button_timer.enable) {
        // Initialize button timer
        button_timer_init();
    }

    // Configure button pin
    HAL_Pin_Mode(HAL_Buttons[button].pin, HAL_Buttons[button].interrupt_mode == RISING ? INPUT_PULLDOWN : INPUT_PULLUP);
    if (Button_Mode == BUTTON_MODE_EXTI)  {
        /* Attach GPIOTE Interrupt */
        BUTTON_EXTI_Config(button, ENABLE);
    }

    // Check status when starting up
    if (HAL_Buttons[button].pin != PIN_INVALID && 
        BUTTON_GetState(button) == (HAL_Buttons[button].interrupt_mode == RISING ? 1 : 0)) 
    {
        HAL_Buttons[button].active = true;
        button_timer_start();
    }
}
示例#11
0
/*******************************************************************************
 * Function Name  : EXTI15_10_IRQHandler
 * Description    : This function handles EXTI15_10 interrupt request.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
void EXTI15_10_IRQHandler(void)
{
    //EXTI_Line10 and EXTI_Line12 support is not required for CORE_V02

    if (EXTI_GetITStatus(EXTI_Line13) != RESET)
    {
        /* Clear the EXTI line pending bit */
        EXTI_ClearITPendingBit(EXTI_Line13);

        if(NULL != Wiring_EXTI_Interrupt_Handler)
        {
            Wiring_EXTI_Interrupt_Handler(13);
        }
    }

    if (EXTI_GetITStatus(EXTI_Line14) != RESET)
    {
        /* Clear the EXTI line pending bit */
        EXTI_ClearITPendingBit(EXTI_Line14);

        if(NULL != Wiring_EXTI_Interrupt_Handler)
        {
            Wiring_EXTI_Interrupt_Handler(14);
        }
    }

    if (EXTI_GetITStatus(EXTI_Line15) != RESET)
    {
        /* Clear the EXTI line pending bit */
        EXTI_ClearITPendingBit(EXTI_Line15);

        if(NULL != Wiring_EXTI_Interrupt_Handler)
        {
            Wiring_EXTI_Interrupt_Handler(15);
        }
    }

    if (EXTI_GetITStatus(EXTI_Line11) != RESET)//CC3000_WIFI_INT_EXTI_LINE
    {
        /* Clear the EXTI line pending bit */
        EXTI_ClearITPendingBit(EXTI_Line11);//CC3000_WIFI_INT_EXTI_LINE

        SPI_EXTI_IntHandler();
    }

#if defined (USE_SPARK_CORE_V01)
    if (EXTI_GetITStatus(EXTI_Line10) != RESET)//BUTTON1_EXTI_LINE
    {
        /* Clear the EXTI line pending bit */
        EXTI_ClearITPendingBit(EXTI_Line10);//BUTTON1_EXTI_LINE

        BUTTON_DEBOUNCED_TIME[BUTTON1] = 0x00;

        /* Disable BUTTON1 Interrupt */
        BUTTON_EXTI_Config(BUTTON1, DISABLE);

        /* Enable TIM1 CC4 Interrupt */
        TIM_ITConfig(TIM1, TIM_IT_CC4, ENABLE);
    }
#endif
}