mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-06 10:27:34 +00:00
Added I2C support for raspi & first rework of debugging
This commit is contained in:
113
include/sta/devices/stm32/gpio_pin.hpp
Normal file
113
include/sta/devices/stm32/gpio_pin.hpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Wrapper for STM32 GPIO pins.
|
||||
*/
|
||||
#ifndef STA_CORE_STM32_GPIO_PIN_HPP
|
||||
#define STA_CORE_STM32_GPIO_PIN_HPP
|
||||
|
||||
|
||||
// Only enable module on STM32 platform w/ HAL GPIO module enabled
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_PLATFORM_STM32
|
||||
# include <sta/stm32/hal.hpp>
|
||||
# ifdef HAL_GPIO_MODULE_ENABLED
|
||||
# define STA_STM32_GPIO_ENABLED
|
||||
# endif // HAL_GPIO_MODULE_ENABLED
|
||||
#endif // STA_PLATFORM_STM32
|
||||
|
||||
|
||||
#if defined(STA_STM32_GPIO_ENABLED) || defined(DOXYGEN)
|
||||
|
||||
#include <sta/gpio_pin.hpp>
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup sta_core_stm32_gpio GPIO
|
||||
* @ingroup sta_core_stm32
|
||||
* @brief STM32 GPIO module.
|
||||
*/
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @ingroup sta_core_stm32_gpio
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Container for STM GPIO Pin data.
|
||||
*/
|
||||
class STM32GpioPin : public GpioPin
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param port GPIO port
|
||||
* @param pin Pin index
|
||||
*/
|
||||
STM32GpioPin(GPIO_TypeDef * port, uint16_t pin);
|
||||
|
||||
void setState(GpioPinState state) override;
|
||||
|
||||
/**
|
||||
* @brief Get GPIO port for pin.
|
||||
*
|
||||
* @return GPIO port
|
||||
*/
|
||||
GPIO_TypeDef * getPort() const;
|
||||
/**
|
||||
* @brief Get pin index for pin.
|
||||
*
|
||||
* @return Pin index
|
||||
*/
|
||||
uint16_t getPin() const;
|
||||
/**
|
||||
* @brief Get GPIO port index for pin.
|
||||
*
|
||||
* @return GPIO port index
|
||||
*/
|
||||
uint8_t getPortIndex() 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 */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Check pin EXIT pin configuration.
|
||||
*
|
||||
* @param pin GPIO pin
|
||||
* @param edge Interrupt trigger edge
|
||||
* @return True if EXIT pin and trigger edge matches
|
||||
*/
|
||||
bool isInterruptEdge(const STM32GpioPin & pin, InterruptEdge edge);
|
||||
|
||||
|
||||
/** @} */
|
||||
} // namespace sta
|
||||
|
||||
/**
|
||||
* @brief Create STM32GpioPin object from pin label.
|
||||
*
|
||||
* @param label Pin label
|
||||
*
|
||||
* @ingroup sta_core_stm32_gpio
|
||||
*/
|
||||
#define STA_STM32_GPIO_PIN(label) sta::STM32GpioPin{label##_GPIO_Port, label##_Pin}
|
||||
|
||||
|
||||
#endif // STA_STM32_GPIO_ENABLED
|
||||
|
||||
#endif // STA_CORE_STM32_GPIO_PIN_HPP
|
Reference in New Issue
Block a user