reflow-oven-control-sw/stm-firmware/button.c

46 lines
1.4 KiB
C
Raw Normal View History

/* Reflow Oven Controller
*
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of the Reflow Oven Controller Project.
*
* The reflow oven controller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the reflow oven controller project.
* If not, see <http://www.gnu.org/licenses/>.
*/
2020-02-23 21:48:52 +01:00
#include <stm32/stm32f4xx.h>
#include <reflow-controller/button.h>
2020-02-23 21:48:52 +01:00
#include <stm-periph/clock-enable-manager.h>
#include <stdint.h>
static volatile uint64_t to_active_timestamp;
void button_init()
{
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(BUTTON_RCC_MASK));
BUTTON_PORT->MODER &= MODER_DELETE(BUTTON_PIN);
BUTTON_PORT->PUPDR &= PUPDR_DELETE(BUTTON_PIN);
BUTTON_PORT->PUPDR |= PULLUP(BUTTON_PIN);
}
enum button_state button_read_event();
void button_deinit()
{
BUTTON_PORT->MODER &= MODER_DELETE(BUTTON_PIN);
BUTTON_PORT->PUPDR &= PUPDR_DELETE(BUTTON_PIN);
rcc_manager_disable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(BUTTON_RCC_MASK));
}