mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-09-29 05:17:33 +00:00
Move STM32 related code to sta-stm32-core repo
This commit is contained in:
82
include/sta/stm32/gpio_pin.hpp
Normal file
82
include/sta/stm32/gpio_pin.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Wrapper for STM32 GPIO pins.
|
||||
*/
|
||||
#ifndef STA_STM32_GPIO_PIN_HPP
|
||||
#define STA_STM32_GPIO_PIN_HPP
|
||||
|
||||
/**
|
||||
* @defgroup stm32GPIO GPIO
|
||||
* @ingroup stm32
|
||||
* @brief STM GPIO module.
|
||||
*/
|
||||
|
||||
#ifdef DOXYGEN
|
||||
/**
|
||||
* @def STA_STM32_GPIO_ENABLE
|
||||
* @brief Enable module.
|
||||
*
|
||||
* @ingroup stm32BuildConfig
|
||||
*/
|
||||
# define STA_STM32_GPIO_ENABLE
|
||||
#endif // DOXYGEN
|
||||
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_STM32_GPIO_ENABLE
|
||||
|
||||
#include <sta/intf/gpio_pin.hpp>
|
||||
|
||||
#include <sta/stm32/hal.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Container for STM GPIO Pin data.
|
||||
*
|
||||
* @ingroup stm32GPIO
|
||||
*/
|
||||
class STM32GpioPin : public GpioPin
|
||||
{
|
||||
public:
|
||||
STM32GpioPin(GPIO_TypeDef * port, uint16_t pin);
|
||||
|
||||
void setState(GpioPinState state) override;
|
||||
|
||||
GPIO_TypeDef * getPort() const;
|
||||
uint16_t getPin() const;
|
||||
uint8_t getIndex() const;
|
||||
|
||||
private:
|
||||
GPIO_TypeDef * port_; /**< GPIO port */
|
||||
uint16_t pin_; /**< GPIO pin */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Interrupt trigger edge.
|
||||
*/
|
||||
enum class InterruptEdge
|
||||
{
|
||||
RISING, /**< Rising edge */
|
||||
FALLING, /**< Falling edge */
|
||||
BOTH /**< Rising and falling edge */
|
||||
};
|
||||
|
||||
bool isInterruptEdge(const STM32GpioPin & pin, InterruptEdge edge);
|
||||
} // namespace sta
|
||||
|
||||
/**
|
||||
* @brief Create STM32GpioPin object from pin label.
|
||||
*
|
||||
* @param label Pin label
|
||||
*
|
||||
* @ingroup stm32GPIO
|
||||
*/
|
||||
#define STA_STM32_GPIO_PIN(label) sta::STM32GpioPin{label##_GPIO_Port, label##_Pin}
|
||||
|
||||
|
||||
#endif // STA_STM32_GPIO_ENABLE
|
||||
|
||||
#endif // STA_STM32_GPIO_PIN_HPP
|
Reference in New Issue
Block a user