63 lines
2.0 KiB
C
Executable File
63 lines
2.0 KiB
C
Executable File
//! \file stm32f4_gpio.h
|
|
//! \author tkl
|
|
//! \date Mai 8, 2012
|
|
//! \brief Header file of the stm32f4xx architecture dependent gpio driver.
|
|
#ifndef STM32F4_GPIO_H_
|
|
#define STM32F4_GPIO_H_
|
|
|
|
//! callback for the external interrupt
|
|
typedef void* (*gpio_ext_it_cb_t)(void*);
|
|
|
|
//! \brief stm32f4 gpio device
|
|
struct stm32f4_gpio {
|
|
GPIO_TypeDef *port; //!< Gpio port
|
|
const GPIO_InitTypeDef *pin; //!< Gpio pin
|
|
const EXTI_InitTypeDef *exti; //!< Gpio exit it (could be NULL)
|
|
const NVIC_InitTypeDef *nvic; //!< Gpio nvic (could be NULL)
|
|
gpio_ext_it_cb_t ext_it_cb; //!< Gpio ext it callback (could be NULL)
|
|
void *param; //!< Parameter for the callback
|
|
};
|
|
|
|
//! \brief Open a gpio.
|
|
//! \param gpio The gpio to open. Must be of type stm32f4_gpio_t.
|
|
//! \retval -1 in error case.
|
|
int stm32f4_gpio_open(const void *gpio);
|
|
|
|
//! \brief Close a gpio.
|
|
//! \param gpio The gpio to close. Must be of type stm32f4_gpio_t.
|
|
//! \retval -1 in error case.
|
|
int stm32f4_gpio_close(const void *gpio);
|
|
|
|
//! \brief Read a gpio.
|
|
//! \param gpio The gpio to read. Must be of type stm32f4_gpio_t.
|
|
//! \return read out value.
|
|
char stm32f4_gpio_read(const void *gpio);
|
|
|
|
//! \brief Write to a gpio.
|
|
//! \param gpio The gpio to write. Must be of type stm32f4_gpio_t.
|
|
//! \param byte The data to write.
|
|
void stm32f4_gpio_write(const void *gpio, char byte);
|
|
|
|
//! \brief Toggle a gpio.
|
|
//! \param gpio The gpio to read. Must be of type stm32f4_gpio_t.
|
|
void stm32f4_gpio_toggle(const void *gpio);
|
|
|
|
//! \brief Set the callback for a gpio pin external interrupt.
|
|
//! \param gpio The gpio to set call back for. Must be of type stm32f4_gpio_t.
|
|
//! \param callback The function pointer to call back.
|
|
//! \param param The parameter for the call back.
|
|
//! \retval -1 in error case.
|
|
int stm32f4_gpio_set_exti_callback(const void *gpio, const void *callback,
|
|
const void *param);
|
|
|
|
static const struct gpio_fp gpio_fp = {
|
|
stm32f4_gpio_open,
|
|
stm32f4_gpio_close,
|
|
stm32f4_gpio_read,
|
|
stm32f4_gpio_write,
|
|
stm32f4_gpio_toggle,
|
|
stm32f4_gpio_set_exti_callback
|
|
};
|
|
|
|
#endif /* STM32F4_GPIO_H_ */
|