engine_control/source/firmware/kernel/driver/include/gpio.h
tkl 4eaea0c98b - folder structure reordered
- unnecessary drivers removed
2016-07-27 14:47:22 +02:00

79 lines
2.6 KiB
C
Executable File

/*! \file gpio.h
* \author tkl
* \date Feb 13, 2012
* \brief Header file of the architecture independent gpio driver.
*/
#ifndef GPIO_H_
#define GPIO_H_
//! \brief Function pointer to the open function.
typedef int (*gpio_fp_open_t)(const void*);
//! \brief Function pointer to the close function.
typedef int (*gpio_fp_close_t)(const void*);
//! \brief Function pointer to the read function.
typedef char (*gpio_fp_read_t)(const void*);
//! \brief Function pointer to the write function.
typedef void (*gpio_fp_write_t)(const void*, char);
//! \brief Function pointer to the toggle function.
typedef void (*gpio_fp_toggle_t)(const void*);
//! \brief Function pointer to the set_callback function.
typedef int (*gpio_fp_set_cb_t)(const void*, const void*, const void*);
//! \brief Contains the function pointer to access the gpio driver.
struct gpio_fp {
const gpio_fp_open_t open; //!< Function pointer to the open function.
const gpio_fp_close_t close; //!< Function pointer to the close function.
const gpio_fp_read_t read; //!< Function pointer to the read function.
const gpio_fp_write_t write; //!< Function pointer to the write function.
const gpio_fp_toggle_t toggle; //!< Function pointer to the toggle function.
const gpio_fp_set_cb_t set_cb; //!< Function pointer to the set_callback function.
};
//! \brief Contains the architecture depended device and the access functions to the gpio driver.
struct gpio {
const void *arch_dep_device; //!< Architecture depended gpio device (i.e. stm32f10x_gpio_t).
const struct gpio_fp *fp; //!< Function pointer for the gpio driver access.
};
/*! \brief Open a gpio pin.
* \param device The gpio to open.
* \retval -1 in error case.
*/
int gpio_open(const struct gpio *device);
/*! \brief Close a gpio pin
* \param device The gpio to close.
* \retval -1 in error case.
*/
int gpio_close(const struct gpio *device);
/*! \brief read from a gpio pin
* \param device The gpio to read from
* \return Read out value.
*/
char gpio_read(const struct gpio *device);
/*! \brief write to a gpio pin
* \param device The gpio to write to.
* \param byte The value to write.
*/
void gpio_write(const struct gpio *device, char byte);
//! \brief toggle a gpio pin
//! \param device the gpio to toggle.
void gpio_toggle(const struct gpio *device);
//! \brief set the callback for a gpio pin external interrupt
//! \param device The gpio to set a callback for.
//! \param callback The function pointer to be called back.
//! \param param The parameter for the call back.
int gpio_set_exti_callback(const struct gpio *device, const void *callback,
const void *param);
#endif /* GPIO_H_ */