reflow-oven-control-sw/stm-firmware/include/reflow-controller/digio.h

178 lines
4.0 KiB
C
Raw Permalink Normal View History

2020-02-15 22:09:55 +01:00
/* 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/>.
*/
2021-05-22 17:02:37 +02:00
/**
* @addtogroup digio
* @{
*/
#ifndef __DIGIO_H__
#define __DIGIO_H__
#include <stdbool.h>
#include <stdint.h>
#include <helper-macros/helper-macros.h>
2021-05-22 17:02:37 +02:00
/**
* @brief Port the digital I/Os are located in
*/
#define DIGIO_PORT GPIOB
2021-05-22 17:02:37 +02:00
/**
* @brief Reset and clock control bit mask to enable clock of @ref DIGIO_PORT
*/
#define DIGIO_RCC_MASK RCC_AHB1ENR_GPIOBEN
2021-05-22 17:02:37 +02:00
/**
* @brief List of the pins used by the digio module
*/
#define DIGIO_PINS 4,5,6,7
2021-05-22 17:02:37 +02:00
#if defined(DEBUGBUILD) || defined(UART_ON_DEBUG_HEADER)
#define DIGIO_INOUT_DEFAULT 0,0,0,0
#define DIGIO_ALTFUNC_DEFAULT 0,0,0,0
#else
#define DIGIO_INOUT_DEFAULT 0,0,2,2
#define DIGIO_ALTFUNC_DEFAULT 0,0,7,7
#endif
2021-05-22 17:02:37 +02:00
/**
* @brief The port, the loudspeaker is connected to
*/
#define BEEPER_PORT GPIOB
2021-05-22 17:02:37 +02:00
/**
* @brief The RCC mask for @ref BEEPER_PORT
*/
#define BEEPER_RCC_MASK RCC_AHB1ENR_GPIOBEN
2021-05-22 17:02:37 +02:00
/**
* @brief Enable all clocks and setup pins in default setting
* @warning This function uses @ref rcc_manager_enable_clock to enable the clocks. Therefore, it must not be called
* multiple times.
*/
void digio_setup_default_all(void);
2021-05-22 17:02:37 +02:00
/**
* @brief Set up a DIGIO pin.
*
* Set up a digital IO pin config. For the index association see the @ref DIGIO_PINS table.
*
* @param num DIGIO number starting with 0
* @param in_out In: 0, Out 1, alternate function: 2
* @param alt_func Alternate function to set. Consult datasheet of STM32F407
*/
void digio_setup_pin(uint8_t num, uint8_t in_out, uint8_t alt_func);
2021-05-22 17:02:37 +02:00
/**
* @brief Set a digio output port
* @param num Digio channel number
* @param val Value: 0 or 1.
*/
void digio_set(uint8_t num, int val);
2021-05-22 17:02:37 +02:00
/**
* @brief Read the state of a digio channel
* @param num Channel number
* @return digital pin level.
*/
int digio_get(uint8_t num);
2021-05-22 17:02:37 +02:00
/**
* @brief Port the LEDs are connected to
*/
#define LED_PORT GPIOB
2021-05-22 17:02:37 +02:00
/**
* @brief RCC mask to enable clock for @ref LED_PORT
*/
#define LED_RCC_MASK RCC_AHB1ENR_GPIOBEN
2021-05-22 17:02:37 +02:00
/**
* @brief Pin list on @ref LED_PORT that are connected to LEDs
*/
#define LED_PINS 2,3
2021-05-22 17:02:37 +02:00
/**
* @brief Set up the LED Port
*/
void led_setup(void);
2021-05-22 17:02:37 +02:00
/**
* @brief Set the LED status
* @param num LED number
* @param val Value: 1 on, 0 off.
*/
void led_set(uint8_t num, int val);
2021-05-22 17:02:37 +02:00
/**
* @brief Get the state of a LED
* @param num LED number
* @return Stateof the LED: 0 off, 1 on; -1 in case of an error
*/
int led_get(uint8_t num);
2021-05-22 17:02:37 +02:00
/**
* @brief Port to use for the loudpseaker
*/
#define LOUDSPEAKER_PORT GPIOB
2021-05-22 17:02:37 +02:00
/**
* @brief RCC mask for @ref LOUDSPEAKER_PORT
*/
#define LOUDSPEAKER_RCC_MASK RCC_AHB1ENR_GPIOBEN
2021-05-22 17:02:37 +02:00
/**
* @brief Pin on @ref LOUDSPEAKER_PORT the speaker is cnnected to
*/
#define LOUDSPEAKER_PIN 1
2021-05-22 17:02:37 +02:00
/**
* @brief The loudpseaker requires a frequncy signal instead of a simple on/off signal.
*/
2020-05-24 23:35:17 +02:00
#define LOUDSPEAKER_MULTIFREQ 1
2021-05-22 17:02:37 +02:00
/**
* @brief Defautl timer relaod for the frequency of the speaker. Only relevant if @ref LOUDSPEAKER_MULTIFREQ is 1.
*/
#define LOUDSPEAKER_MULTIFREQ_DEFAULT 9
2021-05-22 17:02:37 +02:00
/**
* @brief Setup the loudspeaker
*/
void loudspeaker_setup(void);
2021-05-22 17:02:37 +02:00
/**
* @brief Set the loudspeaker value
* @param val Value
*/
2020-05-24 23:35:17 +02:00
void loudspeaker_set(uint16_t val);
2021-05-22 17:02:37 +02:00
/**
* @brief Get current value of the loadspeaker
* @return Value
*/
uint16_t loudspeaker_get(void);
#endif /* __DIGIO_H__ */
2021-05-22 17:02:37 +02:00
/** @} */