/* 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.
*
* GDSII-Converter 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/>.
*/

#ifndef __ROTARY_ENCODER_H__
#define __ROTARY_ENCODER_H__

#include <stm32/stm32f4xx.h>

#define ROTARY_ENCODER_TIMER TIM5
#define ROTARY_ENCODER_TIMER_RCC_MASK RCC_APB1ENR_TIM5EN
#define ROTARY_ENCODER_PIN1 0
#define ROTARY_ENCODER_PIN2 1
#define ROTARY_ENCODER_PORT GPIOA
#define ROTARY_ENCODER_PORT_ALTFUNC 2
#define ROTARY_ENCODER_RCC_MASK RCC_AHB1ENR_GPIOAEN

void rotary_encoder_setup(void);

uint32_t rotary_encoder_get_abs_val(void);

int32_t rotary_encoder_get_change_val(void);

void rotary_encoder_stop(void);

void rotary_encoder_zero(void);

#endif /* __ROTARY_ENCODER_H__ */
