gpio: add gpio_pin_interrupt_configure function
This commit moves interrupt configuration for a single pin from gpio_pin_configure to gpio_pin_interrupt_configure function. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
This commit is contained in:
parent
d6191b5781
commit
33193a57eb
2 changed files with 46 additions and 0 deletions
|
@ -76,6 +76,15 @@ static inline int z_vrfy_gpio_port_toggle_bits(struct device *port,
|
||||||
}
|
}
|
||||||
#include <syscalls/gpio_port_toggle_bits_mrsh.c>
|
#include <syscalls/gpio_port_toggle_bits_mrsh.c>
|
||||||
|
|
||||||
|
static inline int z_vrfy_gpio_pin_interrupt_configure(struct device *port,
|
||||||
|
unsigned int pin, unsigned int flags)
|
||||||
|
{
|
||||||
|
Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, pin_interrupt_configure));
|
||||||
|
return z_impl_gpio_pin_interrupt_configure((struct device *)port, pin,
|
||||||
|
flags);
|
||||||
|
}
|
||||||
|
#include <syscalls/gpio_pin_interrupt_configure_mrsh.c>
|
||||||
|
|
||||||
static inline int z_vrfy_gpio_enable_callback(struct device *port,
|
static inline int z_vrfy_gpio_enable_callback(struct device *port,
|
||||||
int access_op, u32_t pin)
|
int access_op, u32_t pin)
|
||||||
{
|
{
|
||||||
|
|
|
@ -450,6 +450,8 @@ struct gpio_driver_api {
|
||||||
int (*port_set_bits_raw)(struct device *port, gpio_pins_t pins);
|
int (*port_set_bits_raw)(struct device *port, gpio_pins_t pins);
|
||||||
int (*port_clear_bits_raw)(struct device *port, gpio_pins_t pins);
|
int (*port_clear_bits_raw)(struct device *port, gpio_pins_t pins);
|
||||||
int (*port_toggle_bits)(struct device *port, gpio_pins_t pins);
|
int (*port_toggle_bits)(struct device *port, gpio_pins_t pins);
|
||||||
|
int (*pin_interrupt_configure)(struct device *port, unsigned int pin,
|
||||||
|
unsigned int flags);
|
||||||
int (*manage_callback)(struct device *port, struct gpio_callback *cb,
|
int (*manage_callback)(struct device *port, struct gpio_callback *cb,
|
||||||
bool set);
|
bool set);
|
||||||
int (*enable_callback)(struct device *port, int access_op, u32_t pin);
|
int (*enable_callback)(struct device *port, int access_op, u32_t pin);
|
||||||
|
@ -966,6 +968,41 @@ static inline int gpio_pin_read(struct device *port, u32_t pin,
|
||||||
return gpio_read(port, GPIO_ACCESS_BY_PIN, pin, value);
|
return gpio_read(port, GPIO_ACCESS_BY_PIN, pin, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure pin interrupt.
|
||||||
|
*
|
||||||
|
* @note This function can also be used to configure interrupts on pins
|
||||||
|
* not controlled directly by the GPIO module. That is, pins which are
|
||||||
|
* routed to other modules such as I2C, SPI, UART.
|
||||||
|
*
|
||||||
|
* @param port Pointer to device structure for the driver instance.
|
||||||
|
* @param pin Pin number.
|
||||||
|
* @param flags Interrupt configuration flags as defined by GPIO_INT_*.
|
||||||
|
*
|
||||||
|
* @retval 0 If successful.
|
||||||
|
* @retval -ENOTSUP If any of the configuration options is not supported.
|
||||||
|
* @retval -EINVAL Invalid argument.
|
||||||
|
* @retval -EBUSY Interrupt line required to configure pin interrupt is
|
||||||
|
* already in use.
|
||||||
|
*/
|
||||||
|
__syscall int gpio_pin_interrupt_configure(struct device *port,
|
||||||
|
unsigned int pin, unsigned int flags);
|
||||||
|
|
||||||
|
static inline int z_impl_gpio_pin_interrupt_configure(struct device *port,
|
||||||
|
unsigned int pin, unsigned int flags)
|
||||||
|
{
|
||||||
|
const struct gpio_driver_api *api =
|
||||||
|
(const struct gpio_driver_api *)port->driver_api;
|
||||||
|
|
||||||
|
__ASSERT(pin < GPIO_MAX_PINS_PER_PORT, "Invalid pin number");
|
||||||
|
|
||||||
|
__ASSERT(((flags & GPIO_INT_ENABLE) == 0) ||
|
||||||
|
((flags & (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1)) != 0),
|
||||||
|
"At least one of GPIO_INT_LOW_0, GPIO_INT_HIGH_1 has to be "
|
||||||
|
"enabled.");
|
||||||
|
return api->pin_interrupt_configure(port, pin, flags);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Helper to initialize a struct gpio_callback properly
|
* @brief Helper to initialize a struct gpio_callback properly
|
||||||
* @param callback A valid Application's callback structure pointer.
|
* @param callback A valid Application's callback structure pointer.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue